baiducloud-python-sdk-blb 0.0.1__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.
@@ -0,0 +1,5 @@
1
+ """
2
+ This module defines some common string constants.
3
+ """
4
+
5
+ SDK_VERSION = b'0.0.1'
File without changes
@@ -0,0 +1,257 @@
1
+ """
2
+ Example for blb client.
3
+ """
4
+
5
+ import copy
6
+ import logging
7
+
8
+ from baiducloud_python_sdk_core import utils, bce_base_client
9
+ from baiducloud_python_sdk_core.auth import bce_v1_signer
10
+ from baiducloud_python_sdk_core.bce_base_client import BceBaseClient
11
+ from baiducloud_python_sdk_core.http import bce_http_client
12
+ from baiducloud_python_sdk_core.http import handler
13
+ from baiducloud_python_sdk_core.http import http_methods
14
+ from baiducloud_python_sdk_blb.models.billing_change_post_to_pre_blb_response import BillingChangePostToPreBlbResponse
15
+ from baiducloud_python_sdk_blb.models.billing_change_pre_to_post_blb_response import BillingChangePreToPostBlbResponse
16
+ from baiducloud_python_sdk_blb.models.resize_blb_response import ResizeBlbResponse
17
+
18
+ _logger = logging.getLogger(__name__)
19
+
20
+
21
+ class BlbClient(BceBaseClient):
22
+ """
23
+ blb base sdk client
24
+ """
25
+
26
+ VERSION_V1 = b'/v1'
27
+
28
+ CONSTANT_BLB = b'blb'
29
+
30
+ CONSTANT_CHARGE = b'charge'
31
+
32
+ CONSTANT_PRICE = b'price'
33
+
34
+ CONSTANT_REFUND = b'refund'
35
+
36
+ def __init__(self, config=None):
37
+ """
38
+ Initialize the blb client.
39
+
40
+ :param config: Client configuration
41
+ :type config: baidubce.BceClientConfiguration
42
+ """
43
+ bce_base_client.BceBaseClient.__init__(self, config)
44
+
45
+ def billing_change_cancel_to_post_blb(self, request, config=None):
46
+ """
47
+ billing_change_cancel_to_post_blb
48
+
49
+ :param request: Request entity containing all parameters
50
+ :type request: BlbClientRequest
51
+ :param config: Optional request configuration override
52
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
53
+
54
+ :return: API response
55
+ :rtype: baiducloud_python_sdk_core.bce_response.BceResponse
56
+
57
+ :raises BceClientError: Client error (network failure, invalid parameters, etc.)
58
+ :raises BceServerError: Server error (4xx/5xx HTTP status codes)
59
+ """
60
+ path = utils.append_uri(
61
+ BlbClient.VERSION_V1, BlbClient.CONSTANT_BLB, request.blb_id, BlbClient.CONSTANT_CHARGE
62
+ )
63
+ params = {}
64
+ params['action'] = 'CANCEL_TO_POSTPAY'
65
+ if request.client_token is not None:
66
+ params['clientToken'] = request.client_token
67
+ return self._send_request(http_methods.POST, path=path, params=params, config=config)
68
+
69
+ def billing_change_post_to_pre_blb(self, request, config=None):
70
+ """
71
+ billing_change_post_to_pre_blb
72
+
73
+ :param request: Request entity containing all parameters
74
+ :type request: BlbClientRequest
75
+ :param config: Optional request configuration override
76
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
77
+
78
+ :return: API response containing BillingChangePostToPreBlbResponse data
79
+ :rtype: BillingChangePostToPreBlbResponse
80
+
81
+ :raises BceClientError: Client error (network failure, invalid parameters, etc.)
82
+ :raises BceServerError: Server error (4xx/5xx HTTP status codes)
83
+ """
84
+ path = utils.append_uri(
85
+ BlbClient.VERSION_V1, BlbClient.CONSTANT_BLB, request.blb_id, BlbClient.CONSTANT_CHARGE
86
+ )
87
+ params = {}
88
+ params['action'] = 'TO_PREPAY'
89
+ if request.client_token is not None:
90
+ params['clientToken'] = request.client_token
91
+ return self._send_request(
92
+ http_methods.POST,
93
+ path=path,
94
+ body=request.to_json_string(),
95
+ params=params,
96
+ config=config,
97
+ model=BillingChangePostToPreBlbResponse,
98
+ )
99
+
100
+ def billing_change_pre_to_post_blb(self, request, config=None):
101
+ """
102
+ billing_change_pre_to_post_blb
103
+
104
+ :param request: Request entity containing all parameters
105
+ :type request: BlbClientRequest
106
+ :param config: Optional request configuration override
107
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
108
+
109
+ :return: API response containing BillingChangePreToPostBlbResponse data
110
+ :rtype: BillingChangePreToPostBlbResponse
111
+
112
+ :raises BceClientError: Client error (network failure, invalid parameters, etc.)
113
+ :raises BceServerError: Server error (4xx/5xx HTTP status codes)
114
+ """
115
+ path = utils.append_uri(
116
+ BlbClient.VERSION_V1, BlbClient.CONSTANT_BLB, request.blb_id, BlbClient.CONSTANT_CHARGE
117
+ )
118
+ params = {}
119
+ params['action'] = 'TO_POSTPAY'
120
+ if request.client_token is not None:
121
+ params['clientToken'] = request.client_token
122
+ return self._send_request(
123
+ http_methods.POST,
124
+ path=path,
125
+ body=request.to_json_string(),
126
+ params=params,
127
+ config=config,
128
+ model=BillingChangePreToPostBlbResponse,
129
+ )
130
+
131
+ def blb_inquiry(self, request, config=None):
132
+ """
133
+ blb_inquiry
134
+
135
+ :param request: Request entity containing all parameters
136
+ :type request: BlbClientRequest
137
+ :param config: Optional request configuration override
138
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
139
+
140
+ :return: API response
141
+ :rtype: baiducloud_python_sdk_core.bce_response.BceResponse
142
+
143
+ :raises BceClientError: Client error (network failure, invalid parameters, etc.)
144
+ :raises BceServerError: Server error (4xx/5xx HTTP status codes)
145
+ """
146
+ path = utils.append_uri(BlbClient.VERSION_V1, BlbClient.CONSTANT_BLB, BlbClient.CONSTANT_PRICE)
147
+ return self._send_request(http_methods.POST, path=path, body=request.to_json_string(), config=config)
148
+
149
+ def refund_blb(self, request, config=None):
150
+ """
151
+ refund_blb
152
+
153
+ :param request: Request entity containing all parameters
154
+ :type request: BlbClientRequest
155
+ :param config: Optional request configuration override
156
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
157
+
158
+ :return: API response
159
+ :rtype: baiducloud_python_sdk_core.bce_response.BceResponse
160
+
161
+ :raises BceClientError: Client error (network failure, invalid parameters, etc.)
162
+ :raises BceServerError: Server error (4xx/5xx HTTP status codes)
163
+ """
164
+ path = utils.append_uri(
165
+ BlbClient.VERSION_V1, BlbClient.CONSTANT_BLB, BlbClient.CONSTANT_REFUND, request.blb_id
166
+ )
167
+ params = {}
168
+ if request.client_token is not None:
169
+ params['clientToken'] = request.client_token
170
+ return self._send_request(http_methods.PUT, path=path, params=params, config=config)
171
+
172
+ def resize_blb(self, request, config=None):
173
+ """
174
+ resize_blb
175
+
176
+ :param request: Request entity containing all parameters
177
+ :type request: BlbClientRequest
178
+ :param config: Optional request configuration override
179
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
180
+
181
+ :return: API response containing ResizeBlbResponse data
182
+ :rtype: ResizeBlbResponse
183
+
184
+ :raises BceClientError: Client error (network failure, invalid parameters, etc.)
185
+ :raises BceServerError: Server error (4xx/5xx HTTP status codes)
186
+ """
187
+ path = utils.append_uri(BlbClient.VERSION_V1, BlbClient.CONSTANT_BLB, request.blb_id)
188
+ params = {}
189
+ params['action'] = 'RESIZE'
190
+ if request.client_token is not None:
191
+ params['clientToken'] = request.client_token
192
+ return self._send_request(
193
+ http_methods.POST,
194
+ path=path,
195
+ body=request.to_json_string(),
196
+ params=params,
197
+ config=config,
198
+ model=ResizeBlbResponse,
199
+ )
200
+
201
+ def _merge_config(self, config=None):
202
+ """
203
+ :param config:
204
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
205
+ """
206
+ if config is None:
207
+ return self.config
208
+ else:
209
+ new_config = copy.copy(self.config)
210
+ new_config.merge_non_none_values(config)
211
+ return new_config
212
+
213
+ def _send_request(
214
+ self, http_method, path, body=None, headers=None, params=None, config=None, body_parser=None, model=None
215
+ ):
216
+ """
217
+ Send an HTTP request to the service endpoint.
218
+
219
+ :param http_method: HTTP method (GET, POST, PUT, DELETE, etc.)
220
+ :type http_method: bytes
221
+ :param path: Request path
222
+ :type path: bytes
223
+ :param body: Optional request body
224
+ :type body: str or bytes
225
+ :param headers: Optional HTTP headers
226
+ :type headers: dict
227
+ :param params: Optional query parameters
228
+ :type params: dict
229
+ :param config: Optional request configuration override
230
+ :type config: baiducloud_python_sdk_core.BceClientConfiguration
231
+ :param body_parser: Optional custom body parser function
232
+ :type body_parser: callable
233
+ :param model: Optional response model class for deserialization
234
+ :type model: class
235
+
236
+ :return: API response
237
+ :rtype: baiducloud_python_sdk_core.bce_response.BceResponse
238
+
239
+ :raises BceClientError: Client error (network connection failure, SSL errors, etc.)
240
+ :raises BceServerError: Server returned error response
241
+ """
242
+ config = self._merge_config(config)
243
+ if body_parser is None:
244
+ body_parser = handler.parse_json
245
+ if headers is None:
246
+ headers = {b'Accept': b'*/*', b'Content-Type': b'application/json;charset=utf-8'}
247
+ return bce_http_client.send_request(
248
+ config,
249
+ bce_v1_signer.sign,
250
+ [handler.parse_error, body_parser],
251
+ http_method,
252
+ path,
253
+ body,
254
+ headers,
255
+ params,
256
+ model=model,
257
+ )
File without changes
@@ -0,0 +1,76 @@
1
+ """
2
+ Billing information
3
+ """
4
+
5
+ from baiducloud_python_sdk_core.abstract_model import AbstractModel
6
+
7
+ from baiducloud_python_sdk_blb.models.reservation import Reservation
8
+
9
+
10
+ class Billing(AbstractModel):
11
+ """
12
+ Billing
13
+ """
14
+
15
+ def __init__(self, payment_timing=None, billing_method=None, reservation=None):
16
+ """
17
+ Initialize Billing instance.
18
+
19
+ :param payment_timing: 付款时间,预支付(Prepaid)和后支付(Postpaid)
20
+ :type payment_timing: str (optional)
21
+
22
+ :param billing_method: 计费方式,预付费的时候不要传,后付费的时候传,按固定规格计费(BySpec)和按使用量计费(ByCapacityUnit)
23
+ :type billing_method: str (optional)
24
+
25
+ :param reservation: reservation attribute
26
+ :type reservation: Reservation (optional)
27
+ """
28
+ super().__init__()
29
+ self.payment_timing = payment_timing
30
+ self.billing_method = billing_method
31
+ self.reservation = reservation
32
+
33
+ def to_dict(self):
34
+ """
35
+ Convert the model instance to a dictionary representation.
36
+
37
+ Nested model objects are recursively converted to dictionaries.
38
+
39
+ :return: Dictionary representation of the model
40
+ :rtype: dict
41
+ """
42
+ _map = super().to_dict()
43
+ if _map is not None:
44
+ return _map
45
+ result = dict()
46
+ if self.payment_timing is not None:
47
+ result['paymentTiming'] = self.payment_timing
48
+ if self.billing_method is not None:
49
+ result['billingMethod'] = self.billing_method
50
+ if self.reservation is not None:
51
+ result['reservation'] = self.reservation.to_dict()
52
+ return result
53
+
54
+ def from_dict(self, m):
55
+ """
56
+ Populate the model instance from a dictionary.
57
+
58
+ Nested dictionaries are recursively converted to model objects.
59
+
60
+ :param m: Dictionary containing model data
61
+ :type m: dict
62
+
63
+ :return: Self reference for method chaining
64
+ :rtype: Billing
65
+
66
+ :raises TypeError: If input is not a dictionary type
67
+ :raises ValueError: If nested model conversion fails
68
+ """
69
+ m = m or dict()
70
+ if m.get('paymentTiming') is not None:
71
+ self.payment_timing = m.get('paymentTiming')
72
+ if m.get('billingMethod') is not None:
73
+ self.billing_method = m.get('billingMethod')
74
+ if m.get('reservation') is not None:
75
+ self.reservation = Reservation().from_dict(m.get('reservation'))
76
+ return self
@@ -0,0 +1,64 @@
1
+ """
2
+ Request entity for BillingChangeCancelToPostBlbRequest information.
3
+ """
4
+
5
+ from baiducloud_python_sdk_core.abstract_model import AbstractModel
6
+
7
+
8
+ class BillingChangeCancelToPostBlbRequest(AbstractModel):
9
+ """
10
+ Request entity for BillingChangeCancelToPostBlbRequest operation.
11
+
12
+ This class encapsulates all parameters for the API request.
13
+ """
14
+
15
+ def __init__(self, blb_id, client_token=None):
16
+ """
17
+ Initialize BillingChangeCancelToPostBlbRequest request entity.
18
+
19
+ :param blb_id: blb_id parameter
20
+ :type blb_id: str (required)
21
+
22
+ :param client_token: client_token parameter
23
+ :type client_token: str (optional)
24
+ """
25
+ super().__init__()
26
+ self.blb_id = blb_id
27
+ self.client_token = client_token
28
+
29
+ def to_dict(self):
30
+ """
31
+ Convert the request entity to a dictionary representation.
32
+
33
+ Nested model objects are recursively converted to dictionaries.
34
+
35
+ :return: Dictionary representation of the request
36
+ :rtype: dict
37
+ """
38
+ _map = super().to_dict()
39
+ if _map is not None:
40
+ return _map
41
+ result = dict()
42
+ return result
43
+
44
+ def from_dict(self, m):
45
+ """
46
+ Populate the request entity from a dictionary.
47
+
48
+ Nested dictionaries are recursively converted to model objects.
49
+
50
+ :param m: Dictionary containing request data
51
+ :type m: dict
52
+
53
+ :return: Self reference for method chaining
54
+ :rtype: BillingChangeCancelToPostBlbRequest
55
+
56
+ :raises TypeError: If input is not a dictionary or field type mismatch
57
+ :raises ValueError: If nested model conversion fails
58
+ """
59
+ m = m or dict()
60
+ if m.get('blbId') is not None:
61
+ self.blb_id = m.get('blbId')
62
+ if m.get('clientToken') is not None:
63
+ self.client_token = m.get('clientToken')
64
+ return self
@@ -0,0 +1,90 @@
1
+ """
2
+ Request entity for BillingChangePostToPreBlbRequest information.
3
+ """
4
+
5
+ from baiducloud_python_sdk_core.abstract_model import AbstractModel
6
+
7
+
8
+ class BillingChangePostToPreBlbRequest(AbstractModel):
9
+ """
10
+ Request entity for BillingChangePostToPreBlbRequest operation.
11
+
12
+ This class encapsulates all parameters for the API request.
13
+ """
14
+
15
+ def __init__(self, blb_id, reservation_length, client_token=None, billing_method=None, performance_level=None):
16
+ """
17
+ Initialize BillingChangePostToPreBlbRequest request entity.
18
+
19
+ :param blb_id: blb_id parameter
20
+ :type blb_id: str (required)
21
+
22
+ :param client_token: client_token parameter
23
+ :type client_token: str (optional)
24
+
25
+ :param billing_method: 计费类型。当前只支持默认值\"BySpec\"。
26
+ :type billing_method: str (optional)
27
+
28
+ :param performance_level:
29
+ 性能规格。不填表示不进行配置变更。取值如下:\"small1\"标准型1,\"small2\"标准型2,\"medium1\"增强型1,\"medium2\"增强型2,\"large1\"超大型1,
30
+ \"large2\"超大型2,\"large3\"超大型3。注意:预付费不支持\"unlimited\"不限速
31
+ :type performance_level: str (optional)
32
+
33
+ :param reservation_length: 购买月份时长,[1,2,3,4,5,6,7,8,9,12,24,36]
34
+ :type reservation_length: int (required)
35
+ """
36
+ super().__init__()
37
+ self.blb_id = blb_id
38
+ self.client_token = client_token
39
+ self.billing_method = billing_method
40
+ self.performance_level = performance_level
41
+ self.reservation_length = reservation_length
42
+
43
+ def to_dict(self):
44
+ """
45
+ Convert the request entity to a dictionary representation.
46
+
47
+ Nested model objects are recursively converted to dictionaries.
48
+
49
+ :return: Dictionary representation of the request
50
+ :rtype: dict
51
+ """
52
+ _map = super().to_dict()
53
+ if _map is not None:
54
+ return _map
55
+ result = dict()
56
+ if self.billing_method is not None:
57
+ result['billingMethod'] = self.billing_method
58
+ if self.performance_level is not None:
59
+ result['performanceLevel'] = self.performance_level
60
+ if self.reservation_length is not None:
61
+ result['reservationLength'] = self.reservation_length
62
+ return result
63
+
64
+ def from_dict(self, m):
65
+ """
66
+ Populate the request entity from a dictionary.
67
+
68
+ Nested dictionaries are recursively converted to model objects.
69
+
70
+ :param m: Dictionary containing request data
71
+ :type m: dict
72
+
73
+ :return: Self reference for method chaining
74
+ :rtype: BillingChangePostToPreBlbRequest
75
+
76
+ :raises TypeError: If input is not a dictionary or field type mismatch
77
+ :raises ValueError: If nested model conversion fails
78
+ """
79
+ m = m or dict()
80
+ if m.get('blbId') is not None:
81
+ self.blb_id = m.get('blbId')
82
+ if m.get('clientToken') is not None:
83
+ self.client_token = m.get('clientToken')
84
+ if m.get('billingMethod') is not None:
85
+ self.billing_method = m.get('billingMethod')
86
+ if m.get('performanceLevel') is not None:
87
+ self.performance_level = m.get('performanceLevel')
88
+ if m.get('reservationLength') is not None:
89
+ self.reservation_length = m.get('reservationLength')
90
+ return self
@@ -0,0 +1,61 @@
1
+ """
2
+ Request entity for BillingChangePostToPreBlbResponse information.
3
+ """
4
+
5
+ from baiducloud_python_sdk_core.bce_response import BceResponse
6
+
7
+
8
+ class BillingChangePostToPreBlbResponse(BceResponse):
9
+ """
10
+ BillingChangePostToPreBlbResponse
11
+ """
12
+
13
+ def __init__(self, order_id=None):
14
+ """
15
+ Initialize BillingChangePostToPreBlbResponse response.
16
+
17
+ :param order_id: 后付费转预付费订单ID
18
+ :type order_id: str (optional)
19
+ """
20
+ super().__init__()
21
+ self.order_id = order_id
22
+
23
+ def to_dict(self):
24
+ """
25
+ Convert the response instance to a dictionary representation.
26
+
27
+ Includes metadata from the parent BceResponse class.
28
+ Nested model objects are recursively converted to dictionaries.
29
+
30
+ :return: Dictionary representation of the response
31
+ :rtype: dict
32
+ """
33
+ _map = super().to_dict()
34
+ if _map is not None:
35
+ return _map
36
+ result = dict()
37
+ if self.metadata is not None:
38
+ result['metadata'] = self.metadata
39
+ if self.order_id is not None:
40
+ result['orderId'] = self.order_id
41
+ return result
42
+
43
+ def from_dict(self, m):
44
+ """
45
+ Populate the response instance from a dictionary.
46
+
47
+ Nested dictionaries are recursively converted to model objects.
48
+
49
+ :param m: Dictionary containing response data
50
+ :type m: dict
51
+
52
+ :return: Self reference for method chaining
53
+ :rtype: BillingChangePostToPreBlbResponse
54
+
55
+ :raises TypeError: If input is not a dictionary or field type mismatch
56
+ :raises ValueError: If nested model conversion fails
57
+ """
58
+ m = m or dict()
59
+ if m.get('orderId') is not None:
60
+ self.order_id = m.get('orderId')
61
+ return self
@@ -0,0 +1,92 @@
1
+ """
2
+ Request entity for BillingChangePreToPostBlbRequest information.
3
+ """
4
+
5
+ from baiducloud_python_sdk_core.abstract_model import AbstractModel
6
+
7
+
8
+ class BillingChangePreToPostBlbRequest(AbstractModel):
9
+ """
10
+ Request entity for BillingChangePreToPostBlbRequest operation.
11
+
12
+ This class encapsulates all parameters for the API request.
13
+ """
14
+
15
+ def __init__(
16
+ self, blb_id, client_token=None, billing_method=None, performance_level=None, effective_immediately=None
17
+ ):
18
+ """
19
+ Initialize BillingChangePreToPostBlbRequest request entity.
20
+
21
+ :param blb_id: blb_id parameter
22
+ :type blb_id: str (required)
23
+
24
+ :param client_token: client_token parameter
25
+ :type client_token: str (optional)
26
+
27
+ :param billing_method: 计费方式。\"BySpec\"表示按固定规格计费(默认值),\"ByCapacityUnit\"表示按使用量计费。
28
+ :type billing_method: str (optional)
29
+
30
+ :param performance_level:
31
+ 性能规格参数,默认为当前实例的性能规格。取值如下:\"small1\"标准型1,\"small2\"标准型2,\"medium1\"增强型1,\"medium2\"增强型2,\"large1\"超大型1,
32
+ \"large2\"超大型2,\"large3\"超大型3。仅后付费-按使用量支持\"unlimited\"不限速。
33
+ :type performance_level: str (optional)
34
+
35
+ :param effective_immediately: 是否立即生效,默认false。
36
+ :type effective_immediately: bool (optional)
37
+ """
38
+ super().__init__()
39
+ self.blb_id = blb_id
40
+ self.client_token = client_token
41
+ self.billing_method = billing_method
42
+ self.performance_level = performance_level
43
+ self.effective_immediately = effective_immediately
44
+
45
+ def to_dict(self):
46
+ """
47
+ Convert the request entity to a dictionary representation.
48
+
49
+ Nested model objects are recursively converted to dictionaries.
50
+
51
+ :return: Dictionary representation of the request
52
+ :rtype: dict
53
+ """
54
+ _map = super().to_dict()
55
+ if _map is not None:
56
+ return _map
57
+ result = dict()
58
+ if self.billing_method is not None:
59
+ result['billingMethod'] = self.billing_method
60
+ if self.performance_level is not None:
61
+ result['performanceLevel'] = self.performance_level
62
+ if self.effective_immediately is not None:
63
+ result['effectiveImmediately'] = self.effective_immediately
64
+ return result
65
+
66
+ def from_dict(self, m):
67
+ """
68
+ Populate the request entity from a dictionary.
69
+
70
+ Nested dictionaries are recursively converted to model objects.
71
+
72
+ :param m: Dictionary containing request data
73
+ :type m: dict
74
+
75
+ :return: Self reference for method chaining
76
+ :rtype: BillingChangePreToPostBlbRequest
77
+
78
+ :raises TypeError: If input is not a dictionary or field type mismatch
79
+ :raises ValueError: If nested model conversion fails
80
+ """
81
+ m = m or dict()
82
+ if m.get('blbId') is not None:
83
+ self.blb_id = m.get('blbId')
84
+ if m.get('clientToken') is not None:
85
+ self.client_token = m.get('clientToken')
86
+ if m.get('billingMethod') is not None:
87
+ self.billing_method = m.get('billingMethod')
88
+ if m.get('performanceLevel') is not None:
89
+ self.performance_level = m.get('performanceLevel')
90
+ if m.get('effectiveImmediately') is not None:
91
+ self.effective_immediately = m.get('effectiveImmediately')
92
+ return self