schema: exclude local commands

Commands inherited from Local can't be executed remotely, so exclude them
from API schema.

https://fedorahosted.org/freeipa/ticket/4739

Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Jan Cholasta
2016-06-14 13:37:23 +02:00
parent f7240c6df8
commit a64aba36a4

View File

@@ -10,7 +10,7 @@ import six
from ipalib import errors
from ipalib.crud import PKQuery, Retrieve, Search
from ipalib.frontend import Command, Method, Object
from ipalib.frontend import Command, Local, Method, Object
from ipalib.output import Entry, ListOfEntries, ListOfPrimaryKeys, PrimaryKey
from ipalib.parameters import Bool, Dict, Flag, Int, Str
from ipalib.plugable import Registry
@@ -188,8 +188,12 @@ class command(MetaObject):
def _retrieve(self, name, **kwargs):
try:
return self.api.Command[name]
command = self.api.Command[name]
if not isinstance(command, Local):
return command
except KeyError:
pass
raise errors.NotFound(
reason=_("%(pkey)s: %(oname)s not found") % {
'pkey': name, 'oname': self.name,
@@ -197,7 +201,9 @@ class command(MetaObject):
)
def _search(self, **kwargs):
return self.api.Command()
for command in self.api.Command():
if not isinstance(command, Local):
yield command
@register()