mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 06:29:25 -02:30
Actually query the API for the user or users requested
This commit is contained in:
@@ -132,12 +132,14 @@ class Export(CustomCommand):
|
|||||||
resources.add_argument('--users', nargs='?', const='')
|
resources.add_argument('--users', nargs='?', const='')
|
||||||
|
|
||||||
def get_resources(self, client, resource, value):
|
def get_resources(self, client, resource, value):
|
||||||
|
api_resource = getattr(client.v2, resource)
|
||||||
if value:
|
if value:
|
||||||
from .options import pk_or_name
|
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:
|
else:
|
||||||
print("Pulling all {}.".format(resource))
|
return api_resource.get(all_pages=True).json['results']
|
||||||
|
|
||||||
def handle(self, client, parser):
|
def handle(self, client, parser):
|
||||||
self.extend_parser(parser)
|
self.extend_parser(parser)
|
||||||
@@ -153,11 +155,10 @@ class Export(CustomCommand):
|
|||||||
for resource in ('users',):
|
for resource in ('users',):
|
||||||
value = getattr(parsed, resource, None)
|
value = getattr(parsed, resource, None)
|
||||||
if value is None:
|
if value is None:
|
||||||
print("Pulling no {}.".format(resource))
|
|
||||||
continue
|
continue
|
||||||
self.get_resources(client, resource, value)
|
resources = self.get_resources(client, resource, value) or []
|
||||||
|
|
||||||
data[resource] = {}
|
data[resource] = resources
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user