diff options
author | Zuul <zuul@review.openstack.org> | 2019-03-06 16:50:19 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2019-03-06 16:50:19 +0000 |
commit | a54ae8b4bb5c4d4d3037eca15ca39268077281d9 (patch) | |
tree | cdb63ee9eec65b56d2a398ab18f79df8b655fbfa | |
parent | f106a95ba37f49dfdc7448c773fb42942b79b4ce (diff) | |
parent | e288539298370c2018fc44fea832b73b703e75ea (diff) | |
download | python-designateclient-a54ae8b4bb5c4d4d3037eca15ca39268077281d9.tar.gz |
Merge "Update json module to jsonutils"
-rw-r--r-- | designateclient/client.py | 6 | ||||
-rw-r--r-- | designateclient/tests/base.py | 7 | ||||
-rw-r--r-- | designateclient/utils.py | 5 | ||||
-rw-r--r-- | designateclient/v1/domains.py | 7 | ||||
-rw-r--r-- | designateclient/v1/quotas.py | 5 | ||||
-rw-r--r-- | designateclient/v1/records.py | 6 | ||||
-rw-r--r-- | designateclient/v1/servers.py | 6 | ||||
-rw-r--r-- | requirements.txt | 1 |
8 files changed, 25 insertions, 18 deletions
diff --git a/designateclient/client.py b/designateclient/client.py index 8b7305b..27ac528 100644 --- a/designateclient/client.py +++ b/designateclient/client.py @@ -13,13 +13,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. + import abc -import json import six from six.moves.urllib import parse from stevedore import extension +from oslo_serialization import jsonutils + from designateclient import exceptions @@ -48,7 +50,7 @@ class Controller(object): content_type = headers.get('Content-Type') if headers else None if 'data' in kwargs and content_type in {None, 'application/json'}: - kwargs['data'] = json.dumps(kwargs['data']) + kwargs['data'] = jsonutils.dumps(kwargs['data']) def _post(self, url, response_key=None, **kwargs): self._serialize(kwargs) diff --git a/designateclient/tests/base.py b/designateclient/tests/base.py index e006861..2fc7c01 100644 --- a/designateclient/tests/base.py +++ b/designateclient/tests/base.py @@ -12,11 +12,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import json as json_ + import os import fixtures from keystoneauth1 import session as keystone_session +from oslo_serialization import jsonutils from oslotest import base as test from requests_mock.contrib import fixture as req_fixture import six @@ -81,7 +82,7 @@ class APITestCase(TestCase): base_url = self.get_base(base_url) if json: - kwargs['text'] = json_.dumps(json) + kwargs['text'] = jsonutils.dumps(json) headers = kwargs.setdefault('headers', {}) headers['Content-Type'] = 'application/json' @@ -103,7 +104,7 @@ class APITestCase(TestCase): def assertRequestBodyIs(self, body=None, json=None): last_request_body = self.requests.last_request.body if json: - val = json_.loads(last_request_body) + val = jsonutils.loads(last_request_body) self.assertEqual(json, val) elif body: self.assertEqual(body, last_request_body) diff --git a/designateclient/utils.py b/designateclient/utils.py index ff81f9b..d526fd8 100644 --- a/designateclient/utils.py +++ b/designateclient/utils.py @@ -14,10 +14,11 @@ # License for the specific language governing permissions and limitations # under the License. -import json import os import uuid +from oslo_serialization import jsonutils + from debtcollector import removals from keystoneauth1 import adapter from keystoneauth1.identity import generic @@ -51,7 +52,7 @@ def load_schema(version, name, package=None): schema_string = resource_string('schemas', version, '%s.json' % name, package=package) - return json.loads(schema_string.decode('utf-8')) + return jsonutils.loads(schema_string) def get_item_properties(item, fields, mixed_case_fields=[], formatters={}): diff --git a/designateclient/v1/domains.py b/designateclient/v1/domains.py index 2b556a5..1430bbf 100644 --- a/designateclient/v1/domains.py +++ b/designateclient/v1/domains.py @@ -13,7 +13,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import json + +from oslo_serialization import jsonutils from designateclient import client from designateclient import utils @@ -53,7 +54,7 @@ class DomainsController(client.CrudController): :param domain: A :class:`Domain` to create :returns: :class:`Domain` """ - response = self.client.post('/domains', data=json.dumps(domain)) + response = self.client.post('/domains', data=jsonutils.dumps(domain)) return Domain(response.json()) @@ -65,7 +66,7 @@ class DomainsController(client.CrudController): :returns: :class:`Domain` """ response = self.client.put('/domains/%s' % domain.id, - data=json.dumps(domain.changes)) + data=jsonutils.dumps(domain.changes)) return Domain(response.json()) diff --git a/designateclient/v1/quotas.py b/designateclient/v1/quotas.py index 32a1467..432edf2 100644 --- a/designateclient/v1/quotas.py +++ b/designateclient/v1/quotas.py @@ -13,7 +13,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import json + +from oslo_serialization import jsonutils from designateclient import client @@ -29,7 +30,7 @@ class QuotasController(client.Controller): def update(self, tenant_id, values): response = self.client.put('/quotas/%s' % tenant_id, - data=json.dumps(values)) + data=jsonutils.dumps(values)) return response.json() def reset(self, tenant_id): diff --git a/designateclient/v1/records.py b/designateclient/v1/records.py index cd699a7..c239e12 100644 --- a/designateclient/v1/records.py +++ b/designateclient/v1/records.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -import json +from oslo_serialization import jsonutils from designateclient import client from designateclient import utils @@ -74,7 +74,7 @@ class RecordsController(client.CrudController): 'domain_id': domain_id } - response = self.client.post(uri, data=json.dumps(record)) + response = self.client.post(uri, data=jsonutils.dumps(record)) return Record(response.json()) @@ -93,7 +93,7 @@ class RecordsController(client.CrudController): 'record_id': record.id } - response = self.client.put(uri, data=json.dumps(record.changes)) + response = self.client.put(uri, data=jsonutils.dumps(record.changes)) return Record(response.json()) diff --git a/designateclient/v1/servers.py b/designateclient/v1/servers.py index 9d77e8b..34dcca6 100644 --- a/designateclient/v1/servers.py +++ b/designateclient/v1/servers.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -import json +from oslo_serialization import jsonutils from designateclient import client from designateclient import utils @@ -53,7 +53,7 @@ class ServersController(client.CrudController): :param server: A :class:`Server` to create :returns: :class:`Server` """ - response = self.client.post('/servers', data=json.dumps(server)) + response = self.client.post('/servers', data=jsonutils.dumps(server)) return Server(response.json()) @@ -65,7 +65,7 @@ class ServersController(client.CrudController): :returns: :class:`Server` """ response = self.client.put('/servers/%s' % server.id, - data=json.dumps(server.changes)) + data=jsonutils.dumps(server.changes)) return Server(response.json()) diff --git a/requirements.txt b/requirements.txt index 59a02b4..fe51bcf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ cliff!=2.9.0,>=2.8.0 # Apache-2.0 jsonschema<3.0.0,>=2.6.0 # MIT osc-lib>=1.8.0 # Apache-2.0 +oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 pbr!=2.1.0,>=2.0.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0 |