openmeter 1.0.0b53__py3-none-any.whl → 2.0.0__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.

Files changed (132) hide show
  1. openmeter/__init__.py +89 -15
  2. openmeter/_base_client.py +2041 -0
  3. openmeter/_client.py +518 -70
  4. openmeter/_compat.py +221 -0
  5. openmeter/_constants.py +14 -0
  6. openmeter/_exceptions.py +108 -0
  7. openmeter/_files.py +127 -0
  8. openmeter/_models.py +777 -0
  9. openmeter/_qs.py +150 -0
  10. openmeter/_resource.py +43 -0
  11. openmeter/_response.py +820 -0
  12. openmeter/_streaming.py +333 -0
  13. openmeter/_types.py +222 -0
  14. openmeter/_utils/__init__.py +56 -0
  15. openmeter/_utils/_logs.py +25 -0
  16. openmeter/_utils/_proxy.py +63 -0
  17. openmeter/_utils/_reflection.py +42 -0
  18. openmeter/_utils/_streams.py +12 -0
  19. openmeter/_utils/_sync.py +81 -0
  20. openmeter/_utils/_transform.py +387 -0
  21. openmeter/_utils/_typing.py +120 -0
  22. openmeter/_utils/_utils.py +419 -0
  23. openmeter/_version.py +4 -0
  24. openmeter/lib/.keep +4 -0
  25. openmeter/py.typed +0 -1
  26. openmeter/resources/__init__.py +103 -0
  27. openmeter/resources/debug/__init__.py +33 -0
  28. openmeter/resources/debug/debug.py +102 -0
  29. openmeter/resources/debug/metrics.py +146 -0
  30. openmeter/resources/entitlements/__init__.py +47 -0
  31. openmeter/resources/entitlements/entitlements.py +450 -0
  32. openmeter/resources/entitlements/features.py +578 -0
  33. openmeter/resources/entitlements/grants.py +389 -0
  34. openmeter/resources/events.py +442 -0
  35. openmeter/resources/meters/__init__.py +33 -0
  36. openmeter/resources/meters/meters.py +666 -0
  37. openmeter/resources/meters/subjects.py +163 -0
  38. openmeter/resources/notifications/__init__.py +75 -0
  39. openmeter/resources/notifications/channels.py +686 -0
  40. openmeter/resources/notifications/events.py +365 -0
  41. openmeter/resources/notifications/notifications.py +198 -0
  42. openmeter/resources/notifications/rules.py +781 -0
  43. openmeter/resources/notifications/webhook.py +208 -0
  44. openmeter/resources/portal/__init__.py +47 -0
  45. openmeter/resources/portal/meters.py +230 -0
  46. openmeter/resources/portal/portal.py +112 -0
  47. openmeter/resources/portal/tokens.py +359 -0
  48. openmeter/resources/subjects/entitlements/__init__.py +33 -0
  49. openmeter/resources/subjects/entitlements/entitlements.py +1881 -0
  50. openmeter/resources/subjects/entitlements/grants.py +453 -0
  51. openmeter/resources/subjects.py +419 -0
  52. openmeter/types/__init__.py +21 -0
  53. openmeter/types/debug/__init__.py +5 -0
  54. openmeter/types/debug/metric_list_response.py +7 -0
  55. openmeter/types/entitlement.py +238 -0
  56. openmeter/types/entitlements/__init__.py +11 -0
  57. openmeter/types/entitlements/feature.py +61 -0
  58. openmeter/types/entitlements/feature_create_params.py +43 -0
  59. openmeter/types/entitlements/feature_list_params.py +23 -0
  60. openmeter/types/entitlements/grant_list_params.py +57 -0
  61. openmeter/types/entitlements/grant_list_response.py +11 -0
  62. openmeter/types/entitlements/grant_paginated_response.py +24 -0
  63. openmeter/types/entitlements/list_features_result.py +28 -0
  64. openmeter/types/event_ingest_params.py +46 -0
  65. openmeter/types/event_ingest_response.py +43 -0
  66. openmeter/types/event_list_params.py +22 -0
  67. openmeter/types/event_list_response.py +9 -0
  68. openmeter/types/ingested_event.py +59 -0
  69. openmeter/types/list_entitlements_result.py +28 -0
  70. openmeter/types/meter.py +53 -0
  71. openmeter/types/meter_create_params.py +50 -0
  72. openmeter/types/meter_list_response.py +9 -0
  73. openmeter/types/meter_query_params.py +50 -0
  74. openmeter/types/meter_query_result.py +35 -0
  75. openmeter/types/meters/__init__.py +5 -0
  76. openmeter/types/meters/subject_list_response.py +8 -0
  77. openmeter/types/notifications/__init__.py +18 -0
  78. openmeter/types/notifications/channel_create_params.py +34 -0
  79. openmeter/types/notifications/channel_list_params.py +41 -0
  80. openmeter/types/notifications/channel_list_response.py +24 -0
  81. openmeter/types/notifications/channel_update_params.py +34 -0
  82. openmeter/types/notifications/event_list_params.py +61 -0
  83. openmeter/types/notifications/event_list_response.py +24 -0
  84. openmeter/types/notifications/notification_channel.py +47 -0
  85. openmeter/types/notifications/notification_event.py +215 -0
  86. openmeter/types/notifications/notification_rule.py +70 -0
  87. openmeter/types/notifications/rule_create_params.py +39 -0
  88. openmeter/types/notifications/rule_list_params.py +54 -0
  89. openmeter/types/notifications/rule_list_response.py +24 -0
  90. openmeter/types/notifications/rule_update_params.py +39 -0
  91. openmeter/types/notifications/webhook_svix_params.py +26 -0
  92. openmeter/types/portal/__init__.py +10 -0
  93. openmeter/types/portal/meter_query_params.py +44 -0
  94. openmeter/types/portal/portal_token.py +28 -0
  95. openmeter/types/portal/token_create_params.py +17 -0
  96. openmeter/types/portal/token_invalidate_params.py +15 -0
  97. openmeter/types/portal/token_list_params.py +12 -0
  98. openmeter/types/portal/token_list_response.py +9 -0
  99. openmeter/types/shared/__init__.py +3 -0
  100. openmeter/types/subject.py +37 -0
  101. openmeter/types/subject_list_response.py +9 -0
  102. openmeter/types/subject_param.py +27 -0
  103. openmeter/types/subject_upsert_params.py +39 -0
  104. openmeter/types/subject_upsert_response.py +10 -0
  105. openmeter/types/subjects/__init__.py +13 -0
  106. openmeter/types/subjects/entitlement_history_params.py +35 -0
  107. openmeter/types/subjects/entitlement_history_response.py +98 -0
  108. openmeter/types/subjects/entitlement_list_response.py +10 -0
  109. openmeter/types/subjects/entitlements/__init__.py +8 -0
  110. openmeter/types/subjects/entitlements/entitlement_grant.py +103 -0
  111. openmeter/types/subjects/entitlements/grant_list_response.py +10 -0
  112. openmeter-2.0.0.dist-info/METADATA +396 -0
  113. openmeter-2.0.0.dist-info/RECORD +115 -0
  114. {openmeter-1.0.0b53.dist-info → openmeter-2.0.0.dist-info}/WHEEL +1 -1
  115. openmeter-2.0.0.dist-info/licenses/LICENSE +201 -0
  116. openmeter/_configuration.py +0 -36
  117. openmeter/_operations/__init__.py +0 -17
  118. openmeter/_operations/_operations.py +0 -2098
  119. openmeter/_operations/_patch.py +0 -20
  120. openmeter/_patch.py +0 -20
  121. openmeter/_serialization.py +0 -2008
  122. openmeter/_vendor.py +0 -24
  123. openmeter/aio/__init__.py +0 -21
  124. openmeter/aio/_client.py +0 -83
  125. openmeter/aio/_configuration.py +0 -36
  126. openmeter/aio/_operations/__init__.py +0 -17
  127. openmeter/aio/_operations/_operations.py +0 -1771
  128. openmeter/aio/_operations/_patch.py +0 -20
  129. openmeter/aio/_patch.py +0 -20
  130. openmeter/aio/_vendor.py +0 -24
  131. openmeter-1.0.0b53.dist-info/METADATA +0 -92
  132. openmeter-1.0.0b53.dist-info/RECORD +0 -21
