diff options
author | cao.yuan <cao.yuan@99cloud.net> | 2019-02-24 23:54:49 +0800 |
---|---|---|
committer | caoyuan <cao.yuan@99cloud.net> | 2019-02-28 10:30:22 +0800 |
commit | e288539298370c2018fc44fea832b73b703e75ea (patch) | |
tree | 1cf58c77435361aa476f5cce374bc2295b7c6a0d /designateclient | |
parent | 4ffd836c9a40f9e702ce44e678d953cb9f81b7e4 (diff) | |
download | python-designateclient-e288539298370c2018fc44fea832b73b703e75ea.tar.gz |
Update json module to jsonutils
oslo project provide jsonutils, and the others use it in many place,
this PS to update the json moudule to oslo jsonutils for consistency.
Change-Id: I8cbf78b0735572f550ece31611258c3da9ae1d35
Diffstat (limited to 'designateclient')
-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 |
7 files changed, 24 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()) |