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