Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1502 - support Chinese character #1582

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions f5/bigip/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
message = ("Maybe you're using Python < 2.7 and do not have the "
"orderreddict external dependency installed.")
raise exc(message)
import json
import copy
import keyword
import re
Expand Down Expand Up @@ -401,7 +402,9 @@ def _modify(self, **patch):
raise AttemptedMutationOfReadOnly(msg)

patch = self._prepare_request_json(patch)
response = session.patch(patch_uri, json=patch, **requests_params)
data = json.dumps(patch, ensure_ascii=False)
data = data.encode("utf-8")
response = session.patch(patch_uri, data=data, **requests_params)
self._local_update(response.json())

def modify(self, **patch):
Expand Down Expand Up @@ -577,7 +580,9 @@ def _update(self, **kwargs):
# @see https://github.com/requests/requests/issues/2364
for _ in range(0, 30):
try:
response = session.put(update_uri, json=data_dict, **requests_params)
data = json.dumps(data_dict, ensure_ascii=False)
data = data.encode("utf-8")
response = session.put(update_uri, data=data, **requests_params)
self._meta_data = temp_meta
self._local_update(response.json())
break
Expand Down Expand Up @@ -1012,7 +1017,9 @@ def _create(self, **kwargs):
kwargs = self._prepare_request_json(kwargs)

# Invoke the REST operation on the device.
response = session.post(_create_uri, json=kwargs, **requests_params)
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.post(_create_uri, data=data, **requests_params)

# Make new instance of self
result = self._produce_instance(response)
Expand Down
5 changes: 4 additions & 1 deletion f5/bigip/shared/authn.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
#

import json

from f5.bigip.resource import Collection
from f5.bigip.resource import OrganizingCollection
Expand Down Expand Up @@ -76,7 +77,9 @@ def _create(self, **kwargs):
kwargs = self._prepare_request_json(kwargs)

# Invoke the REST operation on the device.
response = session.post(_create_uri, json=kwargs, **requests_params)
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.post(_create_uri, data=data, **requests_params)

# Make new instance of self
result = self._produce_instance(response)
Expand Down
9 changes: 7 additions & 2 deletions f5/bigip/tm/gtm/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
REST Kind
``tm:gtm:pools:*``
"""
import json

from distutils.version import LooseVersion

Expand Down Expand Up @@ -290,8 +291,10 @@ def create(self, **kwargs):
# fixed in later 12.x release.

try:
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.post(
_create_uri, json=kwargs, **requests_params)
_create_uri, data=data, **requests_params)

except HTTPError as err:
if err.response.status_code != 404:
Expand Down Expand Up @@ -373,8 +376,10 @@ def create(self, **kwargs):
# fixed in later 12.x release.

try:
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.post(
_create_uri, json=kwargs, **requests_params)
_create_uri, data=data, **requests_params)

except HTTPError as err:
if err.response.status_code != 404:
Expand Down
7 changes: 6 additions & 1 deletion f5/bigip/tm/gtm/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
REST Kind
``tm:gtm:topology:*``
"""

import json

from distutils.version import LooseVersion
from f5.bigip.resource import Collection
from f5.bigip.resource import Resource
Expand Down Expand Up @@ -99,8 +102,10 @@ def _create(self, **kwargs):
# fixed in later release.

try:
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.post(
_create_uri, json=kwargs, **requests_params)
_create_uri, data=data, **requests_params)

except HTTPError as err:
if err.response.status_code != 404:
Expand Down
6 changes: 5 additions & 1 deletion f5/bigip/tm/ltm/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
``tm:ltm:policy:*``
"""

import json

from f5.bigip.mixins import CheckExistenceMixin
from f5.bigip.resource import Collection
from f5.bigip.resource import Resource
Expand Down Expand Up @@ -161,7 +163,9 @@ def publish(self, **kwargs):
kwargs['command'] = 'publish'
if 'Drafts' not in self.name:
kwargs['name'] = self.fullPath
session.post(base_uri, json=kwargs, **requests_params)
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
session.post(base_uri, data=data, **requests_params)
get_kwargs = {
'name': self.name, 'partition': self.partition,
'uri_as_parts': True
Expand Down
6 changes: 5 additions & 1 deletion f5/bigip/tm/ltm/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
``tm:ltm:virtual:*``
"""

import json

from distutils.version import LooseVersion

from f5.bigip.mixins import CheckExistenceMixin
Expand Down Expand Up @@ -197,8 +199,10 @@ def create(self, **kwargs):
# this in 11.5.4

try:
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.post(
_create_uri, json=kwargs, **requests_params)
_create_uri, data=data, **requests_params)

except HTTPError as err:
if err.response.status_code != 404:
Expand Down
5 changes: 4 additions & 1 deletion f5/bigiq/cm/device/licensing/pool/regkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import os
import time
import uuid
import json

from f5.bigiq.resource import Collection
from f5.bigiq.resource import OrganizingCollection
Expand Down Expand Up @@ -172,7 +173,9 @@ def delete(self, **kwargs):
if not force:
self._check_generation()

response = session.delete(delete_uri, json=kwargs, **requests_params)
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.delete(delete_uri, data=data, **requests_params)
if response.status_code == 200:
self.__dict__ = {'deleted': True}

Expand Down
6 changes: 4 additions & 2 deletions f5/bigiq/cm/device/licensing/pool/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import os
import time
import uuid
import json

from f5.bigip.mixins import ExclusiveAttributesMixin
from f5.bigiq.resource import Collection
Expand Down Expand Up @@ -174,8 +175,9 @@ def delete(self, **kwargs):
force = self._check_force_arg(kwargs.pop('force', True))
if not force:
self._check_generation()

response = session.delete(delete_uri, json=kwargs, **requests_params)
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.delete(delete_uri, data=data, **requests_params)
if response.status_code == 200:
self.__dict__ = {'deleted': True}

Expand Down
6 changes: 4 additions & 2 deletions f5/bigiq/cm/shared/licensing/pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
REST Kind
``cm:shared:licensing:pools:*``
"""
import json

from f5.bigiq.resource import Collection
from f5.bigiq.resource import Resource
Expand Down Expand Up @@ -127,7 +128,8 @@ def delete(self, **kwargs):
force = self._check_force_arg(kwargs.pop('force', True))
if not force:
self._check_generation()

response = session.delete(delete_uri, json=kwargs, **requests_params)
data = json.dumps(kwargs, ensure_ascii=False)
data = data.encode("utf-8")
response = session.delete(delete_uri, data=data, **requests_params)
if response.status_code == 200:
self.__dict__ = {'deleted': True}