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:
softwarefactory-project-zuul[bot] 2020-03-25 15:33:37 +00:00 committed by GitHub
commit ee4dcd2055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -166,13 +166,13 @@ class Page(object):
return self.__class__
@classmethod
def from_json(cls, raw):
def from_json(cls, raw, connection=None):
resp = Response()
data = json.dumps(raw)
resp._content = bytes(data, 'utf-8')
resp.encoding = 'utf-8'
resp.status_code = 200
return cls(r=resp)
return cls(r=resp, connection=connection)
def page_identity(self, response, request_json=None):
"""Takes a `requests.Response` and
@ -283,7 +283,7 @@ class Page(object):
json['results'] = []
for page in paged_results:
json['results'].extend(page)
page = self.__class__.from_json(json)
page = self.__class__.from_json(json, connection=self.connection)
return page
def head(self):

View File

@ -177,7 +177,7 @@ def parse_resource(client, skip_deprecated=False):
}
_filter = 'key, value'
formatted = format_response(
Page.from_json(response),
Page.from_json(response, connection=client.root.connection),
fmt=client.get_config('format'),
filter=_filter
)