mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Merge pull request #6403 from jbradberry/awxkit-from-json-connection
Add a connection kwarg to Page.from_json Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -166,13 +166,13 @@ class Page(object):
|
|||||||
return self.__class__
|
return self.__class__
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, raw):
|
def from_json(cls, raw, connection=None):
|
||||||
resp = Response()
|
resp = Response()
|
||||||
data = json.dumps(raw)
|
data = json.dumps(raw)
|
||||||
resp._content = bytes(data, 'utf-8')
|
resp._content = bytes(data, 'utf-8')
|
||||||
resp.encoding = 'utf-8'
|
resp.encoding = 'utf-8'
|
||||||
resp.status_code = 200
|
resp.status_code = 200
|
||||||
return cls(r=resp)
|
return cls(r=resp, connection=connection)
|
||||||
|
|
||||||
def page_identity(self, response, request_json=None):
|
def page_identity(self, response, request_json=None):
|
||||||
"""Takes a `requests.Response` and
|
"""Takes a `requests.Response` and
|
||||||
@@ -283,7 +283,7 @@ class Page(object):
|
|||||||
json['results'] = []
|
json['results'] = []
|
||||||
for page in paged_results:
|
for page in paged_results:
|
||||||
json['results'].extend(page)
|
json['results'].extend(page)
|
||||||
page = self.__class__.from_json(json)
|
page = self.__class__.from_json(json, connection=self.connection)
|
||||||
return page
|
return page
|
||||||
|
|
||||||
def head(self):
|
def head(self):
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ def parse_resource(client, skip_deprecated=False):
|
|||||||
}
|
}
|
||||||
_filter = 'key, value'
|
_filter = 'key, value'
|
||||||
formatted = format_response(
|
formatted = format_response(
|
||||||
Page.from_json(response),
|
Page.from_json(response, connection=client.root.connection),
|
||||||
fmt=client.get_config('format'),
|
fmt=client.get_config('format'),
|
||||||
filter=_filter
|
filter=_filter
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user