@@ -1,1771 +0,0 @@
1
- # pylint: disable=too-many-lines
2
- # coding=utf-8
3
- # --------------------------------------------------------------------------
4
- # Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.1, generator: @autorest/python@6.9.4)
5
- # Changes may cause incorrect behavior and will be lost if the code is regenerated.
6
- # --------------------------------------------------------------------------
7
- import datetime
8
- from io import IOBase
9
- import sys
10
- from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload
11
-
12
- from azure.core.exceptions import (
13
- ClientAuthenticationError,
14
- HttpResponseError,
15
- ResourceExistsError,
16
- ResourceNotFoundError,
17
- ResourceNotModifiedError,
18
- map_error,
19
- )
20
- from azure.core.pipeline import PipelineResponse
21
- from azure.core.rest import AsyncHttpResponse, HttpRequest
22
- from azure.core.tracing.decorator_async import distributed_trace_async
23
- from azure.core.utils import case_insensitive_dict
24
-
25
- from ..._operations._operations import (
26
- build_create_meter_request,
27
- build_create_portal_token_request,
28
- build_delete_meter_request,
29
- build_delete_subject_request,
30
- build_get_meter_request,
31
- build_get_subject_request,
32
- build_ingest_events_request,
33
- build_invalidate_portal_tokens_request,
34
- build_list_events_request,
35
- build_list_meter_subjects_request,
36
- build_list_meters_request,
37
- build_list_portal_tokens_request,
38
- build_list_subjects_request,
39
- build_query_meter_request,
40
- build_query_portal_meter_request,
41
- build_upsert_subject_request,
42
- )
43
- from .._vendor import ClientMixinABC
44
-
45
- if sys.version_info >= (3, 9):
46
- from collections.abc import MutableMapping
47
- else:
48
- from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
49
- JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
50
- T = TypeVar("T")
51
- ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
52
-
53
-
54
- class ClientOperationsMixin(ClientMixinABC):
55
- @overload
56
- async def ingest_events( # pylint: disable=inconsistent-return-statements
57
- self, body: JSON, *, content_type: str = "application/cloudevents+json", **kwargs: Any
58
- ) -> None:
59
- """Ingest events.
60
-
61
- :param body: Required.
62
- :type body: JSON
63
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
64
- Default value is "application/cloudevents+json".
65
- :paramtype content_type: str
66
- :return: None
67
- :rtype: None
68
- :raises ~azure.core.exceptions.HttpResponseError:
69
-
70
- Example:
71
- .. code-block:: python
72
-
73
- # JSON input template you can fill out and use as your body input.
74
- body = {
75
- "id": "str", # Identifies the event. Required.
76
- "source": "str", # Identifies the context in which an event happened.
77
- Required.
78
- "specversion": "str", # The version of the CloudEvents specification which
79
- the event uses. Required.
80
- "subject": "str", # Describes the subject of the event in the context of the
81
- event producer (identified by source). Required.
82
- "type": "str", # Describes the type of event related to the originating
83
- occurrence. Required.
84
- "data": {
85
- "str": {} # Optional. The event payload.
86
- },
87
- "datacontenttype": "str", # Optional. Content type of the data value. Must
88
- adhere to RFC 2046 format. "application/json"
89
- "dataschema": "str", # Optional. Identifies the schema that data adheres to.
90
- "time": "2020-02-20 00:00:00" # Optional. Timestamp of when the occurrence
91
- happened. Must adhere to RFC 3339.
92
- }
93
- """
94
-
95
- @overload
96
- async def ingest_events( # pylint: disable=inconsistent-return-statements
97
- self, body: List[JSON], *, content_type: str = "application/cloudevents-batch+json", **kwargs: Any
98
- ) -> None:
99
- """Ingest events.
100
-
101
- :param body: Required.
102
- :type body: list[JSON]
103
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
104
- Default value is "application/cloudevents-batch+json".
105
- :paramtype content_type: str
106
- :return: None
107
- :rtype: None
108
- :raises ~azure.core.exceptions.HttpResponseError:
109
-
110
- Example:
111
- .. code-block:: python
112
-
113
- # JSON input template you can fill out and use as your body input.
114
- body = [
115
- {
116
- "id": "str", # Identifies the event. Required.
117
- "source": "str", # Identifies the context in which an event
118
- happened. Required.
119
- "specversion": "str", # The version of the CloudEvents specification
120
- which the event uses. Required.
121
- "subject": "str", # Describes the subject of the event in the
122
- context of the event producer (identified by source). Required.
123
- "type": "str", # Describes the type of event related to the
124
- originating occurrence. Required.
125
- "data": {
126
- "str": {} # Optional. The event payload.
127
- },
128
- "datacontenttype": "str", # Optional. Content type of the data
129
- value. Must adhere to RFC 2046 format. "application/json"
130
- "dataschema": "str", # Optional. Identifies the schema that data
131
- adheres to.
132
- "time": "2020-02-20 00:00:00" # Optional. Timestamp of when the
133
- occurrence happened. Must adhere to RFC 3339.
134
- }
135
- ]
136
- """
137
-
138
- @distributed_trace_async
139
- async def ingest_events( # pylint: disable=inconsistent-return-statements
140
- self, body: Union[JSON, List[JSON]], **kwargs: Any
141
- ) -> None:
142
- """Ingest events.
143
-
144
- :param body: Is either a JSON type or a [JSON] type. Required.
145
- :type body: JSON or list[JSON]
146
- :keyword content_type: Body Parameter content-type. Known values are:
147
- 'application/cloudevents+json', 'application/cloudevents-batch+json'. Default value is None.
148
- :paramtype content_type: str
149
- :return: None
150
- :rtype: None
151
- :raises ~azure.core.exceptions.HttpResponseError:
152
-
153
- Example:
154
- .. code-block:: python
155
-
156
- # JSON input template you can fill out and use as your body input.
157
- body = {
158
- "id": "str", # Identifies the event. Required.
159
- "source": "str", # Identifies the context in which an event happened.
160
- Required.
161
- "specversion": "str", # The version of the CloudEvents specification which
162
- the event uses. Required.
163
- "subject": "str", # Describes the subject of the event in the context of the
164
- event producer (identified by source). Required.
165
- "type": "str", # Describes the type of event related to the originating
166
- occurrence. Required.
167
- "data": {
168
- "str": {} # Optional. The event payload.
169
- },
170
- "datacontenttype": "str", # Optional. Content type of the data value. Must
171
- adhere to RFC 2046 format. "application/json"
172
- "dataschema": "str", # Optional. Identifies the schema that data adheres to.
173
- "time": "2020-02-20 00:00:00" # Optional. Timestamp of when the occurrence
174
- happened. Must adhere to RFC 3339.
175
- }
176
- """
177
- error_map = {
178
- 401: ClientAuthenticationError,
179
- 404: ResourceNotFoundError,
180
- 409: ResourceExistsError,
181
- 304: ResourceNotModifiedError,
182
- 400: HttpResponseError,
183
- }
184
- error_map.update(kwargs.pop("error_map", {}) or {})
185
-
186
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
187
- _params = kwargs.pop("params", {}) or {}
188
-
189
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
190
- cls: ClsType[None] = kwargs.pop("cls", None)
191
-
192
- _json = None
193
- if isinstance(body, MutableMapping):
194
- content_type = content_type or "application/cloudevents+json"
195
- _json = body
196
- elif isinstance(body, list):
197
- content_type = content_type or "application/cloudevents-batch+json"
198
- _json = body
199
-
200
- _request = build_ingest_events_request(
201
- content_type=content_type,
202
- json=_json,
203
- headers=_headers,
204
- params=_params,
205
- )
206
- _request.url = self._client.format_url(_request.url)
207
-
208
- _stream = False
209
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
210
- _request, stream=_stream, **kwargs
211
- )
212
-
213
- response = pipeline_response.http_response
214
-
215
- if response.status_code not in [204]:
216
- if _stream:
217
- await response.read() # Load the body in memory and close the socket
218
- map_error(status_code=response.status_code, response=response, error_map=error_map)
219
- raise HttpResponseError(response=response)
220
-
221
- if cls:
222
- return cls(pipeline_response, None, {}) # type: ignore
223
-
224
- @distributed_trace_async
225
- async def list_events(
226
- self,
227
- *,
228
- from_parameter: Optional[datetime.datetime] = None,
229
- to: Optional[datetime.datetime] = None,
230
- limit: Optional[int] = None,
231
- **kwargs: Any
232
- ) -> List[JSON]:
233
- """Retrieve latest raw events.
234
-
235
- :keyword from_parameter: Start date-time in RFC 3339 format.
236
- Inclusive. Default value is None.
237
- :paramtype from_parameter: ~datetime.datetime
238
- :keyword to: End date-time in RFC 3339 format.
239
- Inclusive. Default value is None.
240
- :paramtype to: ~datetime.datetime
241
- :keyword limit: Number of events to return. Default value is None.
242
- :paramtype limit: int
243
- :return: list of JSON object
244
- :rtype: list[JSON]
245
- :raises ~azure.core.exceptions.HttpResponseError:
246
-
247
- Example:
248
- .. code-block:: python
249
-
250
- # response body for status code(s): 200
251
- response == [
252
- {
253
- "event": {
254
- "id": "str", # Identifies the event. Required.
255
- "source": "str", # Identifies the context in which an event
256
- happened. Required.
257
- "specversion": "str", # The version of the CloudEvents
258
- specification which the event uses. Required.
259
- "subject": "str", # Describes the subject of the event in
260
- the context of the event producer (identified by source). Required.
261
- "type": "str", # Describes the type of event related to the
262
- originating occurrence. Required.
263
- "data": {
264
- "str": {} # Optional. The event payload.
265
- },
266
- "datacontenttype": "str", # Optional. Content type of the
267
- data value. Must adhere to RFC 2046 format. "application/json"
268
- "dataschema": "str", # Optional. Identifies the schema that
269
- data adheres to.
270
- "time": "2020-02-20 00:00:00" # Optional. Timestamp of when
271
- the occurrence happened. Must adhere to RFC 3339.
272
- },
273
- "validationError": "str" # Optional.
274
- }
275
- ]
276
- """
277
- error_map = {
278
- 401: ClientAuthenticationError,
279
- 404: ResourceNotFoundError,
280
- 409: ResourceExistsError,
281
- 304: ResourceNotModifiedError,
282
- 400: HttpResponseError,
283
- }
284
- error_map.update(kwargs.pop("error_map", {}) or {})
285
-
286
- _headers = kwargs.pop("headers", {}) or {}
287
- _params = kwargs.pop("params", {}) or {}
288
-
289
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
290
-
291
- _request = build_list_events_request(
292
- from_parameter=from_parameter,
293
- to=to,
294
- limit=limit,
295
- headers=_headers,
296
- params=_params,
297
- )
298
- _request.url = self._client.format_url(_request.url)
299
-
300
- _stream = False
301
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
302
- _request, stream=_stream, **kwargs
303
- )
304
-
305
- response = pipeline_response.http_response
306
-
307
- if response.status_code not in [200]:
308
- if _stream:
309
- await response.read() # Load the body in memory and close the socket
310
- map_error(status_code=response.status_code, response=response, error_map=error_map)
311
- raise HttpResponseError(response=response)
312
-
313
- if response.content:
314
- deserialized = response.json()
315
- else:
316
- deserialized = None
317
-
318
- if cls:
319
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
320
-
321
- return cast(List[JSON], deserialized) # type: ignore
322
-
323
- @distributed_trace_async
324
- async def list_meters(self, **kwargs: Any) -> List[JSON]:
325
- """List meters.
326
-
327
- :return: list of JSON object
328
- :rtype: list[JSON]
329
- :raises ~azure.core.exceptions.HttpResponseError:
330
-
331
- Example:
332
- .. code-block:: python
333
-
334
- # response body for status code(s): 200
335
- response == [
336
- {
337
- "aggregation": "str", # The aggregation type to use for the meter.
338
- Required. Known values are: "SUM", "COUNT", "AVG", "MIN", and "MAX".
339
- "eventType": "str", # The event type to aggregate. Required.
340
- "slug": "str", # A unique identifier for the meter. Required.
341
- "windowSize": "str", # Aggregation window size. Required. Known
342
- values are: "MINUTE", "HOUR", and "DAY".
343
- "description": "str", # Optional. A description of the meter.
344
- "groupBy": {
345
- "str": "str" # Optional. Named JSONPath expressions to
346
- extract the group by values from the event data.
347
- },
348
- "id": "str", # Optional. A unique identifier for the meter.
349
- "valueProperty": "str" # Optional. JSONPath expression to extract
350
- the value from the event data.
351
- }
352
- ]
353
- """
354
- error_map = {
355
- 401: ClientAuthenticationError,
356
- 404: ResourceNotFoundError,
357
- 409: ResourceExistsError,
358
- 304: ResourceNotModifiedError,
359
- }
360
- error_map.update(kwargs.pop("error_map", {}) or {})
361
-
362
- _headers = kwargs.pop("headers", {}) or {}
363
- _params = kwargs.pop("params", {}) or {}
364
-
365
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
366
-
367
- _request = build_list_meters_request(
368
- headers=_headers,
369
- params=_params,
370
- )
371
- _request.url = self._client.format_url(_request.url)
372
-
373
- _stream = False
374
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
375
- _request, stream=_stream, **kwargs
376
- )
377
-
378
- response = pipeline_response.http_response
379
-
380
- if response.status_code not in [200]:
381
- if _stream:
382
- await response.read() # Load the body in memory and close the socket
383
- map_error(status_code=response.status_code, response=response, error_map=error_map)
384
- raise HttpResponseError(response=response)
385
-
386
- if response.content:
387
- deserialized = response.json()
388
- else:
389
- deserialized = None
390
-
391
- if cls:
392
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
393
-
394
- return cast(List[JSON], deserialized) # type: ignore
395
-
396
- @overload
397
- async def create_meter(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
398
- """Create meter.
399
-
400
- :param body: Required.
401
- :type body: JSON
402
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
403
- Default value is "application/json".
404
- :paramtype content_type: str
405
- :return: JSON object
406
- :rtype: JSON
407
- :raises ~azure.core.exceptions.HttpResponseError:
408
-
409
- Example:
410
- .. code-block:: python
411
-
412
- # JSON input template you can fill out and use as your body input.
413
- body = {
414
- "aggregation": "str", # The aggregation type to use for the meter. Required.
415
- Known values are: "SUM", "COUNT", "AVG", "MIN", and "MAX".
416
- "eventType": "str", # The event type to aggregate. Required.
417
- "slug": "str", # A unique identifier for the meter. Required.
418
- "windowSize": "str", # Aggregation window size. Required. Known values are:
419
- "MINUTE", "HOUR", and "DAY".
420
- "description": "str", # Optional. A description of the meter.
421
- "groupBy": {
422
- "str": "str" # Optional. Named JSONPath expressions to extract the
423
- group by values from the event data.
424
- },
425
- "id": "str", # Optional. A unique identifier for the meter.
426
- "valueProperty": "str" # Optional. JSONPath expression to extract the value
427
- from the event data.
428
- }
429
-
430
- # response body for status code(s): 201
431
- response == {
432
- "aggregation": "str", # The aggregation type to use for the meter. Required.
433
- Known values are: "SUM", "COUNT", "AVG", "MIN", and "MAX".
434
- "eventType": "str", # The event type to aggregate. Required.
435
- "slug": "str", # A unique identifier for the meter. Required.
436
- "windowSize": "str", # Aggregation window size. Required. Known values are:
437
- "MINUTE", "HOUR", and "DAY".
438
- "description": "str", # Optional. A description of the meter.
439
- "groupBy": {
440
- "str": "str" # Optional. Named JSONPath expressions to extract the
441
- group by values from the event data.
442
- },
443
- "id": "str", # Optional. A unique identifier for the meter.
444
- "valueProperty": "str" # Optional. JSONPath expression to extract the value
445
- from the event data.
446
- }
447
- """
448
-
449
- @overload
450
- async def create_meter(self, body: IO, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
451
- """Create meter.
452
-
453
- :param body: Required.
454
- :type body: IO
455
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
456
- Default value is "application/json".
457
- :paramtype content_type: str
458
- :return: JSON object
459
- :rtype: JSON
460
- :raises ~azure.core.exceptions.HttpResponseError:
461
-
462
- Example:
463
- .. code-block:: python
464
-
465
- # response body for status code(s): 201
466
- response == {
467
- "aggregation": "str", # The aggregation type to use for the meter. Required.
468
- Known values are: "SUM", "COUNT", "AVG", "MIN", and "MAX".
469
- "eventType": "str", # The event type to aggregate. Required.
470
- "slug": "str", # A unique identifier for the meter. Required.
471
- "windowSize": "str", # Aggregation window size. Required. Known values are:
472
- "MINUTE", "HOUR", and "DAY".
473
- "description": "str", # Optional. A description of the meter.
474
- "groupBy": {
475
- "str": "str" # Optional. Named JSONPath expressions to extract the
476
- group by values from the event data.
477
- },
478
- "id": "str", # Optional. A unique identifier for the meter.
479
- "valueProperty": "str" # Optional. JSONPath expression to extract the value
480
- from the event data.
481
- }
482
- """
483
-
484
- @distributed_trace_async
485
- async def create_meter(self, body: Union[JSON, IO], **kwargs: Any) -> JSON:
486
- """Create meter.
487
-
488
- :param body: Is either a JSON type or a IO type. Required.
489
- :type body: JSON or IO
490
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
491
- Default value is None.
492
- :paramtype content_type: str
493
- :return: JSON object
494
- :rtype: JSON
495
- :raises ~azure.core.exceptions.HttpResponseError:
496
-
497
- Example:
498
- .. code-block:: python
499
-
500
- # JSON input template you can fill out and use as your body input.
501
- body = {
502
- "aggregation": "str", # The aggregation type to use for the meter. Required.
503
- Known values are: "SUM", "COUNT", "AVG", "MIN", and "MAX".
504
- "eventType": "str", # The event type to aggregate. Required.
505
- "slug": "str", # A unique identifier for the meter. Required.
506
- "windowSize": "str", # Aggregation window size. Required. Known values are:
507
- "MINUTE", "HOUR", and "DAY".
508
- "description": "str", # Optional. A description of the meter.
509
- "groupBy": {
510
- "str": "str" # Optional. Named JSONPath expressions to extract the
511
- group by values from the event data.
512
- },
513
- "id": "str", # Optional. A unique identifier for the meter.
514
- "valueProperty": "str" # Optional. JSONPath expression to extract the value
515
- from the event data.
516
- }
517
-
518
- # response body for status code(s): 201
519
- response == {
520
- "aggregation": "str", # The aggregation type to use for the meter. Required.
521
- Known values are: "SUM", "COUNT", "AVG", "MIN", and "MAX".
522
- "eventType": "str", # The event type to aggregate. Required.
523
- "slug": "str", # A unique identifier for the meter. Required.
524
- "windowSize": "str", # Aggregation window size. Required. Known values are:
525
- "MINUTE", "HOUR", and "DAY".
526
- "description": "str", # Optional. A description of the meter.
527
- "groupBy": {
528
- "str": "str" # Optional. Named JSONPath expressions to extract the
529
- group by values from the event data.
530
- },
531
- "id": "str", # Optional. A unique identifier for the meter.
532
- "valueProperty": "str" # Optional. JSONPath expression to extract the value
533
- from the event data.
534
- }
535
- """
536
- error_map = {
537
- 401: ClientAuthenticationError,
538
- 404: ResourceNotFoundError,
539
- 409: ResourceExistsError,
540
- 304: ResourceNotModifiedError,
541
- 400: HttpResponseError,
542
- 501: HttpResponseError,
543
- }
544
- error_map.update(kwargs.pop("error_map", {}) or {})
545
-
546
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
547
- _params = kwargs.pop("params", {}) or {}
548
-
549
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
550
- cls: ClsType[JSON] = kwargs.pop("cls", None)
551
-
552
- content_type = content_type or "application/json"
553
- _json = None
554
- _content = None
555
- if isinstance(body, (IOBase, bytes)):
556
- _content = body
557
- else:
558
- _json = body
559
-
560
- _request = build_create_meter_request(
561
- content_type=content_type,
562
- json=_json,
563
- content=_content,
564
- headers=_headers,
565
- params=_params,
566
- )
567
- _request.url = self._client.format_url(_request.url)
568
-
569
- _stream = False
570
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
571
- _request, stream=_stream, **kwargs
572
- )
573
-
574
- response = pipeline_response.http_response
575
-
576
- if response.status_code not in [201]:
577
- if _stream:
578
- await response.read() # Load the body in memory and close the socket
579
- map_error(status_code=response.status_code, response=response, error_map=error_map)
580
- raise HttpResponseError(response=response)
581
-
582
- if response.content:
583
- deserialized = response.json()
584
- else:
585
- deserialized = None
586
-
587
- if cls:
588
- return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
589
-
590
- return cast(JSON, deserialized) # type: ignore
591
-
592
- @distributed_trace_async
593
- async def get_meter(self, meter_id_or_slug: str, **kwargs: Any) -> JSON:
594
- """Get meter by slugs.
595
-
596
- :param meter_id_or_slug: A unique identifier for the meter. Required.
597
- :type meter_id_or_slug: str
598
- :return: JSON object
599
- :rtype: JSON
600
- :raises ~azure.core.exceptions.HttpResponseError:
601
-
602
- Example:
603
- .. code-block:: python
604
-
605
- # response body for status code(s): 200
606
- response == {
607
- "aggregation": "str", # The aggregation type to use for the meter. Required.
608
- Known values are: "SUM", "COUNT", "AVG", "MIN", and "MAX".
609
- "eventType": "str", # The event type to aggregate. Required.
610
- "slug": "str", # A unique identifier for the meter. Required.
611
- "windowSize": "str", # Aggregation window size. Required. Known values are:
612
- "MINUTE", "HOUR", and "DAY".
613
- "description": "str", # Optional. A description of the meter.
614
- "groupBy": {
615
- "str": "str" # Optional. Named JSONPath expressions to extract the
616
- group by values from the event data.
617
- },
618
- "id": "str", # Optional. A unique identifier for the meter.
619
- "valueProperty": "str" # Optional. JSONPath expression to extract the value
620
- from the event data.
621
- }
622
- """
623
- error_map = {
624
- 401: ClientAuthenticationError,
625
- 409: ResourceExistsError,
626
- 304: ResourceNotModifiedError,
627
- 404: lambda response: ResourceNotFoundError(response=response),
628
- }
629
- error_map.update(kwargs.pop("error_map", {}) or {})
630
-
631
- _headers = kwargs.pop("headers", {}) or {}
632
- _params = kwargs.pop("params", {}) or {}
633
-
634
- cls: ClsType[JSON] = kwargs.pop("cls", None)
635
-
636
- _request = build_get_meter_request(
637
- meter_id_or_slug=meter_id_or_slug,
638
- headers=_headers,
639
- params=_params,
640
- )
641
- _request.url = self._client.format_url(_request.url)
642
-
643
- _stream = False
644
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
645
- _request, stream=_stream, **kwargs
646
- )
647
-
648
- response = pipeline_response.http_response
649
-
650
- if response.status_code not in [200]:
651
- if _stream:
652
- await response.read() # Load the body in memory and close the socket
653
- map_error(status_code=response.status_code, response=response, error_map=error_map)
654
- raise HttpResponseError(response=response)
655
-
656
- if response.content:
657
- deserialized = response.json()
658
- else:
659
- deserialized = None
660
-
661
- if cls:
662
- return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
663
-
664
- return cast(JSON, deserialized) # type: ignore
665
-
666
- @distributed_trace_async
667
- async def delete_meter( # pylint: disable=inconsistent-return-statements
668
- self, meter_id_or_slug: str, **kwargs: Any
669
- ) -> None:
670
- """Delete meter by slug.
671
-
672
- :param meter_id_or_slug: A unique identifier for the meter. Required.
673
- :type meter_id_or_slug: str
674
- :return: None
675
- :rtype: None
676
- :raises ~azure.core.exceptions.HttpResponseError:
677
- """
678
- error_map = {
679
- 401: ClientAuthenticationError,
680
- 409: ResourceExistsError,
681
- 304: ResourceNotModifiedError,
682
- 404: lambda response: ResourceNotFoundError(response=response),
683
- 501: HttpResponseError,
684
- }
685
- error_map.update(kwargs.pop("error_map", {}) or {})
686
-
687
- _headers = kwargs.pop("headers", {}) or {}
688
- _params = kwargs.pop("params", {}) or {}
689
-
690
- cls: ClsType[None] = kwargs.pop("cls", None)
691
-
692
- _request = build_delete_meter_request(
693
- meter_id_or_slug=meter_id_or_slug,
694
- headers=_headers,
695
- params=_params,
696
- )
697
- _request.url = self._client.format_url(_request.url)
698
-
699
- _stream = False
700
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
701
- _request, stream=_stream, **kwargs
702
- )
703
-
704
- response = pipeline_response.http_response
705
-
706
- if response.status_code not in [204]:
707
- if _stream:
708
- await response.read() # Load the body in memory and close the socket
709
- map_error(status_code=response.status_code, response=response, error_map=error_map)
710
- raise HttpResponseError(response=response)
711
-
712
- if cls:
713
- return cls(pipeline_response, None, {}) # type: ignore
714
-
715
- @distributed_trace_async
716
- async def query_meter(
717
- self,
718
- meter_id_or_slug: str,
719
- *,
720
- from_parameter: Optional[datetime.datetime] = None,
721
- to: Optional[datetime.datetime] = None,
722
- window_size: Optional[str] = None,
723
- window_time_zone: str = "UTC",
724
- subject: Optional[List[str]] = None,
725
- group_by: Optional[List[str]] = None,
726
- **kwargs: Any
727
- ) -> Union[JSON, str]:
728
- """Query meter.
729
-
730
- :param meter_id_or_slug: A unique identifier for the meter. Required.
731
- :type meter_id_or_slug: str
732
- :keyword from_parameter: Start date-time in RFC 3339 format.
733
- Inclusive. Default value is None.
734
- :paramtype from_parameter: ~datetime.datetime
735
- :keyword to: End date-time in RFC 3339 format.
736
- Inclusive. Default value is None.
737
- :paramtype to: ~datetime.datetime
738
- :keyword window_size: If not specified, a single usage aggregate will be returned for the
739
- entirety of the specified period for each subject and group. Known values are: "MINUTE",
740
- "HOUR", and "DAY". Default value is None.
741
- :paramtype window_size: str
742
- :keyword window_time_zone: The value is the name of the time zone as defined in the IANA Time
743
- Zone Database (http://www.iana.org/time-zones).
744
- If not specified, the UTC timezone will be used. Default value is "UTC".
745
- :paramtype window_time_zone: str
746
- :keyword subject: Default value is None.
747
- :paramtype subject: list[str]
748
- :keyword group_by: If not specified a single aggregate will be returned for each subject and
749
- time window.
750
- ``subject`` is a reserved group by value. Default value is None.
751
- :paramtype group_by: list[str]
752
- :return: JSON object or str
753
- :rtype: JSON or str
754
- :raises ~azure.core.exceptions.HttpResponseError:
755
-
756
- Example:
757
- .. code-block:: python
758
-
759
- # response body for status code(s): 200
760
- response == {
761
- "data": [
762
- {
763
- "value": 0.0, # Required.
764
- "windowEnd": "2020-02-20 00:00:00", # Required.
765
- "windowStart": "2020-02-20 00:00:00", # Required.
766
- "groupBy": {
767
- "str": "str" # Optional. Dictionary of
768
- :code:`<string>`.
769
- },
770
- "subject": "str" # Optional. The subject of the meter value.
771
- }
772
- ],
773
- "from": "2020-02-20 00:00:00", # Optional.
774
- "to": "2020-02-20 00:00:00", # Optional.
775
- "windowSize": "str" # Optional. Aggregation window size. Known values are:
776
- "MINUTE", "HOUR", and "DAY".
777
- }
778
- """
779
- error_map = {
780
- 401: ClientAuthenticationError,
781
- 404: ResourceNotFoundError,
782
- 409: ResourceExistsError,
783
- 304: ResourceNotModifiedError,
784
- 400: HttpResponseError,
785
- }
786
- error_map.update(kwargs.pop("error_map", {}) or {})
787
-
788
- _headers = kwargs.pop("headers", {}) or {}
789
- _params = kwargs.pop("params", {}) or {}
790
-
791
- cls: ClsType[Union[JSON, str]] = kwargs.pop("cls", None)
792
-
793
- _request = build_query_meter_request(
794
- meter_id_or_slug=meter_id_or_slug,
795
- from_parameter=from_parameter,
796
- to=to,
797
- window_size=window_size,
798
- window_time_zone=window_time_zone,
799
- subject=subject,
800
- group_by=group_by,
801
- headers=_headers,
802
- params=_params,
803
- )
804
- _request.url = self._client.format_url(_request.url)
805
-
806
- _stream = False
807
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
808
- _request, stream=_stream, **kwargs
809
- )
810
-
811
- response = pipeline_response.http_response
812
-
813
- if response.status_code not in [200, 200]:
814
- if _stream:
815
- await response.read() # Load the body in memory and close the socket
816
- map_error(status_code=response.status_code, response=response, error_map=error_map)
817
- raise HttpResponseError(response=response)
818
-
819
- if response.status_code == 200:
820
- if response.content:
821
- deserialized = response.json()
822
- else:
823
- deserialized = None
824
-
825
- if response.status_code == 200:
826
- if response.content:
827
- deserialized = response.json()
828
- else:
829
- deserialized = None
830
-
831
- if cls:
832
- return cls(pipeline_response, cast(Union[JSON, str], deserialized), {}) # type: ignore
833
-
834
- return cast(Union[JSON, str], deserialized) # type: ignore
835
-
836
- @distributed_trace_async
837
- async def list_meter_subjects(self, meter_id_or_slug: str, **kwargs: Any) -> List[str]:
838
- """List meter subjects.
839
-
840
- :param meter_id_or_slug: A unique identifier for the meter. Required.
841
- :type meter_id_or_slug: str
842
- :return: list of str
843
- :rtype: list[str]
844
- :raises ~azure.core.exceptions.HttpResponseError:
845
-
846
- Example:
847
- .. code-block:: python
848
-
849
- # response body for status code(s): 200
850
- response == [
851
- "str" # Optional.
852
- ]
853
- """
854
- error_map = {
855
- 401: ClientAuthenticationError,
856
- 404: ResourceNotFoundError,
857
- 409: ResourceExistsError,
858
- 304: ResourceNotModifiedError,
859
- 400: HttpResponseError,
860
- }
861
- error_map.update(kwargs.pop("error_map", {}) or {})
862
-
863
- _headers = kwargs.pop("headers", {}) or {}
864
- _params = kwargs.pop("params", {}) or {}
865
-
866
- cls: ClsType[List[str]] = kwargs.pop("cls", None)
867
-
868
- _request = build_list_meter_subjects_request(
869
- meter_id_or_slug=meter_id_or_slug,
870
- headers=_headers,
871
- params=_params,
872
- )
873
- _request.url = self._client.format_url(_request.url)
874
-
875
- _stream = False
876
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
877
- _request, stream=_stream, **kwargs
878
- )
879
-
880
- response = pipeline_response.http_response
881
-
882
- if response.status_code not in [200]:
883
- if _stream:
884
- await response.read() # Load the body in memory and close the socket
885
- map_error(status_code=response.status_code, response=response, error_map=error_map)
886
- raise HttpResponseError(response=response)
887
-
888
- if response.content:
889
- deserialized = response.json()
890
- else:
891
- deserialized = None
892
-
893
- if cls:
894
- return cls(pipeline_response, cast(List[str], deserialized), {}) # type: ignore
895
-
896
- return cast(List[str], deserialized) # type: ignore
897
-
898
- @overload
899
- async def create_portal_token(
900
- self, body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any
901
- ) -> JSON:
902
- """create_portal_token.
903
-
904
- :param body: Default value is None.
905
- :type body: JSON
906
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
907
- Default value is "application/json".
908
- :paramtype content_type: str
909
- :return: JSON object
910
- :rtype: JSON
911
- :raises ~azure.core.exceptions.HttpResponseError:
912
-
913
- Example:
914
- .. code-block:: python
915
-
916
- # JSON input template you can fill out and use as your body input.
917
- body = {
918
- "createdAt": "2020-02-20 00:00:00", # Required.
919
- "expiresAt": "2020-02-20 00:00:00", # Required.
920
- "id": "str", # Required.
921
- "subject": "str", # Required.
922
- "allowedMeterSlugs": [
923
- "str" # Optional. Optional, if defined only the specified meters
924
- will be allowed.
925
- ],
926
- "expired": bool, # Optional.
927
- "token": "str" # Optional. The token is only returned at creation.
928
- }
929
-
930
- # response body for status code(s): 200
931
- response == {
932
- "createdAt": "2020-02-20 00:00:00", # Required.
933
- "expiresAt": "2020-02-20 00:00:00", # Required.
934
- "id": "str", # Required.
935
- "subject": "str", # Required.
936
- "allowedMeterSlugs": [
937
- "str" # Optional. Optional, if defined only the specified meters
938
- will be allowed.
939
- ],
940
- "expired": bool, # Optional.
941
- "token": "str" # Optional. The token is only returned at creation.
942
- }
943
- """
944
-
945
- @overload
946
- async def create_portal_token(
947
- self, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
948
- ) -> JSON:
949
- """create_portal_token.
950
-
951
- :param body: Default value is None.
952
- :type body: IO
953
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
954
- Default value is "application/json".
955
- :paramtype content_type: str
956
- :return: JSON object
957
- :rtype: JSON
958
- :raises ~azure.core.exceptions.HttpResponseError:
959
-
960
- Example:
961
- .. code-block:: python
962
-
963
- # response body for status code(s): 200
964
- response == {
965
- "createdAt": "2020-02-20 00:00:00", # Required.
966
- "expiresAt": "2020-02-20 00:00:00", # Required.
967
- "id": "str", # Required.
968
- "subject": "str", # Required.
969
- "allowedMeterSlugs": [
970
- "str" # Optional. Optional, if defined only the specified meters
971
- will be allowed.
972
- ],
973
- "expired": bool, # Optional.
974
- "token": "str" # Optional. The token is only returned at creation.
975
- }
976
- """
977
-
978
- @distributed_trace_async
979
- async def create_portal_token(self, body: Optional[Union[JSON, IO]] = None, **kwargs: Any) -> JSON:
980
- """create_portal_token.
981
-
982
- :param body: Is either a JSON type or a IO type. Default value is None.
983
- :type body: JSON or IO
984
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
985
- Default value is None.
986
- :paramtype content_type: str
987
- :return: JSON object
988
- :rtype: JSON
989
- :raises ~azure.core.exceptions.HttpResponseError:
990
-
991
- Example:
992
- .. code-block:: python
993
-
994
- # JSON input template you can fill out and use as your body input.
995
- body = {
996
- "createdAt": "2020-02-20 00:00:00", # Required.
997
- "expiresAt": "2020-02-20 00:00:00", # Required.
998
- "id": "str", # Required.
999
- "subject": "str", # Required.
1000
- "allowedMeterSlugs": [
1001
- "str" # Optional. Optional, if defined only the specified meters
1002
- will be allowed.
1003
- ],
1004
- "expired": bool, # Optional.
1005
- "token": "str" # Optional. The token is only returned at creation.
1006
- }
1007
-
1008
- # response body for status code(s): 200
1009
- response == {
1010
- "createdAt": "2020-02-20 00:00:00", # Required.
1011
- "expiresAt": "2020-02-20 00:00:00", # Required.
1012
- "id": "str", # Required.
1013
- "subject": "str", # Required.
1014
- "allowedMeterSlugs": [
1015
- "str" # Optional. Optional, if defined only the specified meters
1016
- will be allowed.
1017
- ],
1018
- "expired": bool, # Optional.
1019
- "token": "str" # Optional. The token is only returned at creation.
1020
- }
1021
- """
1022
- error_map = {
1023
- 401: ClientAuthenticationError,
1024
- 404: ResourceNotFoundError,
1025
- 409: ResourceExistsError,
1026
- 304: ResourceNotModifiedError,
1027
- 400: HttpResponseError,
1028
- }
1029
- error_map.update(kwargs.pop("error_map", {}) or {})
1030
-
1031
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1032
- _params = kwargs.pop("params", {}) or {}
1033
-
1034
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1035
- cls: ClsType[JSON] = kwargs.pop("cls", None)
1036
-
1037
- content_type = content_type or "application/json"
1038
- _json = None
1039
- _content = None
1040
- if isinstance(body, (IOBase, bytes)):
1041
- _content = body
1042
- else:
1043
- if body is not None:
1044
- _json = body
1045
- else:
1046
- _json = None
1047
-
1048
- _request = build_create_portal_token_request(
1049
- content_type=content_type,
1050
- json=_json,
1051
- content=_content,
1052
- headers=_headers,
1053
- params=_params,
1054
- )
1055
- _request.url = self._client.format_url(_request.url)
1056
-
1057
- _stream = False
1058
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1059
- _request, stream=_stream, **kwargs
1060
- )
1061
-
1062
- response = pipeline_response.http_response
1063
-
1064
- if response.status_code not in [200]:
1065
- if _stream:
1066
- await response.read() # Load the body in memory and close the socket
1067
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1068
- raise HttpResponseError(response=response)
1069
-
1070
- if response.content:
1071
- deserialized = response.json()
1072
- else:
1073
- deserialized = None
1074
-
1075
- if cls:
1076
- return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
1077
-
1078
- return cast(JSON, deserialized) # type: ignore
1079
-
1080
- @distributed_trace_async
1081
- async def list_portal_tokens(self, *, limit: int = 25, **kwargs: Any) -> List[JSON]:
1082
- """list_portal_tokens.
1083
-
1084
- :keyword limit: Number of portal tokens to return. Default is 25. Default value is 25.
1085
- :paramtype limit: int
1086
- :return: list of JSON object
1087
- :rtype: list[JSON]
1088
- :raises ~azure.core.exceptions.HttpResponseError:
1089
-
1090
- Example:
1091
- .. code-block:: python
1092
-
1093
- # response body for status code(s): 200
1094
- response == [
1095
- {
1096
- "createdAt": "2020-02-20 00:00:00", # Required.
1097
- "expiresAt": "2020-02-20 00:00:00", # Required.
1098
- "id": "str", # Required.
1099
- "subject": "str", # Required.
1100
- "allowedMeterSlugs": [
1101
- "str" # Optional. Optional, if defined only the specified
1102
- meters will be allowed.
1103
- ],
1104
- "expired": bool, # Optional.
1105
- "token": "str" # Optional. The token is only returned at creation.
1106
- }
1107
- ]
1108
- """
1109
- error_map = {
1110
- 401: ClientAuthenticationError,
1111
- 404: ResourceNotFoundError,
1112
- 409: ResourceExistsError,
1113
- 304: ResourceNotModifiedError,
1114
- 400: HttpResponseError,
1115
- }
1116
- error_map.update(kwargs.pop("error_map", {}) or {})
1117
-
1118
- _headers = kwargs.pop("headers", {}) or {}
1119
- _params = kwargs.pop("params", {}) or {}
1120
-
1121
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
1122
-
1123
- _request = build_list_portal_tokens_request(
1124
- limit=limit,
1125
- headers=_headers,
1126
- params=_params,
1127
- )
1128
- _request.url = self._client.format_url(_request.url)
1129
-
1130
- _stream = False
1131
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1132
- _request, stream=_stream, **kwargs
1133
- )
1134
-
1135
- response = pipeline_response.http_response
1136
-
1137
- if response.status_code not in [200]:
1138
- if _stream:
1139
- await response.read() # Load the body in memory and close the socket
1140
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1141
- raise HttpResponseError(response=response)
1142
-
1143
- if response.content:
1144
- deserialized = response.json()
1145
- else:
1146
- deserialized = None
1147
-
1148
- if cls:
1149
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
1150
-
1151
- return cast(List[JSON], deserialized) # type: ignore
1152
-
1153
- @overload
1154
- async def invalidate_portal_tokens( # pylint: disable=inconsistent-return-statements
1155
- self, body: Optional[JSON] = None, *, content_type: str = "application/json", **kwargs: Any
1156
- ) -> None:
1157
- """invalidate_portal_tokens.
1158
-
1159
- :param body: Default value is None.
1160
- :type body: JSON
1161
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1162
- Default value is "application/json".
1163
- :paramtype content_type: str
1164
- :return: None
1165
- :rtype: None
1166
- :raises ~azure.core.exceptions.HttpResponseError:
1167
-
1168
- Example:
1169
- .. code-block:: python
1170
-
1171
- # JSON input template you can fill out and use as your body input.
1172
- body = {
1173
- "id": "str", # Optional. Optional portal token ID to invalidate one token
1174
- by.
1175
- "subject": "str" # Optional. Optional subject to invalidate all tokens for
1176
- subject.
1177
- }
1178
- """
1179
-
1180
- @overload
1181
- async def invalidate_portal_tokens( # pylint: disable=inconsistent-return-statements
1182
- self, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
1183
- ) -> None:
1184
- """invalidate_portal_tokens.
1185
-
1186
- :param body: Default value is None.
1187
- :type body: IO
1188
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
1189
- Default value is "application/json".
1190
- :paramtype content_type: str
1191
- :return: None
1192
- :rtype: None
1193
- :raises ~azure.core.exceptions.HttpResponseError:
1194
- """
1195
-
1196
- @distributed_trace_async
1197
- async def invalidate_portal_tokens( # pylint: disable=inconsistent-return-statements
1198
- self, body: Optional[Union[JSON, IO]] = None, **kwargs: Any
1199
- ) -> None:
1200
- """invalidate_portal_tokens.
1201
-
1202
- :param body: Is either a JSON type or a IO type. Default value is None.
1203
- :type body: JSON or IO
1204
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
1205
- Default value is None.
1206
- :paramtype content_type: str
1207
- :return: None
1208
- :rtype: None
1209
- :raises ~azure.core.exceptions.HttpResponseError:
1210
-
1211
- Example:
1212
- .. code-block:: python
1213
-
1214
- # JSON input template you can fill out and use as your body input.
1215
- body = {
1216
- "id": "str", # Optional. Optional portal token ID to invalidate one token
1217
- by.
1218
- "subject": "str" # Optional. Optional subject to invalidate all tokens for
1219
- subject.
1220
- }
1221
- """
1222
- error_map = {
1223
- 401: ClientAuthenticationError,
1224
- 404: ResourceNotFoundError,
1225
- 409: ResourceExistsError,
1226
- 304: ResourceNotModifiedError,
1227
- 400: HttpResponseError,
1228
- }
1229
- error_map.update(kwargs.pop("error_map", {}) or {})
1230
-
1231
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1232
- _params = kwargs.pop("params", {}) or {}
1233
-
1234
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1235
- cls: ClsType[None] = kwargs.pop("cls", None)
1236
-
1237
- content_type = content_type or "application/json"
1238
- _json = None
1239
- _content = None
1240
- if isinstance(body, (IOBase, bytes)):
1241
- _content = body
1242
- else:
1243
- if body is not None:
1244
- _json = body
1245
- else:
1246
- _json = None
1247
-
1248
- _request = build_invalidate_portal_tokens_request(
1249
- content_type=content_type,
1250
- json=_json,
1251
- content=_content,
1252
- headers=_headers,
1253
- params=_params,
1254
- )
1255
- _request.url = self._client.format_url(_request.url)
1256
-
1257
- _stream = False
1258
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1259
- _request, stream=_stream, **kwargs
1260
- )
1261
-
1262
- response = pipeline_response.http_response
1263
-
1264
- if response.status_code not in [204]:
1265
- if _stream:
1266
- await response.read() # Load the body in memory and close the socket
1267
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1268
- raise HttpResponseError(response=response)
1269
-
1270
- if cls:
1271
- return cls(pipeline_response, None, {}) # type: ignore
1272
-
1273
- @distributed_trace_async
1274
- async def list_subjects(self, **kwargs: Any) -> List[JSON]:
1275
- """list_subjects.
1276
-
1277
- :return: list of JSON object
1278
- :rtype: list[JSON]
1279
- :raises ~azure.core.exceptions.HttpResponseError:
1280
-
1281
- Example:
1282
- .. code-block:: python
1283
-
1284
- # response body for status code(s): 200
1285
- response == [
1286
- {
1287
- "id": "str", # Required.
1288
- "key": "str", # Required.
1289
- "currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
1290
- "currentPeriodStart": "2020-02-20 00:00:00", # Optional.
1291
- "displayName": "str", # Optional.
1292
- "metadata": {
1293
- "str": {} # Optional. Dictionary of :code:`<any>`.
1294
- },
1295
- "stripeCustomerId": "str" # Optional.
1296
- }
1297
- ]
1298
- """
1299
- error_map = {
1300
- 401: ClientAuthenticationError,
1301
- 404: ResourceNotFoundError,
1302
- 409: ResourceExistsError,
1303
- 304: ResourceNotModifiedError,
1304
- }
1305
- error_map.update(kwargs.pop("error_map", {}) or {})
1306
-
1307
- _headers = kwargs.pop("headers", {}) or {}
1308
- _params = kwargs.pop("params", {}) or {}
1309
-
1310
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
1311
-
1312
- _request = build_list_subjects_request(
1313
- headers=_headers,
1314
- params=_params,
1315
- )
1316
- _request.url = self._client.format_url(_request.url)
1317
-
1318
- _stream = False
1319
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1320
- _request, stream=_stream, **kwargs
1321
- )
1322
-
1323
- response = pipeline_response.http_response
1324
-
1325
- if response.status_code not in [200]:
1326
- if _stream:
1327
- await response.read() # Load the body in memory and close the socket
1328
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1329
- raise HttpResponseError(response=response)
1330
-
1331
- if response.content:
1332
- deserialized = response.json()
1333
- else:
1334
- deserialized = None
1335
-
1336
- if cls:
1337
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
1338
-
1339
- return cast(List[JSON], deserialized) # type: ignore
1340
-
1341
- @overload
1342
- async def upsert_subject(
1343
- self, body: Optional[List[JSON]] = None, *, content_type: str = "application/json", **kwargs: Any
1344
- ) -> List[JSON]:
1345
- """Upserts a subject. Creates or updates subject.
1346
- If the subject doesn't exist, it will be created.
1347
- If the subject exists, it will be partially updated with the provided fields.
1348
-
1349
- :param body: Default value is None.
1350
- :type body: list[JSON]
1351
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1352
- Default value is "application/json".
1353
- :paramtype content_type: str
1354
- :return: list of JSON object
1355
- :rtype: list[JSON]
1356
- :raises ~azure.core.exceptions.HttpResponseError:
1357
-
1358
- Example:
1359
- .. code-block:: python
1360
-
1361
- # JSON input template you can fill out and use as your body input.
1362
- body = [
1363
- {
1364
- "id": "str", # Required.
1365
- "key": "str", # Required.
1366
- "currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
1367
- "currentPeriodStart": "2020-02-20 00:00:00", # Optional.
1368
- "displayName": "str", # Optional.
1369
- "metadata": {
1370
- "str": {} # Optional. Dictionary of :code:`<any>`.
1371
- },
1372
- "stripeCustomerId": "str" # Optional.
1373
- }
1374
- ]
1375
-
1376
- # response body for status code(s): 200
1377
- response == [
1378
- {
1379
- "id": "str", # Required.
1380
- "key": "str", # Required.
1381
- "currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
1382
- "currentPeriodStart": "2020-02-20 00:00:00", # Optional.
1383
- "displayName": "str", # Optional.
1384
- "metadata": {
1385
- "str": {} # Optional. Dictionary of :code:`<any>`.
1386
- },
1387
- "stripeCustomerId": "str" # Optional.
1388
- }
1389
- ]
1390
- """
1391
-
1392
- @overload
1393
- async def upsert_subject(
1394
- self, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any
1395
- ) -> List[JSON]:
1396
- """Upserts a subject. Creates or updates subject.
1397
- If the subject doesn't exist, it will be created.
1398
- If the subject exists, it will be partially updated with the provided fields.
1399
-
1400
- :param body: Default value is None.
1401
- :type body: IO
1402
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
1403
- Default value is "application/json".
1404
- :paramtype content_type: str
1405
- :return: list of JSON object
1406
- :rtype: list[JSON]
1407
- :raises ~azure.core.exceptions.HttpResponseError:
1408
-
1409
- Example:
1410
- .. code-block:: python
1411
-
1412
- # response body for status code(s): 200
1413
- response == [
1414
- {
1415
- "id": "str", # Required.
1416
- "key": "str", # Required.
1417
- "currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
1418
- "currentPeriodStart": "2020-02-20 00:00:00", # Optional.
1419
- "displayName": "str", # Optional.
1420
- "metadata": {
1421
- "str": {} # Optional. Dictionary of :code:`<any>`.
1422
- },
1423
- "stripeCustomerId": "str" # Optional.
1424
- }
1425
- ]
1426
- """
1427
-
1428
- @distributed_trace_async
1429
- async def upsert_subject(self, body: Optional[Union[List[JSON], IO]] = None, **kwargs: Any) -> List[JSON]:
1430
- """Upserts a subject. Creates or updates subject.
1431
- If the subject doesn't exist, it will be created.
1432
- If the subject exists, it will be partially updated with the provided fields.
1433
-
1434
- :param body: Is either a [JSON] type or a IO type. Default value is None.
1435
- :type body: list[JSON] or IO
1436
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
1437
- Default value is None.
1438
- :paramtype content_type: str
1439
- :return: list of JSON object
1440
- :rtype: list[JSON]
1441
- :raises ~azure.core.exceptions.HttpResponseError:
1442
-
1443
- Example:
1444
- .. code-block:: python
1445
-
1446
- # response body for status code(s): 200
1447
- response == [
1448
- {
1449
- "id": "str", # Required.
1450
- "key": "str", # Required.
1451
- "currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
1452
- "currentPeriodStart": "2020-02-20 00:00:00", # Optional.
1453
- "displayName": "str", # Optional.
1454
- "metadata": {
1455
- "str": {} # Optional. Dictionary of :code:`<any>`.
1456
- },
1457
- "stripeCustomerId": "str" # Optional.
1458
- }
1459
- ]
1460
- """
1461
- error_map = {
1462
- 401: ClientAuthenticationError,
1463
- 404: ResourceNotFoundError,
1464
- 409: ResourceExistsError,
1465
- 304: ResourceNotModifiedError,
1466
- 400: HttpResponseError,
1467
- }
1468
- error_map.update(kwargs.pop("error_map", {}) or {})
1469
-
1470
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1471
- _params = kwargs.pop("params", {}) or {}
1472
-
1473
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1474
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
1475
-
1476
- content_type = content_type or "application/json"
1477
- _json = None
1478
- _content = None
1479
- if isinstance(body, (IOBase, bytes)):
1480
- _content = body
1481
- else:
1482
- if body is not None:
1483
- _json = body
1484
- else:
1485
- _json = None
1486
-
1487
- _request = build_upsert_subject_request(
1488
- content_type=content_type,
1489
- json=_json,
1490
- content=_content,
1491
- headers=_headers,
1492
- params=_params,
1493
- )
1494
- _request.url = self._client.format_url(_request.url)
1495
-
1496
- _stream = False
1497
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1498
- _request, stream=_stream, **kwargs
1499
- )
1500
-
1501
- response = pipeline_response.http_response
1502
-
1503
- if response.status_code not in [200]:
1504
- if _stream:
1505
- await response.read() # Load the body in memory and close the socket
1506
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1507
- raise HttpResponseError(response=response)
1508
-
1509
- if response.content:
1510
- deserialized = response.json()
1511
- else:
1512
- deserialized = None
1513
-
1514
- if cls:
1515
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
1516
-
1517
- return cast(List[JSON], deserialized) # type: ignore
1518
-
1519
- @distributed_trace_async
1520
- async def get_subject(self, subject_id_or_key: str, **kwargs: Any) -> JSON:
1521
- """get_subject.
1522
-
1523
- :param subject_id_or_key: A unique identifier for a subject. Required.
1524
- :type subject_id_or_key: str
1525
- :return: JSON object
1526
- :rtype: JSON
1527
- :raises ~azure.core.exceptions.HttpResponseError:
1528
-
1529
- Example:
1530
- .. code-block:: python
1531
-
1532
- # response body for status code(s): 200
1533
- response == {
1534
- "id": "str", # Required.
1535
- "key": "str", # Required.
1536
- "currentPeriodEnd": "2020-02-20 00:00:00", # Optional.
1537
- "currentPeriodStart": "2020-02-20 00:00:00", # Optional.
1538
- "displayName": "str", # Optional.
1539
- "metadata": {
1540
- "str": {} # Optional. Dictionary of :code:`<any>`.
1541
- },
1542
- "stripeCustomerId": "str" # Optional.
1543
- }
1544
- """
1545
- error_map = {
1546
- 401: ClientAuthenticationError,
1547
- 404: ResourceNotFoundError,
1548
- 409: ResourceExistsError,
1549
- 304: ResourceNotModifiedError,
1550
- }
1551
- error_map.update(kwargs.pop("error_map", {}) or {})
1552
-
1553
- _headers = kwargs.pop("headers", {}) or {}
1554
- _params = kwargs.pop("params", {}) or {}
1555
-
1556
- cls: ClsType[JSON] = kwargs.pop("cls", None)
1557
-
1558
- _request = build_get_subject_request(
1559
- subject_id_or_key=subject_id_or_key,
1560
- headers=_headers,
1561
- params=_params,
1562
- )
1563
- _request.url = self._client.format_url(_request.url)
1564
-
1565
- _stream = False
1566
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1567
- _request, stream=_stream, **kwargs
1568
- )
1569
-
1570
- response = pipeline_response.http_response
1571
-
1572
- if response.status_code not in [200]:
1573
- if _stream:
1574
- await response.read() # Load the body in memory and close the socket
1575
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1576
- raise HttpResponseError(response=response)
1577
-
1578
- if response.content:
1579
- deserialized = response.json()
1580
- else:
1581
- deserialized = None
1582
-
1583
- if cls:
1584
- return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
1585
-
1586
- return cast(JSON, deserialized) # type: ignore
1587
-
1588
- @distributed_trace_async
1589
- async def delete_subject( # pylint: disable=inconsistent-return-statements
1590
- self, subject_id_or_key: str, **kwargs: Any
1591
- ) -> None:
1592
- """delete_subject.
1593
-
1594
- :param subject_id_or_key: A unique identifier for a subject. Required.
1595
- :type subject_id_or_key: str
1596
- :return: None
1597
- :rtype: None
1598
- :raises ~azure.core.exceptions.HttpResponseError:
1599
- """
1600
- error_map = {
1601
- 401: ClientAuthenticationError,
1602
- 404: ResourceNotFoundError,
1603
- 409: ResourceExistsError,
1604
- 304: ResourceNotModifiedError,
1605
- 400: HttpResponseError,
1606
- }
1607
- error_map.update(kwargs.pop("error_map", {}) or {})
1608
-
1609
- _headers = kwargs.pop("headers", {}) or {}
1610
- _params = kwargs.pop("params", {}) or {}
1611
-
1612
- cls: ClsType[None] = kwargs.pop("cls", None)
1613
-
1614
- _request = build_delete_subject_request(
1615
- subject_id_or_key=subject_id_or_key,
1616
- headers=_headers,
1617
- params=_params,
1618
- )
1619
- _request.url = self._client.format_url(_request.url)
1620
-
1621
- _stream = False
1622
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1623
- _request, stream=_stream, **kwargs
1624
- )
1625
-
1626
- response = pipeline_response.http_response
1627
-
1628
- if response.status_code not in [204]:
1629
- if _stream:
1630
- await response.read() # Load the body in memory and close the socket
1631
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1632
- raise HttpResponseError(response=response)
1633
-
1634
- if cls:
1635
- return cls(pipeline_response, None, {}) # type: ignore
1636
-
1637
- @distributed_trace_async
1638
- async def query_portal_meter(
1639
- self,
1640
- meter_slug: str,
1641
- *,
1642
- from_parameter: Optional[datetime.datetime] = None,
1643
- to: Optional[datetime.datetime] = None,
1644
- window_size: Optional[str] = None,
1645
- window_time_zone: str = "UTC",
1646
- group_by: Optional[List[str]] = None,
1647
- **kwargs: Any
1648
- ) -> Union[JSON, str]:
1649
- """query_portal_meter.
1650
-
1651
- :param meter_slug: Required.
1652
- :type meter_slug: str
1653
- :keyword from_parameter: Start date-time in RFC 3339 format.
1654
- Inclusive. Default value is None.
1655
- :paramtype from_parameter: ~datetime.datetime
1656
- :keyword to: End date-time in RFC 3339 format.
1657
- Inclusive. Default value is None.
1658
- :paramtype to: ~datetime.datetime
1659
- :keyword window_size: If not specified, a single usage aggregate will be returned for the
1660
- entirety of the specified period for each subject and group. Known values are: "MINUTE",
1661
- "HOUR", and "DAY". Default value is None.
1662
- :paramtype window_size: str
1663
- :keyword window_time_zone: The value is the name of the time zone as defined in the IANA Time
1664
- Zone Database (http://www.iana.org/time-zones).
1665
- If not specified, the UTC timezone will be used. Default value is "UTC".
1666
- :paramtype window_time_zone: str
1667
- :keyword group_by: If not specified a single aggregate will be returned for each subject and
1668
- time window.
1669
- ``subject`` is a reserved group by value. Default value is None.
1670
- :paramtype group_by: list[str]
1671
- :return: JSON object or str
1672
- :rtype: JSON or str
1673
- :raises ~azure.core.exceptions.HttpResponseError:
1674
-
1675
- Example:
1676
- .. code-block:: python
1677
-
1678
- # response body for status code(s): 200
1679
- response == {
1680
- "data": [
1681
- {
1682
- "value": 0.0, # Required.
1683
- "windowEnd": "2020-02-20 00:00:00", # Required.
1684
- "windowStart": "2020-02-20 00:00:00", # Required.
1685
- "groupBy": {
1686
- "str": "str" # Optional. Dictionary of
1687
- :code:`<string>`.
1688
- },
1689
- "subject": "str" # Optional. The subject of the meter value.
1690
- }
1691
- ],
1692
- "from": "2020-02-20 00:00:00", # Optional.
1693
- "to": "2020-02-20 00:00:00", # Optional.
1694
- "windowSize": "str" # Optional. Aggregation window size. Known values are:
1695
- "MINUTE", "HOUR", and "DAY".
1696
- }
1697
- # response body for status code(s): 401
1698
- response == {
1699
- "detail": "str", # A human-readable explanation specific to this occurrence
1700
- of the problem. Required.
1701
- "status": 0, # The HTTP status code generated by the origin server for this
1702
- occurrence of the problem. Required.
1703
- "title": "str", # A a short, human-readable summary of the problem type.
1704
- Required.
1705
- "type": "str", # Type contains a URI that identifies the problem type.
1706
- Required.
1707
- "instance": "str" # Optional. A URI reference that identifies the specific
1708
- occurrence of the problem.
1709
- }
1710
- """
1711
- error_map = {
1712
- 401: ClientAuthenticationError,
1713
- 404: ResourceNotFoundError,
1714
- 409: ResourceExistsError,
1715
- 304: ResourceNotModifiedError,
1716
- 400: HttpResponseError,
1717
- }
1718
- error_map.update(kwargs.pop("error_map", {}) or {})
1719
-
1720
- _headers = kwargs.pop("headers", {}) or {}
1721
- _params = kwargs.pop("params", {}) or {}
1722
-
1723
- cls: ClsType[Union[JSON, str]] = kwargs.pop("cls", None)
1724
-
1725
- _request = build_query_portal_meter_request(
1726
- meter_slug=meter_slug,
1727
- from_parameter=from_parameter,
1728
- to=to,
1729
- window_size=window_size,
1730
- window_time_zone=window_time_zone,
1731
- group_by=group_by,
1732
- headers=_headers,
1733
- params=_params,
1734
- )
1735
- _request.url = self._client.format_url(_request.url)
1736
-
1737
- _stream = False
1738
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
1739
- _request, stream=_stream, **kwargs
1740
- )
1741
-
1742
- response = pipeline_response.http_response
1743
-
1744
- if response.status_code not in [200, 200, 401]:
1745
- if _stream:
1746
- await response.read() # Load the body in memory and close the socket
1747
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1748
- raise HttpResponseError(response=response)
1749
-
1750
- if response.status_code == 200:
1751
- if response.content:
1752
- deserialized = response.json()
1753
- else:
1754
- deserialized = None
1755
-
1756
- if response.status_code == 200:
1757
- if response.content:
1758
- deserialized = response.json()
1759
- else:
1760
- deserialized = None
1761
-
1762
- if response.status_code == 401:
1763
- if response.content:
1764
- deserialized = response.json()
1765
- else:
1766
- deserialized = None
1767
-
1768
- if cls:
1769
- return cls(pipeline_response, cast(Union[JSON, str], deserialized), {}) # type: ignore
1770
-
1771
- return cast(Union[JSON, str], deserialized) # type: ignore