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