mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Actually query the API for the user or users requested
This commit is contained in:
parent
4312395a3a
commit
f21d6b1fc4
@ -132,12 +132,14 @@ class Export(CustomCommand):
|
||||
resources.add_argument('--users', nargs='?', const='')
|
||||
|
||||
def get_resources(self, client, resource, value):
|
||||
api_resource = getattr(client.v2, resource)
|
||||
if value:
|
||||
from .options import pk_or_name
|
||||
|
||||
print("Pulling {}: {}".format(resource, pk_or_name(client.v2, resource, value)))
|
||||
pk = pk_or_name(client.v2, resource, value)
|
||||
return api_resource.get(id=pk).json['results']
|
||||
else:
|
||||
print("Pulling all {}.".format(resource))
|
||||
return api_resource.get(all_pages=True).json['results']
|
||||
|
||||
def handle(self, client, parser):
|
||||
self.extend_parser(parser)
|
||||
@ -153,11 +155,10 @@ class Export(CustomCommand):
|
||||
for resource in ('users',):
|
||||
value = getattr(parsed, resource, None)
|
||||
if value is None:
|
||||
print("Pulling no {}.".format(resource))
|
||||
continue
|
||||
self.get_resources(client, resource, value)
|
||||
resources = self.get_resources(client, resource, value) or []
|
||||
|
||||
data[resource] = {}
|
||||
data[resource] = resources
|
||||
|
||||
return data
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user