From 91135f638fe8e204e7cc42831e6930a7b4f5cb12 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Tue, 24 Mar 2020 15:27:51 -0400 Subject: [PATCH] Add a connection kwarg to Page.from_json if you don't reuse the connection when doing this, you lose your authentication. --- awxkit/awxkit/api/pages/page.py | 6 +++--- awxkit/awxkit/cli/resource.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/awxkit/awxkit/api/pages/page.py b/awxkit/awxkit/api/pages/page.py index fb21c26ea2..7e714bbb05 100644 --- a/awxkit/awxkit/api/pages/page.py +++ b/awxkit/awxkit/api/pages/page.py @@ -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): diff --git a/awxkit/awxkit/cli/resource.py b/awxkit/awxkit/cli/resource.py index 6937ab1f95..152b9a1cbb 100644 --- a/awxkit/awxkit/cli/resource.py +++ b/awxkit/awxkit/cli/resource.py @@ -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 )