mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Take 2: Extensible return values and validation; steps toward a single output_for_cli(); enable more webUI stuff
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
Base classes for standard CRUD operations.
|
||||
"""
|
||||
|
||||
import backend, frontend, parameters
|
||||
import backend, frontend, parameters, output
|
||||
|
||||
|
||||
class Create(frontend.Method):
|
||||
@@ -28,6 +28,8 @@ class Create(frontend.Method):
|
||||
Create a new entry.
|
||||
"""
|
||||
|
||||
has_output = output.standard_entry
|
||||
|
||||
def get_args(self):
|
||||
if self.obj.primary_key:
|
||||
yield self.obj.primary_key.clone(attribute=True)
|
||||
@@ -53,18 +55,21 @@ class PKQuery(frontend.Method):
|
||||
yield self.obj.primary_key.clone(attribute=True, query=True)
|
||||
|
||||
|
||||
|
||||
class Retrieve(PKQuery):
|
||||
"""
|
||||
Retrieve an entry by its primary key.
|
||||
"""
|
||||
|
||||
has_output = output.standard_entry
|
||||
|
||||
|
||||
class Update(PKQuery):
|
||||
"""
|
||||
Update one or more attributes on an entry.
|
||||
"""
|
||||
|
||||
has_output = output.standard_entry
|
||||
|
||||
def get_options(self):
|
||||
if self.extra_options_first:
|
||||
for option in super(Update, self).get_options():
|
||||
@@ -75,17 +80,22 @@ class Update(PKQuery):
|
||||
for option in super(Update, self).get_options():
|
||||
yield option
|
||||
|
||||
|
||||
class Delete(PKQuery):
|
||||
"""
|
||||
Delete one or more entries.
|
||||
"""
|
||||
|
||||
has_output = output.standard_delete
|
||||
|
||||
|
||||
class Search(frontend.Method):
|
||||
"""
|
||||
Retrieve all entries that match a given search criteria.
|
||||
"""
|
||||
|
||||
has_output = output.standard_list_of_entries
|
||||
|
||||
def get_args(self):
|
||||
yield parameters.Str('criteria?')
|
||||
|
||||
@@ -176,4 +186,3 @@ class CrudBackend(backend.Connectible):
|
||||
this method should return an empty iterable.
|
||||
"""
|
||||
raise NotImplementedError('%s.search()' % self.name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user