openmeter 1.0.0b185__py3-none-any.whl → 1.0.0b188__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.
Potentially problematic release.
This version of openmeter might be problematic. Click here for more details.
- openmeter/_operations/_operations.py +1244 -100
- openmeter/aio/_operations/_operations.py +1053 -6
- {openmeter-1.0.0b185.dist-info → openmeter-1.0.0b188.dist-info}/METADATA +5 -4
- {openmeter-1.0.0b185.dist-info → openmeter-1.0.0b188.dist-info}/RECORD +5 -5
- {openmeter-1.0.0b185.dist-info → openmeter-1.0.0b188.dist-info}/WHEEL +1 -1
|
@@ -23,6 +23,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async
|
|
|
23
23
|
from azure.core.utils import case_insensitive_dict
|
|
24
24
|
|
|
25
25
|
from ..._operations._operations import (
|
|
26
|
+
build_create_customer_request,
|
|
26
27
|
build_create_entitlement_request,
|
|
27
28
|
build_create_feature_request,
|
|
28
29
|
build_create_grant_request,
|
|
@@ -30,12 +31,14 @@ from ..._operations._operations import (
|
|
|
30
31
|
build_create_notification_channel_request,
|
|
31
32
|
build_create_notification_rule_request,
|
|
32
33
|
build_create_portal_token_request,
|
|
34
|
+
build_delete_customer_request,
|
|
33
35
|
build_delete_entitlement_request,
|
|
34
36
|
build_delete_feature_request,
|
|
35
37
|
build_delete_meter_request,
|
|
36
38
|
build_delete_notification_channel_request,
|
|
37
39
|
build_delete_notification_rule_request,
|
|
38
40
|
build_delete_subject_request,
|
|
41
|
+
build_get_customer_request,
|
|
39
42
|
build_get_debug_metrics_request,
|
|
40
43
|
build_get_entitlement_by_id_request,
|
|
41
44
|
build_get_entitlement_history_request,
|
|
@@ -49,6 +52,7 @@ from ..._operations._operations import (
|
|
|
49
52
|
build_get_subject_request,
|
|
50
53
|
build_ingest_events_request,
|
|
51
54
|
build_invalidate_portal_tokens_request,
|
|
55
|
+
build_list_customers_request,
|
|
52
56
|
build_list_entitlement_grants_request,
|
|
53
57
|
build_list_entitlements_request,
|
|
54
58
|
build_list_events_request,
|
|
@@ -68,6 +72,7 @@ from ..._operations._operations import (
|
|
|
68
72
|
build_receive_svix_operational_event_request,
|
|
69
73
|
build_reset_entitlement_usage_request,
|
|
70
74
|
build_test_notification_rule_request,
|
|
75
|
+
build_update_customer_request,
|
|
71
76
|
build_update_notification_channel_request,
|
|
72
77
|
build_update_notification_rule_request,
|
|
73
78
|
build_upsert_subject_request,
|
|
@@ -85,6 +90,1048 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T
|
|
|
85
90
|
|
|
86
91
|
|
|
87
92
|
class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-methods
|
|
93
|
+
@overload
|
|
94
|
+
async def create_customer(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
|
|
95
|
+
# pylint: disable=line-too-long
|
|
96
|
+
"""Create a new customer.
|
|
97
|
+
|
|
98
|
+
:param body: Required.
|
|
99
|
+
:type body: JSON
|
|
100
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
101
|
+
Default value is "application/json".
|
|
102
|
+
:paramtype content_type: str
|
|
103
|
+
:return: JSON object
|
|
104
|
+
:rtype: JSON
|
|
105
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
.. code-block:: python
|
|
109
|
+
|
|
110
|
+
# JSON input template you can fill out and use as your body input.
|
|
111
|
+
body = {
|
|
112
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
113
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
114
|
+
characters. Required.
|
|
115
|
+
"usageAttribution": {
|
|
116
|
+
"subjectKeys": [
|
|
117
|
+
"str" # The subjects that are attributed to the customer.
|
|
118
|
+
Required.
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
122
|
+
"billingAddress": {
|
|
123
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
124
|
+
for tax and invoicing.
|
|
125
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
126
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
127
|
+
Custom two-letter country codes are also supported for convenience.
|
|
128
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
129
|
+
Used for tax and invoicing.
|
|
130
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
131
|
+
Used for tax and invoicing.
|
|
132
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
133
|
+
customer. Used for tax and invoicing.
|
|
134
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
135
|
+
customer. Used for tax and invoicing.
|
|
136
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
137
|
+
for tax and invoicing.
|
|
138
|
+
},
|
|
139
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
140
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
141
|
+
and invoicing.
|
|
142
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
143
|
+
deleted.
|
|
144
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
145
|
+
Maximum 1024 characters.
|
|
146
|
+
"external": {
|
|
147
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
148
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
149
|
+
provider.
|
|
150
|
+
},
|
|
151
|
+
"metadata": {},
|
|
152
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
153
|
+
customer.
|
|
154
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
155
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
# response body for status code(s): 200
|
|
159
|
+
response == {
|
|
160
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
161
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
162
|
+
characters. Required.
|
|
163
|
+
"usageAttribution": {
|
|
164
|
+
"subjectKeys": [
|
|
165
|
+
"str" # The subjects that are attributed to the customer.
|
|
166
|
+
Required.
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
170
|
+
"billingAddress": {
|
|
171
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
172
|
+
for tax and invoicing.
|
|
173
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
174
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
175
|
+
Custom two-letter country codes are also supported for convenience.
|
|
176
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
177
|
+
Used for tax and invoicing.
|
|
178
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
179
|
+
Used for tax and invoicing.
|
|
180
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
181
|
+
customer. Used for tax and invoicing.
|
|
182
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
183
|
+
customer. Used for tax and invoicing.
|
|
184
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
185
|
+
for tax and invoicing.
|
|
186
|
+
},
|
|
187
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
188
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
189
|
+
and invoicing.
|
|
190
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
191
|
+
deleted.
|
|
192
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
193
|
+
Maximum 1024 characters.
|
|
194
|
+
"external": {
|
|
195
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
196
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
197
|
+
provider.
|
|
198
|
+
},
|
|
199
|
+
"metadata": {},
|
|
200
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
201
|
+
customer.
|
|
202
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
203
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
204
|
+
}
|
|
205
|
+
"""
|
|
206
|
+
|
|
207
|
+
@overload
|
|
208
|
+
async def create_customer(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> JSON:
|
|
209
|
+
# pylint: disable=line-too-long
|
|
210
|
+
"""Create a new customer.
|
|
211
|
+
|
|
212
|
+
:param body: Required.
|
|
213
|
+
:type body: IO[bytes]
|
|
214
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
215
|
+
Default value is "application/json".
|
|
216
|
+
:paramtype content_type: str
|
|
217
|
+
:return: JSON object
|
|
218
|
+
:rtype: JSON
|
|
219
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
220
|
+
|
|
221
|
+
Example:
|
|
222
|
+
.. code-block:: python
|
|
223
|
+
|
|
224
|
+
# response body for status code(s): 200
|
|
225
|
+
response == {
|
|
226
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
227
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
228
|
+
characters. Required.
|
|
229
|
+
"usageAttribution": {
|
|
230
|
+
"subjectKeys": [
|
|
231
|
+
"str" # The subjects that are attributed to the customer.
|
|
232
|
+
Required.
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
236
|
+
"billingAddress": {
|
|
237
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
238
|
+
for tax and invoicing.
|
|
239
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
240
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
241
|
+
Custom two-letter country codes are also supported for convenience.
|
|
242
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
243
|
+
Used for tax and invoicing.
|
|
244
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
245
|
+
Used for tax and invoicing.
|
|
246
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
247
|
+
customer. Used for tax and invoicing.
|
|
248
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
249
|
+
customer. Used for tax and invoicing.
|
|
250
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
251
|
+
for tax and invoicing.
|
|
252
|
+
},
|
|
253
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
254
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
255
|
+
and invoicing.
|
|
256
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
257
|
+
deleted.
|
|
258
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
259
|
+
Maximum 1024 characters.
|
|
260
|
+
"external": {
|
|
261
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
262
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
263
|
+
provider.
|
|
264
|
+
},
|
|
265
|
+
"metadata": {},
|
|
266
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
267
|
+
customer.
|
|
268
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
269
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
270
|
+
}
|
|
271
|
+
"""
|
|
272
|
+
|
|
273
|
+
@distributed_trace_async
|
|
274
|
+
async def create_customer(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
275
|
+
# pylint: disable=line-too-long
|
|
276
|
+
"""Create a new customer.
|
|
277
|
+
|
|
278
|
+
:param body: Is either a JSON type or a IO[bytes] type. Required.
|
|
279
|
+
:type body: JSON or IO[bytes]
|
|
280
|
+
:return: JSON object
|
|
281
|
+
:rtype: JSON
|
|
282
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
283
|
+
|
|
284
|
+
Example:
|
|
285
|
+
.. code-block:: python
|
|
286
|
+
|
|
287
|
+
# JSON input template you can fill out and use as your body input.
|
|
288
|
+
body = {
|
|
289
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
290
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
291
|
+
characters. Required.
|
|
292
|
+
"usageAttribution": {
|
|
293
|
+
"subjectKeys": [
|
|
294
|
+
"str" # The subjects that are attributed to the customer.
|
|
295
|
+
Required.
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
299
|
+
"billingAddress": {
|
|
300
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
301
|
+
for tax and invoicing.
|
|
302
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
303
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
304
|
+
Custom two-letter country codes are also supported for convenience.
|
|
305
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
306
|
+
Used for tax and invoicing.
|
|
307
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
308
|
+
Used for tax and invoicing.
|
|
309
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
310
|
+
customer. Used for tax and invoicing.
|
|
311
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
312
|
+
customer. Used for tax and invoicing.
|
|
313
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
314
|
+
for tax and invoicing.
|
|
315
|
+
},
|
|
316
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
317
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
318
|
+
and invoicing.
|
|
319
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
320
|
+
deleted.
|
|
321
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
322
|
+
Maximum 1024 characters.
|
|
323
|
+
"external": {
|
|
324
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
325
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
326
|
+
provider.
|
|
327
|
+
},
|
|
328
|
+
"metadata": {},
|
|
329
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
330
|
+
customer.
|
|
331
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
332
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
# response body for status code(s): 200
|
|
336
|
+
response == {
|
|
337
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
338
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
339
|
+
characters. Required.
|
|
340
|
+
"usageAttribution": {
|
|
341
|
+
"subjectKeys": [
|
|
342
|
+
"str" # The subjects that are attributed to the customer.
|
|
343
|
+
Required.
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
347
|
+
"billingAddress": {
|
|
348
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
349
|
+
for tax and invoicing.
|
|
350
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
351
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
352
|
+
Custom two-letter country codes are also supported for convenience.
|
|
353
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
354
|
+
Used for tax and invoicing.
|
|
355
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
356
|
+
Used for tax and invoicing.
|
|
357
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
358
|
+
customer. Used for tax and invoicing.
|
|
359
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
360
|
+
customer. Used for tax and invoicing.
|
|
361
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
362
|
+
for tax and invoicing.
|
|
363
|
+
},
|
|
364
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
365
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
366
|
+
and invoicing.
|
|
367
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
368
|
+
deleted.
|
|
369
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
370
|
+
Maximum 1024 characters.
|
|
371
|
+
"external": {
|
|
372
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
373
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
374
|
+
provider.
|
|
375
|
+
},
|
|
376
|
+
"metadata": {},
|
|
377
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
378
|
+
customer.
|
|
379
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
380
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
381
|
+
}
|
|
382
|
+
"""
|
|
383
|
+
error_map = {
|
|
384
|
+
404: ResourceNotFoundError,
|
|
385
|
+
409: ResourceExistsError,
|
|
386
|
+
304: ResourceNotModifiedError,
|
|
387
|
+
400: HttpResponseError,
|
|
388
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
389
|
+
}
|
|
390
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
391
|
+
|
|
392
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
393
|
+
_params = kwargs.pop("params", {}) or {}
|
|
394
|
+
|
|
395
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
396
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
397
|
+
|
|
398
|
+
content_type = content_type or "application/json"
|
|
399
|
+
_json = None
|
|
400
|
+
_content = None
|
|
401
|
+
if isinstance(body, (IOBase, bytes)):
|
|
402
|
+
_content = body
|
|
403
|
+
else:
|
|
404
|
+
_json = body
|
|
405
|
+
|
|
406
|
+
_request = build_create_customer_request(
|
|
407
|
+
content_type=content_type,
|
|
408
|
+
json=_json,
|
|
409
|
+
content=_content,
|
|
410
|
+
headers=_headers,
|
|
411
|
+
params=_params,
|
|
412
|
+
)
|
|
413
|
+
_request.url = self._client.format_url(_request.url)
|
|
414
|
+
|
|
415
|
+
_stream = False
|
|
416
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
417
|
+
_request, stream=_stream, **kwargs
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
response = pipeline_response.http_response
|
|
421
|
+
|
|
422
|
+
if response.status_code not in [200]:
|
|
423
|
+
if _stream:
|
|
424
|
+
await response.read() # Load the body in memory and close the socket
|
|
425
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
426
|
+
raise HttpResponseError(response=response)
|
|
427
|
+
|
|
428
|
+
if response.content:
|
|
429
|
+
deserialized = response.json()
|
|
430
|
+
else:
|
|
431
|
+
deserialized = None
|
|
432
|
+
|
|
433
|
+
if cls:
|
|
434
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
435
|
+
|
|
436
|
+
return cast(JSON, deserialized) # type: ignore
|
|
437
|
+
|
|
438
|
+
@distributed_trace_async
|
|
439
|
+
async def list_customers(
|
|
440
|
+
self, *, include_deleted: bool = False, page: int = 1, page_size: int = 100, **kwargs: Any
|
|
441
|
+
) -> List[JSON]:
|
|
442
|
+
# pylint: disable=line-too-long
|
|
443
|
+
"""List customers.
|
|
444
|
+
|
|
445
|
+
:keyword include_deleted: Include deleted customers. Default value is False.
|
|
446
|
+
:paramtype include_deleted: bool
|
|
447
|
+
:keyword page: The page number. Default value is 1.
|
|
448
|
+
:paramtype page: int
|
|
449
|
+
:keyword page_size: The number of items in the page. Default value is 100.
|
|
450
|
+
:paramtype page_size: int
|
|
451
|
+
:return: list of JSON object
|
|
452
|
+
:rtype: list[JSON]
|
|
453
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
454
|
+
|
|
455
|
+
Example:
|
|
456
|
+
.. code-block:: python
|
|
457
|
+
|
|
458
|
+
# response body for status code(s): 200
|
|
459
|
+
response == [
|
|
460
|
+
{
|
|
461
|
+
"items": [
|
|
462
|
+
{
|
|
463
|
+
"id": {}, # A unique identifier for the customer.
|
|
464
|
+
Required.
|
|
465
|
+
"name": "str", # Human-readable name for the
|
|
466
|
+
resource. Between 1 and 256 characters. Required.
|
|
467
|
+
"usageAttribution": {
|
|
468
|
+
"subjectKeys": [
|
|
469
|
+
"str" # The subjects that are
|
|
470
|
+
attributed to the customer. Required.
|
|
471
|
+
]
|
|
472
|
+
},
|
|
473
|
+
"archivedAt": {}, # Optional. Timestamp of when the
|
|
474
|
+
resource was archived.
|
|
475
|
+
"billingAddress": {
|
|
476
|
+
"city": "str", # Optional. The billing
|
|
477
|
+
address of the customer. Used for tax and invoicing.
|
|
478
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
479
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2
|
|
480
|
+
country code. Custom two-letter country codes are also supported
|
|
481
|
+
for convenience.
|
|
482
|
+
"line1": "str", # Optional. The billing
|
|
483
|
+
address of the customer. Used for tax and invoicing.
|
|
484
|
+
"line2": "str", # Optional. The billing
|
|
485
|
+
address of the customer. Used for tax and invoicing.
|
|
486
|
+
"phoneNumber": "str", # Optional. The
|
|
487
|
+
billing address of the customer. Used for tax and invoicing.
|
|
488
|
+
"postalCode": "str", # Optional. The billing
|
|
489
|
+
address of the customer. Used for tax and invoicing.
|
|
490
|
+
"state": "str" # Optional. The billing
|
|
491
|
+
address of the customer. Used for tax and invoicing.
|
|
492
|
+
},
|
|
493
|
+
"createdAt": {}, # Optional. Timestamp of when the
|
|
494
|
+
resource was created.
|
|
495
|
+
"currency": {}, # Optional. Currency of the
|
|
496
|
+
customer. Used for billing, tax and invoicing.
|
|
497
|
+
"deletedAt": {}, # Optional. Timestamp of when the
|
|
498
|
+
resource was permanently deleted.
|
|
499
|
+
"description": "str", # Optional. Optional
|
|
500
|
+
description of the resource. Maximum 1024 characters.
|
|
501
|
+
"external": {
|
|
502
|
+
"stripeCustomerId": "str" # Optional. The
|
|
503
|
+
Stripe customer ID. Mapping to a Stripe Customer object. Required
|
|
504
|
+
to use Stripe as an invocing provider.
|
|
505
|
+
},
|
|
506
|
+
"metadata": {},
|
|
507
|
+
"primaryEmail": "str", # Optional. The primary email
|
|
508
|
+
address of the customer.
|
|
509
|
+
"timezone": "str", # Optional. Timezone of the
|
|
510
|
+
customer.
|
|
511
|
+
"updatedAt": {} # Optional. Timestamp of when the
|
|
512
|
+
resource was last updated.
|
|
513
|
+
}
|
|
514
|
+
],
|
|
515
|
+
"page": 0, # The page number. Required.
|
|
516
|
+
"pageSize": 0, # The number of items in the page. Required.
|
|
517
|
+
"totalCount": 0 # The total number of items. Required.
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
"""
|
|
521
|
+
error_map = {
|
|
522
|
+
404: ResourceNotFoundError,
|
|
523
|
+
409: ResourceExistsError,
|
|
524
|
+
304: ResourceNotModifiedError,
|
|
525
|
+
400: HttpResponseError,
|
|
526
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
527
|
+
}
|
|
528
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
529
|
+
|
|
530
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
531
|
+
_params = kwargs.pop("params", {}) or {}
|
|
532
|
+
|
|
533
|
+
cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
|
|
534
|
+
|
|
535
|
+
_request = build_list_customers_request(
|
|
536
|
+
include_deleted=include_deleted,
|
|
537
|
+
page=page,
|
|
538
|
+
page_size=page_size,
|
|
539
|
+
headers=_headers,
|
|
540
|
+
params=_params,
|
|
541
|
+
)
|
|
542
|
+
_request.url = self._client.format_url(_request.url)
|
|
543
|
+
|
|
544
|
+
_stream = False
|
|
545
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
546
|
+
_request, stream=_stream, **kwargs
|
|
547
|
+
)
|
|
548
|
+
|
|
549
|
+
response = pipeline_response.http_response
|
|
550
|
+
|
|
551
|
+
if response.status_code not in [200]:
|
|
552
|
+
if _stream:
|
|
553
|
+
await response.read() # Load the body in memory and close the socket
|
|
554
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
555
|
+
raise HttpResponseError(response=response)
|
|
556
|
+
|
|
557
|
+
if response.content:
|
|
558
|
+
deserialized = response.json()
|
|
559
|
+
else:
|
|
560
|
+
deserialized = None
|
|
561
|
+
|
|
562
|
+
if cls:
|
|
563
|
+
return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
|
|
564
|
+
|
|
565
|
+
return cast(List[JSON], deserialized) # type: ignore
|
|
566
|
+
|
|
567
|
+
@distributed_trace_async
|
|
568
|
+
async def get_customer(self, customer_id_or_key: Any, **kwargs: Any) -> JSON:
|
|
569
|
+
# pylint: disable=line-too-long
|
|
570
|
+
"""Get a customer by ID or key.
|
|
571
|
+
|
|
572
|
+
:param customer_id_or_key: Required.
|
|
573
|
+
:type customer_id_or_key: any
|
|
574
|
+
:return: JSON object
|
|
575
|
+
:rtype: JSON
|
|
576
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
577
|
+
|
|
578
|
+
Example:
|
|
579
|
+
.. code-block:: python
|
|
580
|
+
|
|
581
|
+
# response body for status code(s): 200
|
|
582
|
+
response == {
|
|
583
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
584
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
585
|
+
characters. Required.
|
|
586
|
+
"usageAttribution": {
|
|
587
|
+
"subjectKeys": [
|
|
588
|
+
"str" # The subjects that are attributed to the customer.
|
|
589
|
+
Required.
|
|
590
|
+
]
|
|
591
|
+
},
|
|
592
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
593
|
+
"billingAddress": {
|
|
594
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
595
|
+
for tax and invoicing.
|
|
596
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
597
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
598
|
+
Custom two-letter country codes are also supported for convenience.
|
|
599
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
600
|
+
Used for tax and invoicing.
|
|
601
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
602
|
+
Used for tax and invoicing.
|
|
603
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
604
|
+
customer. Used for tax and invoicing.
|
|
605
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
606
|
+
customer. Used for tax and invoicing.
|
|
607
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
608
|
+
for tax and invoicing.
|
|
609
|
+
},
|
|
610
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
611
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
612
|
+
and invoicing.
|
|
613
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
614
|
+
deleted.
|
|
615
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
616
|
+
Maximum 1024 characters.
|
|
617
|
+
"external": {
|
|
618
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
619
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
620
|
+
provider.
|
|
621
|
+
},
|
|
622
|
+
"metadata": {},
|
|
623
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
624
|
+
customer.
|
|
625
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
626
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
627
|
+
}
|
|
628
|
+
"""
|
|
629
|
+
error_map = {
|
|
630
|
+
404: ResourceNotFoundError,
|
|
631
|
+
409: ResourceExistsError,
|
|
632
|
+
304: ResourceNotModifiedError,
|
|
633
|
+
400: HttpResponseError,
|
|
634
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
635
|
+
}
|
|
636
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
637
|
+
|
|
638
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
639
|
+
_params = kwargs.pop("params", {}) or {}
|
|
640
|
+
|
|
641
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
642
|
+
|
|
643
|
+
_request = build_get_customer_request(
|
|
644
|
+
customer_id_or_key=customer_id_or_key,
|
|
645
|
+
headers=_headers,
|
|
646
|
+
params=_params,
|
|
647
|
+
)
|
|
648
|
+
_request.url = self._client.format_url(_request.url)
|
|
649
|
+
|
|
650
|
+
_stream = False
|
|
651
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
652
|
+
_request, stream=_stream, **kwargs
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
response = pipeline_response.http_response
|
|
656
|
+
|
|
657
|
+
if response.status_code not in [200]:
|
|
658
|
+
if _stream:
|
|
659
|
+
await response.read() # Load the body in memory and close the socket
|
|
660
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
661
|
+
raise HttpResponseError(response=response)
|
|
662
|
+
|
|
663
|
+
if response.content:
|
|
664
|
+
deserialized = response.json()
|
|
665
|
+
else:
|
|
666
|
+
deserialized = None
|
|
667
|
+
|
|
668
|
+
if cls:
|
|
669
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
670
|
+
|
|
671
|
+
return cast(JSON, deserialized) # type: ignore
|
|
672
|
+
|
|
673
|
+
@overload
|
|
674
|
+
async def update_customer(
|
|
675
|
+
self, customer_id_or_key: Any, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
676
|
+
) -> JSON:
|
|
677
|
+
# pylint: disable=line-too-long
|
|
678
|
+
"""Update a customer by ID or key.
|
|
679
|
+
|
|
680
|
+
:param customer_id_or_key: Required.
|
|
681
|
+
:type customer_id_or_key: any
|
|
682
|
+
:param body: Required.
|
|
683
|
+
:type body: JSON
|
|
684
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
685
|
+
Default value is "application/json".
|
|
686
|
+
:paramtype content_type: str
|
|
687
|
+
:return: JSON object
|
|
688
|
+
:rtype: JSON
|
|
689
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
690
|
+
|
|
691
|
+
Example:
|
|
692
|
+
.. code-block:: python
|
|
693
|
+
|
|
694
|
+
# JSON input template you can fill out and use as your body input.
|
|
695
|
+
body = {
|
|
696
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
697
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
698
|
+
characters. Required.
|
|
699
|
+
"usageAttribution": {
|
|
700
|
+
"subjectKeys": [
|
|
701
|
+
"str" # The subjects that are attributed to the customer.
|
|
702
|
+
Required.
|
|
703
|
+
]
|
|
704
|
+
},
|
|
705
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
706
|
+
"billingAddress": {
|
|
707
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
708
|
+
for tax and invoicing.
|
|
709
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
710
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
711
|
+
Custom two-letter country codes are also supported for convenience.
|
|
712
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
713
|
+
Used for tax and invoicing.
|
|
714
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
715
|
+
Used for tax and invoicing.
|
|
716
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
717
|
+
customer. Used for tax and invoicing.
|
|
718
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
719
|
+
customer. Used for tax and invoicing.
|
|
720
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
721
|
+
for tax and invoicing.
|
|
722
|
+
},
|
|
723
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
724
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
725
|
+
and invoicing.
|
|
726
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
727
|
+
deleted.
|
|
728
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
729
|
+
Maximum 1024 characters.
|
|
730
|
+
"external": {
|
|
731
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
732
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
733
|
+
provider.
|
|
734
|
+
},
|
|
735
|
+
"metadata": {},
|
|
736
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
737
|
+
customer.
|
|
738
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
739
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
# response body for status code(s): 200
|
|
743
|
+
response == {
|
|
744
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
745
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
746
|
+
characters. Required.
|
|
747
|
+
"usageAttribution": {
|
|
748
|
+
"subjectKeys": [
|
|
749
|
+
"str" # The subjects that are attributed to the customer.
|
|
750
|
+
Required.
|
|
751
|
+
]
|
|
752
|
+
},
|
|
753
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
754
|
+
"billingAddress": {
|
|
755
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
756
|
+
for tax and invoicing.
|
|
757
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
758
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
759
|
+
Custom two-letter country codes are also supported for convenience.
|
|
760
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
761
|
+
Used for tax and invoicing.
|
|
762
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
763
|
+
Used for tax and invoicing.
|
|
764
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
765
|
+
customer. Used for tax and invoicing.
|
|
766
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
767
|
+
customer. Used for tax and invoicing.
|
|
768
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
769
|
+
for tax and invoicing.
|
|
770
|
+
},
|
|
771
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
772
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
773
|
+
and invoicing.
|
|
774
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
775
|
+
deleted.
|
|
776
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
777
|
+
Maximum 1024 characters.
|
|
778
|
+
"external": {
|
|
779
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
780
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
781
|
+
provider.
|
|
782
|
+
},
|
|
783
|
+
"metadata": {},
|
|
784
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
785
|
+
customer.
|
|
786
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
787
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
788
|
+
}
|
|
789
|
+
"""
|
|
790
|
+
|
|
791
|
+
@overload
|
|
792
|
+
async def update_customer(
|
|
793
|
+
self, customer_id_or_key: Any, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
794
|
+
) -> JSON:
|
|
795
|
+
# pylint: disable=line-too-long
|
|
796
|
+
"""Update a customer by ID or key.
|
|
797
|
+
|
|
798
|
+
:param customer_id_or_key: Required.
|
|
799
|
+
:type customer_id_or_key: any
|
|
800
|
+
:param body: Required.
|
|
801
|
+
:type body: IO[bytes]
|
|
802
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
803
|
+
Default value is "application/json".
|
|
804
|
+
:paramtype content_type: str
|
|
805
|
+
:return: JSON object
|
|
806
|
+
:rtype: JSON
|
|
807
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
808
|
+
|
|
809
|
+
Example:
|
|
810
|
+
.. code-block:: python
|
|
811
|
+
|
|
812
|
+
# response body for status code(s): 200
|
|
813
|
+
response == {
|
|
814
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
815
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
816
|
+
characters. Required.
|
|
817
|
+
"usageAttribution": {
|
|
818
|
+
"subjectKeys": [
|
|
819
|
+
"str" # The subjects that are attributed to the customer.
|
|
820
|
+
Required.
|
|
821
|
+
]
|
|
822
|
+
},
|
|
823
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
824
|
+
"billingAddress": {
|
|
825
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
826
|
+
for tax and invoicing.
|
|
827
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
828
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
829
|
+
Custom two-letter country codes are also supported for convenience.
|
|
830
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
831
|
+
Used for tax and invoicing.
|
|
832
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
833
|
+
Used for tax and invoicing.
|
|
834
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
835
|
+
customer. Used for tax and invoicing.
|
|
836
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
837
|
+
customer. Used for tax and invoicing.
|
|
838
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
839
|
+
for tax and invoicing.
|
|
840
|
+
},
|
|
841
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
842
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
843
|
+
and invoicing.
|
|
844
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
845
|
+
deleted.
|
|
846
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
847
|
+
Maximum 1024 characters.
|
|
848
|
+
"external": {
|
|
849
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
850
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
851
|
+
provider.
|
|
852
|
+
},
|
|
853
|
+
"metadata": {},
|
|
854
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
855
|
+
customer.
|
|
856
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
857
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
858
|
+
}
|
|
859
|
+
"""
|
|
860
|
+
|
|
861
|
+
@distributed_trace_async
|
|
862
|
+
async def update_customer(self, customer_id_or_key: Any, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
863
|
+
# pylint: disable=line-too-long
|
|
864
|
+
"""Update a customer by ID or key.
|
|
865
|
+
|
|
866
|
+
:param customer_id_or_key: Required.
|
|
867
|
+
:type customer_id_or_key: any
|
|
868
|
+
:param body: Is either a JSON type or a IO[bytes] type. Required.
|
|
869
|
+
:type body: JSON or IO[bytes]
|
|
870
|
+
:return: JSON object
|
|
871
|
+
:rtype: JSON
|
|
872
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
873
|
+
|
|
874
|
+
Example:
|
|
875
|
+
.. code-block:: python
|
|
876
|
+
|
|
877
|
+
# JSON input template you can fill out and use as your body input.
|
|
878
|
+
body = {
|
|
879
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
880
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
881
|
+
characters. Required.
|
|
882
|
+
"usageAttribution": {
|
|
883
|
+
"subjectKeys": [
|
|
884
|
+
"str" # The subjects that are attributed to the customer.
|
|
885
|
+
Required.
|
|
886
|
+
]
|
|
887
|
+
},
|
|
888
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
889
|
+
"billingAddress": {
|
|
890
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
891
|
+
for tax and invoicing.
|
|
892
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
893
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
894
|
+
Custom two-letter country codes are also supported for convenience.
|
|
895
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
896
|
+
Used for tax and invoicing.
|
|
897
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
898
|
+
Used for tax and invoicing.
|
|
899
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
900
|
+
customer. Used for tax and invoicing.
|
|
901
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
902
|
+
customer. Used for tax and invoicing.
|
|
903
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
904
|
+
for tax and invoicing.
|
|
905
|
+
},
|
|
906
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
907
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
908
|
+
and invoicing.
|
|
909
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
910
|
+
deleted.
|
|
911
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
912
|
+
Maximum 1024 characters.
|
|
913
|
+
"external": {
|
|
914
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
915
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
916
|
+
provider.
|
|
917
|
+
},
|
|
918
|
+
"metadata": {},
|
|
919
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
920
|
+
customer.
|
|
921
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
922
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
# response body for status code(s): 200
|
|
926
|
+
response == {
|
|
927
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
928
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
929
|
+
characters. Required.
|
|
930
|
+
"usageAttribution": {
|
|
931
|
+
"subjectKeys": [
|
|
932
|
+
"str" # The subjects that are attributed to the customer.
|
|
933
|
+
Required.
|
|
934
|
+
]
|
|
935
|
+
},
|
|
936
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
937
|
+
"billingAddress": {
|
|
938
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
939
|
+
for tax and invoicing.
|
|
940
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
941
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
942
|
+
Custom two-letter country codes are also supported for convenience.
|
|
943
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
944
|
+
Used for tax and invoicing.
|
|
945
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
946
|
+
Used for tax and invoicing.
|
|
947
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
948
|
+
customer. Used for tax and invoicing.
|
|
949
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
950
|
+
customer. Used for tax and invoicing.
|
|
951
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
952
|
+
for tax and invoicing.
|
|
953
|
+
},
|
|
954
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
955
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
956
|
+
and invoicing.
|
|
957
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
958
|
+
deleted.
|
|
959
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
960
|
+
Maximum 1024 characters.
|
|
961
|
+
"external": {
|
|
962
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
963
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
964
|
+
provider.
|
|
965
|
+
},
|
|
966
|
+
"metadata": {},
|
|
967
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
968
|
+
customer.
|
|
969
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
970
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
971
|
+
}
|
|
972
|
+
"""
|
|
973
|
+
error_map = {
|
|
974
|
+
404: ResourceNotFoundError,
|
|
975
|
+
409: ResourceExistsError,
|
|
976
|
+
304: ResourceNotModifiedError,
|
|
977
|
+
400: HttpResponseError,
|
|
978
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
979
|
+
}
|
|
980
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
981
|
+
|
|
982
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
983
|
+
_params = kwargs.pop("params", {}) or {}
|
|
984
|
+
|
|
985
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
986
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
987
|
+
|
|
988
|
+
content_type = content_type or "application/json"
|
|
989
|
+
_json = None
|
|
990
|
+
_content = None
|
|
991
|
+
if isinstance(body, (IOBase, bytes)):
|
|
992
|
+
_content = body
|
|
993
|
+
else:
|
|
994
|
+
_json = body
|
|
995
|
+
|
|
996
|
+
_request = build_update_customer_request(
|
|
997
|
+
customer_id_or_key=customer_id_or_key,
|
|
998
|
+
content_type=content_type,
|
|
999
|
+
json=_json,
|
|
1000
|
+
content=_content,
|
|
1001
|
+
headers=_headers,
|
|
1002
|
+
params=_params,
|
|
1003
|
+
)
|
|
1004
|
+
_request.url = self._client.format_url(_request.url)
|
|
1005
|
+
|
|
1006
|
+
_stream = False
|
|
1007
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
1008
|
+
_request, stream=_stream, **kwargs
|
|
1009
|
+
)
|
|
1010
|
+
|
|
1011
|
+
response = pipeline_response.http_response
|
|
1012
|
+
|
|
1013
|
+
if response.status_code not in [200]:
|
|
1014
|
+
if _stream:
|
|
1015
|
+
await response.read() # Load the body in memory and close the socket
|
|
1016
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
1017
|
+
raise HttpResponseError(response=response)
|
|
1018
|
+
|
|
1019
|
+
if response.content:
|
|
1020
|
+
deserialized = response.json()
|
|
1021
|
+
else:
|
|
1022
|
+
deserialized = None
|
|
1023
|
+
|
|
1024
|
+
if cls:
|
|
1025
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
1026
|
+
|
|
1027
|
+
return cast(JSON, deserialized) # type: ignore
|
|
1028
|
+
|
|
1029
|
+
@distributed_trace_async
|
|
1030
|
+
async def delete_customer(self, customer_id_or_key: Any, **kwargs: Any) -> JSON:
|
|
1031
|
+
# pylint: disable=line-too-long
|
|
1032
|
+
"""Delete a customer by ID or key.
|
|
1033
|
+
|
|
1034
|
+
:param customer_id_or_key: Required.
|
|
1035
|
+
:type customer_id_or_key: any
|
|
1036
|
+
:return: JSON object
|
|
1037
|
+
:rtype: JSON
|
|
1038
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1039
|
+
|
|
1040
|
+
Example:
|
|
1041
|
+
.. code-block:: python
|
|
1042
|
+
|
|
1043
|
+
# response body for status code(s): 200
|
|
1044
|
+
response == {
|
|
1045
|
+
"id": {}, # A unique identifier for the customer. Required.
|
|
1046
|
+
"name": "str", # Human-readable name for the resource. Between 1 and 256
|
|
1047
|
+
characters. Required.
|
|
1048
|
+
"usageAttribution": {
|
|
1049
|
+
"subjectKeys": [
|
|
1050
|
+
"str" # The subjects that are attributed to the customer.
|
|
1051
|
+
Required.
|
|
1052
|
+
]
|
|
1053
|
+
},
|
|
1054
|
+
"archivedAt": {}, # Optional. Timestamp of when the resource was archived.
|
|
1055
|
+
"billingAddress": {
|
|
1056
|
+
"city": "str", # Optional. The billing address of the customer. Used
|
|
1057
|
+
for tax and invoicing.
|
|
1058
|
+
"country": "str", # Optional. `ISO 3166-1
|
|
1059
|
+
<https://www.iso.org/iso-3166-country-codes.html>`_ alpha-2 country code.
|
|
1060
|
+
Custom two-letter country codes are also supported for convenience.
|
|
1061
|
+
"line1": "str", # Optional. The billing address of the customer.
|
|
1062
|
+
Used for tax and invoicing.
|
|
1063
|
+
"line2": "str", # Optional. The billing address of the customer.
|
|
1064
|
+
Used for tax and invoicing.
|
|
1065
|
+
"phoneNumber": "str", # Optional. The billing address of the
|
|
1066
|
+
customer. Used for tax and invoicing.
|
|
1067
|
+
"postalCode": "str", # Optional. The billing address of the
|
|
1068
|
+
customer. Used for tax and invoicing.
|
|
1069
|
+
"state": "str" # Optional. The billing address of the customer. Used
|
|
1070
|
+
for tax and invoicing.
|
|
1071
|
+
},
|
|
1072
|
+
"createdAt": {}, # Optional. Timestamp of when the resource was created.
|
|
1073
|
+
"currency": {}, # Optional. Currency of the customer. Used for billing, tax
|
|
1074
|
+
and invoicing.
|
|
1075
|
+
"deletedAt": {}, # Optional. Timestamp of when the resource was permanently
|
|
1076
|
+
deleted.
|
|
1077
|
+
"description": "str", # Optional. Optional description of the resource.
|
|
1078
|
+
Maximum 1024 characters.
|
|
1079
|
+
"external": {
|
|
1080
|
+
"stripeCustomerId": "str" # Optional. The Stripe customer ID.
|
|
1081
|
+
Mapping to a Stripe Customer object. Required to use Stripe as an invocing
|
|
1082
|
+
provider.
|
|
1083
|
+
},
|
|
1084
|
+
"metadata": {},
|
|
1085
|
+
"primaryEmail": "str", # Optional. The primary email address of the
|
|
1086
|
+
customer.
|
|
1087
|
+
"timezone": "str", # Optional. Timezone of the customer.
|
|
1088
|
+
"updatedAt": {} # Optional. Timestamp of when the resource was last updated.
|
|
1089
|
+
}
|
|
1090
|
+
"""
|
|
1091
|
+
error_map = {
|
|
1092
|
+
404: ResourceNotFoundError,
|
|
1093
|
+
409: ResourceExistsError,
|
|
1094
|
+
304: ResourceNotModifiedError,
|
|
1095
|
+
400: HttpResponseError,
|
|
1096
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
1097
|
+
}
|
|
1098
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
1099
|
+
|
|
1100
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
1101
|
+
_params = kwargs.pop("params", {}) or {}
|
|
1102
|
+
|
|
1103
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
1104
|
+
|
|
1105
|
+
_request = build_delete_customer_request(
|
|
1106
|
+
customer_id_or_key=customer_id_or_key,
|
|
1107
|
+
headers=_headers,
|
|
1108
|
+
params=_params,
|
|
1109
|
+
)
|
|
1110
|
+
_request.url = self._client.format_url(_request.url)
|
|
1111
|
+
|
|
1112
|
+
_stream = False
|
|
1113
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
1114
|
+
_request, stream=_stream, **kwargs
|
|
1115
|
+
)
|
|
1116
|
+
|
|
1117
|
+
response = pipeline_response.http_response
|
|
1118
|
+
|
|
1119
|
+
if response.status_code not in [200]:
|
|
1120
|
+
if _stream:
|
|
1121
|
+
await response.read() # Load the body in memory and close the socket
|
|
1122
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
1123
|
+
raise HttpResponseError(response=response)
|
|
1124
|
+
|
|
1125
|
+
if response.content:
|
|
1126
|
+
deserialized = response.json()
|
|
1127
|
+
else:
|
|
1128
|
+
deserialized = None
|
|
1129
|
+
|
|
1130
|
+
if cls:
|
|
1131
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
1132
|
+
|
|
1133
|
+
return cast(JSON, deserialized) # type: ignore
|
|
1134
|
+
|
|
88
1135
|
@distributed_trace_async
|
|
89
1136
|
async def list_events(
|
|
90
1137
|
self,
|
|
@@ -1447,11 +2494,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1447
2494
|
# response body for status code(s): 200
|
|
1448
2495
|
response == [
|
|
1449
2496
|
{
|
|
2497
|
+
"id": "str", # Required.
|
|
1450
2498
|
"key": "str", # Required.
|
|
1451
2499
|
"currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
|
|
1452
2500
|
"currentPeriodStart": "2020-02-20 00:00:00", # Optional.
|
|
1453
2501
|
"displayName": "str", # Optional.
|
|
1454
|
-
"id": "str", # Optional.
|
|
1455
2502
|
"metadata": {
|
|
1456
2503
|
"str": {} # Optional. Dictionary of :code:`<any>`.
|
|
1457
2504
|
},
|
|
@@ -1528,11 +2575,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1528
2575
|
# JSON input template you can fill out and use as your body input.
|
|
1529
2576
|
body = [
|
|
1530
2577
|
{
|
|
2578
|
+
"id": "str", # Required.
|
|
1531
2579
|
"key": "str", # Required.
|
|
1532
2580
|
"currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
|
|
1533
2581
|
"currentPeriodStart": "2020-02-20 00:00:00", # Optional.
|
|
1534
2582
|
"displayName": "str", # Optional.
|
|
1535
|
-
"id": "str", # Optional.
|
|
1536
2583
|
"metadata": {
|
|
1537
2584
|
"str": {} # Optional. Dictionary of :code:`<any>`.
|
|
1538
2585
|
},
|
|
@@ -1543,11 +2590,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1543
2590
|
# response body for status code(s): 200
|
|
1544
2591
|
response == [
|
|
1545
2592
|
{
|
|
2593
|
+
"id": "str", # Required.
|
|
1546
2594
|
"key": "str", # Required.
|
|
1547
2595
|
"currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
|
|
1548
2596
|
"currentPeriodStart": "2020-02-20 00:00:00", # Optional.
|
|
1549
2597
|
"displayName": "str", # Optional.
|
|
1550
|
-
"id": "str", # Optional.
|
|
1551
2598
|
"metadata": {
|
|
1552
2599
|
"str": {} # Optional. Dictionary of :code:`<any>`.
|
|
1553
2600
|
},
|
|
@@ -1583,11 +2630,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1583
2630
|
# response body for status code(s): 200
|
|
1584
2631
|
response == [
|
|
1585
2632
|
{
|
|
2633
|
+
"id": "str", # Required.
|
|
1586
2634
|
"key": "str", # Required.
|
|
1587
2635
|
"currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
|
|
1588
2636
|
"currentPeriodStart": "2020-02-20 00:00:00", # Optional.
|
|
1589
2637
|
"displayName": "str", # Optional.
|
|
1590
|
-
"id": "str", # Optional.
|
|
1591
2638
|
"metadata": {
|
|
1592
2639
|
"str": {} # Optional. Dictionary of :code:`<any>`.
|
|
1593
2640
|
},
|
|
@@ -1618,11 +2665,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1618
2665
|
# response body for status code(s): 200
|
|
1619
2666
|
response == [
|
|
1620
2667
|
{
|
|
2668
|
+
"id": "str", # Required.
|
|
1621
2669
|
"key": "str", # Required.
|
|
1622
2670
|
"currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
|
|
1623
2671
|
"currentPeriodStart": "2020-02-20 00:00:00", # Optional.
|
|
1624
2672
|
"displayName": "str", # Optional.
|
|
1625
|
-
"id": "str", # Optional.
|
|
1626
2673
|
"metadata": {
|
|
1627
2674
|
"str": {} # Optional. Dictionary of :code:`<any>`.
|
|
1628
2675
|
},
|
|
@@ -1705,11 +2752,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1705
2752
|
|
|
1706
2753
|
# response body for status code(s): 200
|
|
1707
2754
|
response == {
|
|
2755
|
+
"id": "str", # Required.
|
|
1708
2756
|
"key": "str", # Required.
|
|
1709
2757
|
"currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
|
|
1710
2758
|
"currentPeriodStart": "2020-02-20 00:00:00", # Optional.
|
|
1711
2759
|
"displayName": "str", # Optional.
|
|
1712
|
-
"id": "str", # Optional.
|
|
1713
2760
|
"metadata": {
|
|
1714
2761
|
"str": {} # Optional. Dictionary of :code:`<any>`.
|
|
1715
2762
|
},
|