python3-core-api-client 0.2__py3-none-any.whl → 0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,14 @@
1
1
  import datetime
2
2
  from json import JSONEncoder
3
+ from ipaddress import IPv4Address, IPv6Address
4
+ from typing import Any
3
5
 
4
6
 
5
- class DatetimeEncoder(JSONEncoder):
6
- def default(self, o: datetime.datetime) -> str:
7
- return o.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
7
+ class CustomEncoder(JSONEncoder):
8
+ def default(self, o: Any) -> str:
9
+ if isinstance(o, datetime.date):
10
+ return o.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
11
+ elif isinstance(o, (IPv6Address, IPv4Address)):
12
+ return str(o)
13
+
14
+ return super().default(o)
@@ -1,7 +1,7 @@
1
1
  import json
2
2
  from typing import Optional, Tuple
3
3
 
4
- from cyberfusion.CoreApiClient._encoders import DatetimeEncoder
4
+ from cyberfusion.CoreApiClient._encoders import CustomEncoder
5
5
  from cyberfusion.CoreApiClient.exceptions import CallException, AuthenticationException
6
6
 
7
7
  from requests.sessions import Session
@@ -108,13 +108,13 @@ class CoreApiClient:
108
108
  url = "".join([self.base_url, path])
109
109
 
110
110
  if data and content_type == "application/json":
111
- data = json.dumps(data, cls=DatetimeEncoder)
111
+ data = json.dumps(data, cls=CustomEncoder)
112
112
 
113
113
  if query_parameters:
114
114
  for key, value in query_parameters.items():
115
115
  if isinstance(value, datetime.datetime):
116
116
  query_parameters[key] = json.loads(
117
- json.dumps(value, cls=DatetimeEncoder)
117
+ json.dumps(value, cls=CustomEncoder)
118
118
  )
119
119
 
120
120
  requests_response = self.requests_session.request(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-core-api-client
3
- Version: 0.2
3
+ Version: 0.3
4
4
  Summary: Python client for Core API.
5
5
  Author-email: Cyberfusion <support@cyberfusion.io>
6
6
  Project-URL: Source, https://github.com/CyberfusionIO/python3-core-api-client
@@ -1,6 +1,6 @@
1
1
  cyberfusion/CoreApiClient/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- cyberfusion/CoreApiClient/_encoders.py,sha256=wyYUK_82h_hOPRvdxIzYta7Ek1TSSYMORR1QF1XfcRA,186
3
- cyberfusion/CoreApiClient/connector.py,sha256=ifnlovR-HiMfGXwIAoibFutXPV_iDWN-oGanu4GkhW4,12704
2
+ cyberfusion/CoreApiClient/_encoders.py,sha256=A40qzD9Ld6Ak7cfzMOH4alMxS9AJgksvBs5xf0EAgbI,402
3
+ cyberfusion/CoreApiClient/connector.py,sha256=7yQs9fH8ldGHpw41xHU07NkXD5OPm3_pjckk3asF6u4,12698
4
4
  cyberfusion/CoreApiClient/exceptions.py,sha256=fNxPtzVL4SzPiVNZmBTu1l8D57dkCxMxflyIXDPLE4Q,204
5
5
  cyberfusion/CoreApiClient/http.py,sha256=z6ZyfQyUnA3QDCmej2BEIw9BOlTYoCE8zvTZ0-u_VoQ,429
6
6
  cyberfusion/CoreApiClient/interfaces.py,sha256=P0wCbmSNEpB-eF49PHudc_qXM4blIXm4TsD2AB0z_7Q,269
@@ -53,7 +53,7 @@ cyberfusion/CoreApiClient/resources/tombstones.py,sha256=AH7G23dD_I-qqmr98AmzsFD
53
53
  cyberfusion/CoreApiClient/resources/unix_users.py,sha256=moqa5CjNSzueccMGms9mNhtUSDFw1UapWlB8QM6Agjk,3636
54
54
  cyberfusion/CoreApiClient/resources/url_redirects.py,sha256=1Y386s9Bge8gBaXucSUBi1npNPPQpMLLVGXqVxA2YFM,2368
55
55
  cyberfusion/CoreApiClient/resources/virtual_hosts.py,sha256=SAo6QPQGO-IJJCwW71zEEdA5FGdAn-6ADdn1iuA03wg,3716
56
- python3_core_api_client-0.2.dist-info/METADATA,sha256=GiVOnEZmhURfOt4VbSlncbahgqS_u0XMrgEwGrgViJs,7022
57
- python3_core_api_client-0.2.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
58
- python3_core_api_client-0.2.dist-info/top_level.txt,sha256=ss011q9S6SL_KIIyq7iujFmIYa0grSjlnInO7cDkeag,12
59
- python3_core_api_client-0.2.dist-info/RECORD,,
56
+ python3_core_api_client-0.3.dist-info/METADATA,sha256=Ya3ItBzEEIJ87nzICYfXR6Qbl9SHKiW-vQFPv1dsL8s,7022
57
+ python3_core_api_client-0.3.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
58
+ python3_core_api_client-0.3.dist-info/top_level.txt,sha256=ss011q9S6SL_KIIyq7iujFmIYa0grSjlnInO7cDkeag,12
59
+ python3_core_api_client-0.3.dist-info/RECORD,,