zenlayercloud-sdk-python 2.0.56__py3-none-any.whl → 2.0.58__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.
- zenlayercloud/__init__.py +1 -1
- zenlayercloud/common/abstract_client.py +10 -6
- zenlayercloud/common/credential.py +16 -1
- zenlayercloud/zec/v20250901/models.py +646 -246
- zenlayercloud/zec/v20250901/zec_client.py +162 -63
- zenlayercloud/zlb/v20250401/models.py +24 -0
- zenlayercloud/zlb/v20250401/zlb_client.py +2 -2
- {zenlayercloud_sdk_python-2.0.56.dist-info → zenlayercloud_sdk_python-2.0.58.dist-info}/METADATA +1 -1
- {zenlayercloud_sdk_python-2.0.56.dist-info → zenlayercloud_sdk_python-2.0.58.dist-info}/RECORD +12 -12
- {zenlayercloud_sdk_python-2.0.56.dist-info → zenlayercloud_sdk_python-2.0.58.dist-info}/WHEEL +0 -0
- {zenlayercloud_sdk_python-2.0.56.dist-info → zenlayercloud_sdk_python-2.0.58.dist-info}/licenses/LICENSE +0 -0
- {zenlayercloud_sdk_python-2.0.56.dist-info → zenlayercloud_sdk_python-2.0.58.dist-info}/top_level.txt +0 -0
zenlayercloud/__init__.py
CHANGED
|
@@ -6,6 +6,7 @@ import time
|
|
|
6
6
|
import zenlayercloud
|
|
7
7
|
from zenlayercloud.common.abstract_model import AbstractModel
|
|
8
8
|
from zenlayercloud.common.config import Config
|
|
9
|
+
from zenlayercloud.common.credential import TokenCredential
|
|
9
10
|
from zenlayercloud.common.excpetion import error_code
|
|
10
11
|
from zenlayercloud.common.excpetion.zenlayer_cloud_sdk_exception import ZenlayerCloudSdkException
|
|
11
12
|
from zenlayercloud.common.request import BaseRequest, ApiProxyClient
|
|
@@ -25,7 +26,7 @@ class AbstractClient(object):
|
|
|
25
26
|
"""base client interactive with zenlayer cloud
|
|
26
27
|
|
|
27
28
|
:param credential: the zenlayer cloud credential
|
|
28
|
-
:type credential: zenlayercloud.common.credential.Credential
|
|
29
|
+
:type credential: zenlayercloud.common.credential.Credential or zenlayercloud.common.credential.TokenCredential
|
|
29
30
|
:param config: the additional config for client
|
|
30
31
|
:type config: zenlayercloud.common.config.Config
|
|
31
32
|
"""
|
|
@@ -49,10 +50,7 @@ class AbstractClient(object):
|
|
|
49
50
|
req = BaseRequest(host=self.config.domain, method=method, uri=uri, header=headers)
|
|
50
51
|
|
|
51
52
|
header = req.header
|
|
52
|
-
timestamp = int(time.time())
|
|
53
53
|
header["x-zc-version"] = self._api_version
|
|
54
|
-
header["x-zc-signature-method"] = self._signature_method
|
|
55
|
-
header["x-zc-timestamp"] = str(timestamp)
|
|
56
54
|
header["x-zc-service"] = self._service
|
|
57
55
|
header["x-zc-action"] = action
|
|
58
56
|
header["x-zc-sdk-version"] = self._sdk_version
|
|
@@ -61,8 +59,14 @@ class AbstractClient(object):
|
|
|
61
59
|
req.set_content_type(_json_content_type)
|
|
62
60
|
req.data = json.dumps(request.serialize())
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
if isinstance(self.credential, TokenCredential):
|
|
63
|
+
req.header["Authorization"] = "Bearer " + self.credential.token
|
|
64
|
+
else:
|
|
65
|
+
timestamp = int(time.time())
|
|
66
|
+
header["x-zc-signature-method"] = self._signature_method
|
|
67
|
+
header["x-zc-timestamp"] = str(timestamp)
|
|
68
|
+
authorization = self._build_zc2_authorization(req)
|
|
69
|
+
req.header["Authorization"] = authorization
|
|
66
70
|
|
|
67
71
|
resp = self._send_request(req)
|
|
68
72
|
return self._handle_response(resp)
|
|
@@ -9,7 +9,7 @@ class Credential(object):
|
|
|
9
9
|
def __init__(self, access_key_id, access_key_password):
|
|
10
10
|
"""Zenlayer Cloud Credential.
|
|
11
11
|
|
|
12
|
-
Access https://console.zenlayer.com/ to manage your
|
|
12
|
+
Access https://console.zenlayer.com/accessKey to manage your
|
|
13
13
|
credentials.
|
|
14
14
|
|
|
15
15
|
:param access_key_id: The access key id of your credential.
|
|
@@ -23,3 +23,18 @@ class Credential(object):
|
|
|
23
23
|
raise ZenlayerCloudSdkException(CREDENTIAL_MISSING_ERROR, "access key password should not be none or empty")
|
|
24
24
|
self.access_key_id = access_key_id.strip()
|
|
25
25
|
self.access_key_password = access_key_password.strip()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class TokenCredential(object):
|
|
29
|
+
|
|
30
|
+
def __init__(self, token):
|
|
31
|
+
"""Zenlayer Cloud Bearer Token Credential.
|
|
32
|
+
|
|
33
|
+
Access https://console.zenlayer.com/accessToken to generate a personal access token and use it instead of HMAC-signed credentials.
|
|
34
|
+
|
|
35
|
+
:param token: The personal access token.
|
|
36
|
+
:type token: str
|
|
37
|
+
"""
|
|
38
|
+
if token is None or token.strip() == "":
|
|
39
|
+
raise ZenlayerCloudSdkException(CREDENTIAL_MISSING_ERROR, "token should not be none or empty")
|
|
40
|
+
self.token = token.strip()
|