openmeter 1.0.0b121__py3-none-any.whl → 1.0.0b123__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openmeter might be problematic. Click here for more details.
- openmeter/_operations/_operations.py +1516 -138
- openmeter/aio/_operations/_operations.py +1220 -135
- {openmeter-1.0.0b121.dist-info → openmeter-1.0.0b123.dist-info}/METADATA +1 -1
- {openmeter-1.0.0b121.dist-info → openmeter-1.0.0b123.dist-info}/RECORD +5 -5
- {openmeter-1.0.0b121.dist-info → openmeter-1.0.0b123.dist-info}/WHEEL +0 -0
|
@@ -27,10 +27,14 @@ from ..._operations._operations import (
|
|
|
27
27
|
build_create_feature_request,
|
|
28
28
|
build_create_grant_request,
|
|
29
29
|
build_create_meter_request,
|
|
30
|
+
build_create_notification_channel_request,
|
|
31
|
+
build_create_notification_rule_request,
|
|
30
32
|
build_create_portal_token_request,
|
|
31
33
|
build_delete_entitlement_request,
|
|
32
34
|
build_delete_feature_request,
|
|
33
35
|
build_delete_meter_request,
|
|
36
|
+
build_delete_notification_channel_request,
|
|
37
|
+
build_delete_notification_rule_request,
|
|
34
38
|
build_delete_subject_request,
|
|
35
39
|
build_get_debug_metrics_request,
|
|
36
40
|
build_get_entitlement_history_request,
|
|
@@ -38,6 +42,9 @@ from ..._operations._operations import (
|
|
|
38
42
|
build_get_entitlement_value_request,
|
|
39
43
|
build_get_feature_request,
|
|
40
44
|
build_get_meter_request,
|
|
45
|
+
build_get_notification_channel_request,
|
|
46
|
+
build_get_notification_event_request,
|
|
47
|
+
build_get_notification_rule_request,
|
|
41
48
|
build_get_subject_request,
|
|
42
49
|
build_ingest_events_request,
|
|
43
50
|
build_invalidate_portal_tokens_request,
|
|
@@ -48,12 +55,17 @@ from ..._operations._operations import (
|
|
|
48
55
|
build_list_grants_request,
|
|
49
56
|
build_list_meter_subjects_request,
|
|
50
57
|
build_list_meters_request,
|
|
58
|
+
build_list_notification_channels_request,
|
|
59
|
+
build_list_notification_events_request,
|
|
60
|
+
build_list_notification_rules_request,
|
|
51
61
|
build_list_portal_tokens_request,
|
|
52
62
|
build_list_subject_entitlements_request,
|
|
53
63
|
build_list_subjects_request,
|
|
54
64
|
build_query_meter_request,
|
|
55
65
|
build_query_portal_meter_request,
|
|
56
66
|
build_reset_entitlement_usage_request,
|
|
67
|
+
build_update_notification_channel_request,
|
|
68
|
+
build_update_notification_rule_request,
|
|
57
69
|
build_upsert_subject_request,
|
|
58
70
|
build_void_grant_request,
|
|
59
71
|
)
|
|
@@ -844,7 +856,7 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
844
856
|
:paramtype window_time_zone: str
|
|
845
857
|
:keyword subject: Filtering by multiple subjects.
|
|
846
858
|
|
|
847
|
-
Usage:
|
|
859
|
+
Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
|
|
848
860
|
:paramtype subject: list[str]
|
|
849
861
|
:keyword filter_group_by: Default value is None.
|
|
850
862
|
:paramtype filter_group_by: dict[str, str]
|
|
@@ -1892,13 +1904,25 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1892
1904
|
|
|
1893
1905
|
@distributed_trace_async
|
|
1894
1906
|
async def list_entitlements(
|
|
1895
|
-
self,
|
|
1896
|
-
|
|
1907
|
+
self,
|
|
1908
|
+
*,
|
|
1909
|
+
page: int = 1,
|
|
1910
|
+
page_size: int = 100,
|
|
1911
|
+
limit: int = 1000,
|
|
1912
|
+
offset: int = 0,
|
|
1913
|
+
order_by: str = "createdAt",
|
|
1914
|
+
**kwargs: Any
|
|
1915
|
+
) -> Any:
|
|
1897
1916
|
"""List entitlements.
|
|
1898
1917
|
|
|
1899
1918
|
List all entitlements regardless of subject. This endpoint is intended for administrative
|
|
1900
1919
|
purposes.
|
|
1920
|
+
If page is provided that takes precedence and the paginated response is returned.
|
|
1901
1921
|
|
|
1922
|
+
:keyword page: Page number to return. Default value is 1.
|
|
1923
|
+
:paramtype page: int
|
|
1924
|
+
:keyword page_size: Number of entries to return per page. Default value is 100.
|
|
1925
|
+
:paramtype page_size: int
|
|
1902
1926
|
:keyword limit: Number of entries to return. Default value is 1000.
|
|
1903
1927
|
:paramtype limit: int
|
|
1904
1928
|
:keyword offset: Number of entries to skip. Default value is 0.
|
|
@@ -1906,17 +1930,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1906
1930
|
:keyword order_by: Order by field. Known values are: "createdAt" and "updatedAt". Default value
|
|
1907
1931
|
is "createdAt".
|
|
1908
1932
|
:paramtype order_by: str
|
|
1909
|
-
:return:
|
|
1910
|
-
:rtype:
|
|
1933
|
+
:return: any
|
|
1934
|
+
:rtype: any
|
|
1911
1935
|
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1912
|
-
|
|
1913
|
-
Example:
|
|
1914
|
-
.. code-block:: python
|
|
1915
|
-
|
|
1916
|
-
# response body for status code(s): 200
|
|
1917
|
-
response == [
|
|
1918
|
-
{}
|
|
1919
|
-
]
|
|
1920
1936
|
"""
|
|
1921
1937
|
error_map = {
|
|
1922
1938
|
404: ResourceNotFoundError,
|
|
@@ -1930,9 +1946,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1930
1946
|
_headers = kwargs.pop("headers", {}) or {}
|
|
1931
1947
|
_params = kwargs.pop("params", {}) or {}
|
|
1932
1948
|
|
|
1933
|
-
cls: ClsType[
|
|
1949
|
+
cls: ClsType[Any] = kwargs.pop("cls", None)
|
|
1934
1950
|
|
|
1935
1951
|
_request = build_list_entitlements_request(
|
|
1952
|
+
page=page,
|
|
1953
|
+
page_size=page_size,
|
|
1936
1954
|
limit=limit,
|
|
1937
1955
|
offset=offset,
|
|
1938
1956
|
order_by=order_by,
|
|
@@ -1960,25 +1978,31 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1960
1978
|
deserialized = None
|
|
1961
1979
|
|
|
1962
1980
|
if cls:
|
|
1963
|
-
return cls(pipeline_response, cast(
|
|
1981
|
+
return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
|
|
1964
1982
|
|
|
1965
|
-
return cast(
|
|
1983
|
+
return cast(Any, deserialized) # type: ignore
|
|
1966
1984
|
|
|
1967
1985
|
@distributed_trace_async
|
|
1968
1986
|
async def list_features(
|
|
1969
1987
|
self,
|
|
1970
1988
|
*,
|
|
1989
|
+
page: int = 1,
|
|
1990
|
+
page_size: int = 100,
|
|
1971
1991
|
limit: int = 1000,
|
|
1972
1992
|
offset: int = 0,
|
|
1973
1993
|
order_by: str = "updatedAt",
|
|
1974
1994
|
include_archived: bool = False,
|
|
1975
1995
|
**kwargs: Any
|
|
1976
|
-
) ->
|
|
1977
|
-
# pylint: disable=line-too-long
|
|
1996
|
+
) -> Any:
|
|
1978
1997
|
"""List features.
|
|
1979
1998
|
|
|
1980
|
-
List all features.
|
|
1999
|
+
List all features. If page is provided that takes precedence and the paginated response is
|
|
2000
|
+
returned.
|
|
1981
2001
|
|
|
2002
|
+
:keyword page: Page number to return. Default value is 1.
|
|
2003
|
+
:paramtype page: int
|
|
2004
|
+
:keyword page_size: Number of entries to return per page. Default value is 100.
|
|
2005
|
+
:paramtype page_size: int
|
|
1982
2006
|
:keyword limit: Number of entries to return. Default value is 1000.
|
|
1983
2007
|
:paramtype limit: int
|
|
1984
2008
|
:keyword offset: Number of entries to skip. Default value is 0.
|
|
@@ -1988,47 +2012,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
1988
2012
|
:paramtype order_by: str
|
|
1989
2013
|
:keyword include_archived: Include archived features. Default value is False.
|
|
1990
2014
|
:paramtype include_archived: bool
|
|
1991
|
-
:return:
|
|
1992
|
-
:rtype:
|
|
2015
|
+
:return: any
|
|
2016
|
+
:rtype: any
|
|
1993
2017
|
:raises ~azure.core.exceptions.HttpResponseError:
|
|
1994
|
-
|
|
1995
|
-
Example:
|
|
1996
|
-
.. code-block:: python
|
|
1997
|
-
|
|
1998
|
-
# response body for status code(s): 200
|
|
1999
|
-
response == [
|
|
2000
|
-
{
|
|
2001
|
-
"createdAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
2002
|
-
was created. Required.
|
|
2003
|
-
"id": "str", # Readonly unique ULID identifier. Required.
|
|
2004
|
-
"key": "str", # The key is an immutable unique identifier of the
|
|
2005
|
-
feature used throughout the API, for example when interacting with a
|
|
2006
|
-
subject's entitlements. The key has to be unique across all active features,
|
|
2007
|
-
but archived features can share the same key. The key should consist of
|
|
2008
|
-
lowercase alphanumeric characters and dashes. Required.
|
|
2009
|
-
"name": "str", # The name of the feature. Required.
|
|
2010
|
-
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
2011
|
-
was last updated. The initial value is the same as createdAt. Required.
|
|
2012
|
-
"archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is
|
|
2013
|
-
archived, no new entitlements can be created for it.
|
|
2014
|
-
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
|
|
2015
|
-
the resource was deleted.
|
|
2016
|
-
"metadata": {
|
|
2017
|
-
"str": "str" # Optional. Additional metadata for the
|
|
2018
|
-
feature, useful for syncing with external systems and annotating custom
|
|
2019
|
-
fields.
|
|
2020
|
-
},
|
|
2021
|
-
"meterGroupByFilters": {
|
|
2022
|
-
"str": "str" # Optional. Optional meter group by filters.
|
|
2023
|
-
Useful if the meter scope is broader than what feature tracks. Example
|
|
2024
|
-
scenario would be a meter tracking all token use with groupBy fields for
|
|
2025
|
-
the model, then the feature could filter for model=gpt-4.
|
|
2026
|
-
},
|
|
2027
|
-
"meterSlug": "str" # Optional. The meter that the feature is
|
|
2028
|
-
associated with and and based on which usage is calculated. The meter
|
|
2029
|
-
selected must have SUM or COUNT aggregation.
|
|
2030
|
-
}
|
|
2031
|
-
]
|
|
2032
2018
|
"""
|
|
2033
2019
|
error_map = {
|
|
2034
2020
|
404: ResourceNotFoundError,
|
|
@@ -2042,9 +2028,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2042
2028
|
_headers = kwargs.pop("headers", {}) or {}
|
|
2043
2029
|
_params = kwargs.pop("params", {}) or {}
|
|
2044
2030
|
|
|
2045
|
-
cls: ClsType[
|
|
2031
|
+
cls: ClsType[Any] = kwargs.pop("cls", None)
|
|
2046
2032
|
|
|
2047
2033
|
_request = build_list_features_request(
|
|
2034
|
+
page=page,
|
|
2035
|
+
page_size=page_size,
|
|
2048
2036
|
limit=limit,
|
|
2049
2037
|
offset=offset,
|
|
2050
2038
|
order_by=order_by,
|
|
@@ -2073,9 +2061,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2073
2061
|
deserialized = None
|
|
2074
2062
|
|
|
2075
2063
|
if cls:
|
|
2076
|
-
return cls(pipeline_response, cast(
|
|
2064
|
+
return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
|
|
2077
2065
|
|
|
2078
|
-
return cast(
|
|
2066
|
+
return cast(Any, deserialized) # type: ignore
|
|
2079
2067
|
|
|
2080
2068
|
@overload
|
|
2081
2069
|
async def create_feature(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
|
|
@@ -2497,97 +2485,43 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2497
2485
|
async def list_grants(
|
|
2498
2486
|
self,
|
|
2499
2487
|
*,
|
|
2488
|
+
page: int = 1,
|
|
2489
|
+
page_size: int = 100,
|
|
2500
2490
|
limit: int = 1000,
|
|
2501
2491
|
offset: int = 0,
|
|
2492
|
+
order: str = "ASC",
|
|
2502
2493
|
order_by: str = "updatedAt",
|
|
2503
2494
|
include_deleted: bool = False,
|
|
2504
2495
|
**kwargs: Any
|
|
2505
|
-
) ->
|
|
2506
|
-
# pylint: disable=line-too-long
|
|
2496
|
+
) -> Any:
|
|
2507
2497
|
"""List grants.
|
|
2508
2498
|
|
|
2509
2499
|
List all grants for all the subjects and entitlements. This endpoint is intended for
|
|
2510
2500
|
administrative purposes only. To fetch the grants of a specific entitlement please use the
|
|
2511
2501
|
/api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
|
|
2512
2502
|
|
|
2503
|
+
If page is provided that takes precedence and the paginated response is returned.
|
|
2504
|
+
|
|
2505
|
+
:keyword page: Page number to return. Default value is 1.
|
|
2506
|
+
:paramtype page: int
|
|
2507
|
+
:keyword page_size: Number of entries to return per page. Default value is 100.
|
|
2508
|
+
:paramtype page_size: int
|
|
2513
2509
|
:keyword limit: Number of entries to return. Default value is 1000.
|
|
2514
2510
|
:paramtype limit: int
|
|
2515
2511
|
:keyword offset: Number of entries to skip. Default value is 0.
|
|
2516
2512
|
:paramtype offset: int
|
|
2513
|
+
:keyword order: Order by field.
|
|
2514
|
+
|
|
2515
|
+
Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
|
|
2516
|
+
:paramtype order: str
|
|
2517
2517
|
:keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
|
|
2518
2518
|
Default value is "updatedAt".
|
|
2519
2519
|
:paramtype order_by: str
|
|
2520
2520
|
:keyword include_deleted: Include deleted entries. Default value is False.
|
|
2521
2521
|
:paramtype include_deleted: bool
|
|
2522
|
-
:return:
|
|
2523
|
-
:rtype:
|
|
2522
|
+
:return: any
|
|
2523
|
+
:rtype: any
|
|
2524
2524
|
:raises ~azure.core.exceptions.HttpResponseError:
|
|
2525
|
-
|
|
2526
|
-
Example:
|
|
2527
|
-
.. code-block:: python
|
|
2528
|
-
|
|
2529
|
-
# response body for status code(s): 200
|
|
2530
|
-
response == [
|
|
2531
|
-
{
|
|
2532
|
-
"amount": 0.0, # The amount to grant. Should be a positive number.
|
|
2533
|
-
Required.
|
|
2534
|
-
"createdAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
2535
|
-
was created. Required.
|
|
2536
|
-
"effectiveAt": "2020-02-20 00:00:00", # Effective date for grants
|
|
2537
|
-
and anchor for recurring grants. Provided value will be ceiled to metering
|
|
2538
|
-
windowSize (minute). Required.
|
|
2539
|
-
"entitlementId": "str", # The unique entitlement ULID that the grant
|
|
2540
|
-
is associated with. Required.
|
|
2541
|
-
"expiration": {
|
|
2542
|
-
"count": 0, # The expiration period count like 12 months.
|
|
2543
|
-
Required.
|
|
2544
|
-
"duration": "str" # The expiration period duration like
|
|
2545
|
-
month. Required. Known values are: "HOUR", "DAY", "WEEK", "MONTH", and
|
|
2546
|
-
"YEAR".
|
|
2547
|
-
},
|
|
2548
|
-
"id": "str", # Readonly unique ULID identifier. Required.
|
|
2549
|
-
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
2550
|
-
was last updated. The initial value is the same as createdAt. Required.
|
|
2551
|
-
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
|
|
2552
|
-
the resource was deleted.
|
|
2553
|
-
"expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date
|
|
2554
|
-
of the grant.
|
|
2555
|
-
"maxRolloverAmount": 0, # Optional. Default value is 0. Grants are
|
|
2556
|
-
rolled over at reset, after which they can have a different balance compared
|
|
2557
|
-
to what they had before the reset. Balance after the reset is calculated as:
|
|
2558
|
-
Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
|
|
2559
|
-
MinRolloverAmount)).
|
|
2560
|
-
"metadata": {
|
|
2561
|
-
"str": "str" # Optional. Dictionary of :code:`<string>`.
|
|
2562
|
-
},
|
|
2563
|
-
"minRolloverAmount": 0, # Optional. Default value is 0. Grants are
|
|
2564
|
-
rolled over at reset, after which they can have a different balance compared
|
|
2565
|
-
to what they had before the reset. Balance after the reset is calculated as:
|
|
2566
|
-
Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
|
|
2567
|
-
MinRolloverAmount)).
|
|
2568
|
-
"nextRecurrence": "2020-02-20 00:00:00", # Optional. The next time
|
|
2569
|
-
the grant will recurr.
|
|
2570
|
-
"priority": 1, # Optional. Default value is 1. The priority of the
|
|
2571
|
-
grant. Grants with higher priority are applied first. Priority is a positive
|
|
2572
|
-
decimal numbers. With lower numbers indicating higher importance. For
|
|
2573
|
-
example, a priority of 1 is more urgent than a priority of 2. When there are
|
|
2574
|
-
several grants available for the same subject, the system selects the grant
|
|
2575
|
-
with the highest priority. In cases where grants share the same priority
|
|
2576
|
-
level, the grant closest to its expiration will be used first. In the case of
|
|
2577
|
-
two grants have identical priorities and expiration dates, the system will
|
|
2578
|
-
use the grant that was created first.
|
|
2579
|
-
"recurrence": {
|
|
2580
|
-
"anchor": "2020-02-20 00:00:00", # An arbitrary anchor to
|
|
2581
|
-
base the recurring period on. Required.
|
|
2582
|
-
"interval": "str" # List of pre-defined periods that can be
|
|
2583
|
-
used for recurring & scheduling. DAY: Every day WEEK: Every
|
|
2584
|
-
week MONTH: Every month YEAR: Every year. Required. Known values
|
|
2585
|
-
are: "DAY", "WEEK", "MONTH", and "YEAR".
|
|
2586
|
-
},
|
|
2587
|
-
"voidedAt": "2020-02-20 00:00:00" # Optional. The date and time the
|
|
2588
|
-
grant was voided (cannot be used after that).
|
|
2589
|
-
}
|
|
2590
|
-
]
|
|
2591
2525
|
"""
|
|
2592
2526
|
error_map = {
|
|
2593
2527
|
404: ResourceNotFoundError,
|
|
@@ -2600,11 +2534,14 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2600
2534
|
_headers = kwargs.pop("headers", {}) or {}
|
|
2601
2535
|
_params = kwargs.pop("params", {}) or {}
|
|
2602
2536
|
|
|
2603
|
-
cls: ClsType[
|
|
2537
|
+
cls: ClsType[Any] = kwargs.pop("cls", None)
|
|
2604
2538
|
|
|
2605
2539
|
_request = build_list_grants_request(
|
|
2540
|
+
page=page,
|
|
2541
|
+
page_size=page_size,
|
|
2606
2542
|
limit=limit,
|
|
2607
2543
|
offset=offset,
|
|
2544
|
+
order=order,
|
|
2608
2545
|
order_by=order_by,
|
|
2609
2546
|
include_deleted=include_deleted,
|
|
2610
2547
|
headers=_headers,
|
|
@@ -2631,9 +2568,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2631
2568
|
deserialized = None
|
|
2632
2569
|
|
|
2633
2570
|
if cls:
|
|
2634
|
-
return cls(pipeline_response, cast(
|
|
2571
|
+
return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
|
|
2635
2572
|
|
|
2636
|
-
return cast(
|
|
2573
|
+
return cast(Any, deserialized) # type: ignore
|
|
2637
2574
|
|
|
2638
2575
|
@distributed_trace_async
|
|
2639
2576
|
async def void_grant(self, grant_id: str, **kwargs: Any) -> Optional[JSON]:
|
|
@@ -4245,3 +4182,1151 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4245
4182
|
return cls(pipeline_response, cast(str, deserialized), {}) # type: ignore
|
|
4246
4183
|
|
|
4247
4184
|
return cast(str, deserialized) # type: ignore
|
|
4185
|
+
|
|
4186
|
+
@distributed_trace_async
|
|
4187
|
+
async def list_notification_channels(
|
|
4188
|
+
self, *, limit: int = 1000, offset: int = 0, order_by: str = "id", include_disabled: bool = False, **kwargs: Any
|
|
4189
|
+
) -> List[JSON]:
|
|
4190
|
+
"""List notification channels.
|
|
4191
|
+
|
|
4192
|
+
List all notification channels.
|
|
4193
|
+
|
|
4194
|
+
:keyword limit: Number of entries to return. Default value is 1000.
|
|
4195
|
+
:paramtype limit: int
|
|
4196
|
+
:keyword offset: Number of entries to skip. Default value is 0.
|
|
4197
|
+
:paramtype offset: int
|
|
4198
|
+
:keyword order_by: Order by field. Known values are: "id", "type", "createdAt", and
|
|
4199
|
+
"updatedAt". Default value is "id".
|
|
4200
|
+
:paramtype order_by: str
|
|
4201
|
+
:keyword include_disabled: Include disabled entries. Default value is False.
|
|
4202
|
+
:paramtype include_disabled: bool
|
|
4203
|
+
:return: list of JSON object
|
|
4204
|
+
:rtype: list[JSON]
|
|
4205
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4206
|
+
|
|
4207
|
+
Example:
|
|
4208
|
+
.. code-block:: python
|
|
4209
|
+
|
|
4210
|
+
# response body for status code(s): 200
|
|
4211
|
+
response == [
|
|
4212
|
+
{}
|
|
4213
|
+
]
|
|
4214
|
+
"""
|
|
4215
|
+
error_map = {
|
|
4216
|
+
404: ResourceNotFoundError,
|
|
4217
|
+
409: ResourceExistsError,
|
|
4218
|
+
304: ResourceNotModifiedError,
|
|
4219
|
+
400: HttpResponseError,
|
|
4220
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4221
|
+
}
|
|
4222
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4223
|
+
|
|
4224
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
4225
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4226
|
+
|
|
4227
|
+
cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
|
|
4228
|
+
|
|
4229
|
+
_request = build_list_notification_channels_request(
|
|
4230
|
+
limit=limit,
|
|
4231
|
+
offset=offset,
|
|
4232
|
+
order_by=order_by,
|
|
4233
|
+
include_disabled=include_disabled,
|
|
4234
|
+
headers=_headers,
|
|
4235
|
+
params=_params,
|
|
4236
|
+
)
|
|
4237
|
+
_request.url = self._client.format_url(_request.url)
|
|
4238
|
+
|
|
4239
|
+
_stream = False
|
|
4240
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4241
|
+
_request, stream=_stream, **kwargs
|
|
4242
|
+
)
|
|
4243
|
+
|
|
4244
|
+
response = pipeline_response.http_response
|
|
4245
|
+
|
|
4246
|
+
if response.status_code not in [200]:
|
|
4247
|
+
if _stream:
|
|
4248
|
+
await response.read() # Load the body in memory and close the socket
|
|
4249
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4250
|
+
raise HttpResponseError(response=response)
|
|
4251
|
+
|
|
4252
|
+
if response.content:
|
|
4253
|
+
deserialized = response.json()
|
|
4254
|
+
else:
|
|
4255
|
+
deserialized = None
|
|
4256
|
+
|
|
4257
|
+
if cls:
|
|
4258
|
+
return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
|
|
4259
|
+
|
|
4260
|
+
return cast(List[JSON], deserialized) # type: ignore
|
|
4261
|
+
|
|
4262
|
+
@overload
|
|
4263
|
+
async def create_notification_channel(
|
|
4264
|
+
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
4265
|
+
) -> JSON:
|
|
4266
|
+
"""Create a notification channel.
|
|
4267
|
+
|
|
4268
|
+
Create a new notification channel.
|
|
4269
|
+
|
|
4270
|
+
:param body: The notification channel to create. Required.
|
|
4271
|
+
:type body: JSON
|
|
4272
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4273
|
+
Default value is "application/json".
|
|
4274
|
+
:paramtype content_type: str
|
|
4275
|
+
:return: JSON object
|
|
4276
|
+
:rtype: JSON
|
|
4277
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4278
|
+
|
|
4279
|
+
Example:
|
|
4280
|
+
.. code-block:: python
|
|
4281
|
+
|
|
4282
|
+
# JSON input template you can fill out and use as your body input.
|
|
4283
|
+
body = {}
|
|
4284
|
+
|
|
4285
|
+
# response body for status code(s): 409
|
|
4286
|
+
response == {
|
|
4287
|
+
"detail": "str", # A human-readable explanation specific to this occurrence
|
|
4288
|
+
of the problem. Required.
|
|
4289
|
+
"status": 0, # The HTTP status code generated by the origin server for this
|
|
4290
|
+
occurrence of the problem. Required.
|
|
4291
|
+
"title": "str", # A a short, human-readable summary of the problem type.
|
|
4292
|
+
Required.
|
|
4293
|
+
"type": "str", # Type contains a URI that identifies the problem type.
|
|
4294
|
+
Required.
|
|
4295
|
+
"extensions": {
|
|
4296
|
+
"conflictingEntityId": "str" # The id of the conflicting entity.
|
|
4297
|
+
Required.
|
|
4298
|
+
},
|
|
4299
|
+
"instance": "str" # Optional. A URI reference that identifies the specific
|
|
4300
|
+
occurrence of the problem.
|
|
4301
|
+
}
|
|
4302
|
+
"""
|
|
4303
|
+
|
|
4304
|
+
@overload
|
|
4305
|
+
async def create_notification_channel(
|
|
4306
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
4307
|
+
) -> JSON:
|
|
4308
|
+
"""Create a notification channel.
|
|
4309
|
+
|
|
4310
|
+
Create a new notification channel.
|
|
4311
|
+
|
|
4312
|
+
:param body: The notification channel to create. Required.
|
|
4313
|
+
:type body: IO[bytes]
|
|
4314
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
4315
|
+
Default value is "application/json".
|
|
4316
|
+
:paramtype content_type: str
|
|
4317
|
+
:return: JSON object
|
|
4318
|
+
:rtype: JSON
|
|
4319
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4320
|
+
|
|
4321
|
+
Example:
|
|
4322
|
+
.. code-block:: python
|
|
4323
|
+
|
|
4324
|
+
# response body for status code(s): 409
|
|
4325
|
+
response == {
|
|
4326
|
+
"detail": "str", # A human-readable explanation specific to this occurrence
|
|
4327
|
+
of the problem. Required.
|
|
4328
|
+
"status": 0, # The HTTP status code generated by the origin server for this
|
|
4329
|
+
occurrence of the problem. Required.
|
|
4330
|
+
"title": "str", # A a short, human-readable summary of the problem type.
|
|
4331
|
+
Required.
|
|
4332
|
+
"type": "str", # Type contains a URI that identifies the problem type.
|
|
4333
|
+
Required.
|
|
4334
|
+
"extensions": {
|
|
4335
|
+
"conflictingEntityId": "str" # The id of the conflicting entity.
|
|
4336
|
+
Required.
|
|
4337
|
+
},
|
|
4338
|
+
"instance": "str" # Optional. A URI reference that identifies the specific
|
|
4339
|
+
occurrence of the problem.
|
|
4340
|
+
}
|
|
4341
|
+
"""
|
|
4342
|
+
|
|
4343
|
+
@distributed_trace_async
|
|
4344
|
+
async def create_notification_channel(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
4345
|
+
"""Create a notification channel.
|
|
4346
|
+
|
|
4347
|
+
Create a new notification channel.
|
|
4348
|
+
|
|
4349
|
+
:param body: The notification channel to create. Is either a JSON type or a IO[bytes] type.
|
|
4350
|
+
Required.
|
|
4351
|
+
:type body: JSON or IO[bytes]
|
|
4352
|
+
:return: JSON object
|
|
4353
|
+
:rtype: JSON
|
|
4354
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4355
|
+
|
|
4356
|
+
Example:
|
|
4357
|
+
.. code-block:: python
|
|
4358
|
+
|
|
4359
|
+
# JSON input template you can fill out and use as your body input.
|
|
4360
|
+
body = {}
|
|
4361
|
+
|
|
4362
|
+
# response body for status code(s): 409
|
|
4363
|
+
response == {
|
|
4364
|
+
"detail": "str", # A human-readable explanation specific to this occurrence
|
|
4365
|
+
of the problem. Required.
|
|
4366
|
+
"status": 0, # The HTTP status code generated by the origin server for this
|
|
4367
|
+
occurrence of the problem. Required.
|
|
4368
|
+
"title": "str", # A a short, human-readable summary of the problem type.
|
|
4369
|
+
Required.
|
|
4370
|
+
"type": "str", # Type contains a URI that identifies the problem type.
|
|
4371
|
+
Required.
|
|
4372
|
+
"extensions": {
|
|
4373
|
+
"conflictingEntityId": "str" # The id of the conflicting entity.
|
|
4374
|
+
Required.
|
|
4375
|
+
},
|
|
4376
|
+
"instance": "str" # Optional. A URI reference that identifies the specific
|
|
4377
|
+
occurrence of the problem.
|
|
4378
|
+
}
|
|
4379
|
+
"""
|
|
4380
|
+
error_map = {
|
|
4381
|
+
404: ResourceNotFoundError,
|
|
4382
|
+
409: ResourceExistsError,
|
|
4383
|
+
304: ResourceNotModifiedError,
|
|
4384
|
+
400: HttpResponseError,
|
|
4385
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4386
|
+
}
|
|
4387
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4388
|
+
|
|
4389
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
4390
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4391
|
+
|
|
4392
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
4393
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
4394
|
+
|
|
4395
|
+
content_type = content_type or "application/json"
|
|
4396
|
+
_json = None
|
|
4397
|
+
_content = None
|
|
4398
|
+
if isinstance(body, (IOBase, bytes)):
|
|
4399
|
+
_content = body
|
|
4400
|
+
else:
|
|
4401
|
+
_json = body
|
|
4402
|
+
|
|
4403
|
+
_request = build_create_notification_channel_request(
|
|
4404
|
+
content_type=content_type,
|
|
4405
|
+
json=_json,
|
|
4406
|
+
content=_content,
|
|
4407
|
+
headers=_headers,
|
|
4408
|
+
params=_params,
|
|
4409
|
+
)
|
|
4410
|
+
_request.url = self._client.format_url(_request.url)
|
|
4411
|
+
|
|
4412
|
+
_stream = False
|
|
4413
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4414
|
+
_request, stream=_stream, **kwargs
|
|
4415
|
+
)
|
|
4416
|
+
|
|
4417
|
+
response = pipeline_response.http_response
|
|
4418
|
+
|
|
4419
|
+
if response.status_code not in [201, 409]:
|
|
4420
|
+
if _stream:
|
|
4421
|
+
await response.read() # Load the body in memory and close the socket
|
|
4422
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4423
|
+
raise HttpResponseError(response=response)
|
|
4424
|
+
|
|
4425
|
+
if response.status_code == 201:
|
|
4426
|
+
if response.content:
|
|
4427
|
+
deserialized = response.json()
|
|
4428
|
+
else:
|
|
4429
|
+
deserialized = None
|
|
4430
|
+
|
|
4431
|
+
if response.status_code == 409:
|
|
4432
|
+
if response.content:
|
|
4433
|
+
deserialized = response.json()
|
|
4434
|
+
else:
|
|
4435
|
+
deserialized = None
|
|
4436
|
+
|
|
4437
|
+
if cls:
|
|
4438
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
4439
|
+
|
|
4440
|
+
return cast(JSON, deserialized) # type: ignore
|
|
4441
|
+
|
|
4442
|
+
@distributed_trace_async
|
|
4443
|
+
async def get_notification_channel(self, channel_id: str, **kwargs: Any) -> JSON:
|
|
4444
|
+
"""Get notification channel.
|
|
4445
|
+
|
|
4446
|
+
Get a notification channel by id.
|
|
4447
|
+
|
|
4448
|
+
:param channel_id: A unique ULID identifier for a notification channel. Required.
|
|
4449
|
+
:type channel_id: str
|
|
4450
|
+
:return: JSON object
|
|
4451
|
+
:rtype: JSON
|
|
4452
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4453
|
+
"""
|
|
4454
|
+
error_map = {
|
|
4455
|
+
409: ResourceExistsError,
|
|
4456
|
+
304: ResourceNotModifiedError,
|
|
4457
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4458
|
+
404: lambda response: ResourceNotFoundError(response=response),
|
|
4459
|
+
}
|
|
4460
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4461
|
+
|
|
4462
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
4463
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4464
|
+
|
|
4465
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
4466
|
+
|
|
4467
|
+
_request = build_get_notification_channel_request(
|
|
4468
|
+
channel_id=channel_id,
|
|
4469
|
+
headers=_headers,
|
|
4470
|
+
params=_params,
|
|
4471
|
+
)
|
|
4472
|
+
_request.url = self._client.format_url(_request.url)
|
|
4473
|
+
|
|
4474
|
+
_stream = False
|
|
4475
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4476
|
+
_request, stream=_stream, **kwargs
|
|
4477
|
+
)
|
|
4478
|
+
|
|
4479
|
+
response = pipeline_response.http_response
|
|
4480
|
+
|
|
4481
|
+
if response.status_code not in [200]:
|
|
4482
|
+
if _stream:
|
|
4483
|
+
await response.read() # Load the body in memory and close the socket
|
|
4484
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4485
|
+
raise HttpResponseError(response=response)
|
|
4486
|
+
|
|
4487
|
+
if response.content:
|
|
4488
|
+
deserialized = response.json()
|
|
4489
|
+
else:
|
|
4490
|
+
deserialized = None
|
|
4491
|
+
|
|
4492
|
+
if cls:
|
|
4493
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
4494
|
+
|
|
4495
|
+
return cast(JSON, deserialized) # type: ignore
|
|
4496
|
+
|
|
4497
|
+
@distributed_trace_async
|
|
4498
|
+
async def delete_notification_channel( # pylint: disable=inconsistent-return-statements
|
|
4499
|
+
self, channel_id: str, **kwargs: Any
|
|
4500
|
+
) -> None:
|
|
4501
|
+
"""Delete a notification channel.
|
|
4502
|
+
|
|
4503
|
+
Delete notification channel by id.
|
|
4504
|
+
|
|
4505
|
+
:param channel_id: A unique ULID identifier for a notification channel. Required.
|
|
4506
|
+
:type channel_id: str
|
|
4507
|
+
:return: None
|
|
4508
|
+
:rtype: None
|
|
4509
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4510
|
+
"""
|
|
4511
|
+
error_map = {
|
|
4512
|
+
409: ResourceExistsError,
|
|
4513
|
+
304: ResourceNotModifiedError,
|
|
4514
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4515
|
+
404: lambda response: ResourceNotFoundError(response=response),
|
|
4516
|
+
}
|
|
4517
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4518
|
+
|
|
4519
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
4520
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4521
|
+
|
|
4522
|
+
cls: ClsType[None] = kwargs.pop("cls", None)
|
|
4523
|
+
|
|
4524
|
+
_request = build_delete_notification_channel_request(
|
|
4525
|
+
channel_id=channel_id,
|
|
4526
|
+
headers=_headers,
|
|
4527
|
+
params=_params,
|
|
4528
|
+
)
|
|
4529
|
+
_request.url = self._client.format_url(_request.url)
|
|
4530
|
+
|
|
4531
|
+
_stream = False
|
|
4532
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4533
|
+
_request, stream=_stream, **kwargs
|
|
4534
|
+
)
|
|
4535
|
+
|
|
4536
|
+
response = pipeline_response.http_response
|
|
4537
|
+
|
|
4538
|
+
if response.status_code not in [204]:
|
|
4539
|
+
if _stream:
|
|
4540
|
+
await response.read() # Load the body in memory and close the socket
|
|
4541
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4542
|
+
raise HttpResponseError(response=response)
|
|
4543
|
+
|
|
4544
|
+
if cls:
|
|
4545
|
+
return cls(pipeline_response, None, {}) # type: ignore
|
|
4546
|
+
|
|
4547
|
+
@overload
|
|
4548
|
+
async def update_notification_channel(
|
|
4549
|
+
self, channel_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
4550
|
+
) -> JSON:
|
|
4551
|
+
"""Update notification channel.
|
|
4552
|
+
|
|
4553
|
+
Update a notification channel by id.
|
|
4554
|
+
|
|
4555
|
+
:param channel_id: A unique ULID identifier for a notification channel. Required.
|
|
4556
|
+
:type channel_id: str
|
|
4557
|
+
:param body: The notification channel to update. Required.
|
|
4558
|
+
:type body: JSON
|
|
4559
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4560
|
+
Default value is "application/json".
|
|
4561
|
+
:paramtype content_type: str
|
|
4562
|
+
:return: JSON object
|
|
4563
|
+
:rtype: JSON
|
|
4564
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4565
|
+
|
|
4566
|
+
Example:
|
|
4567
|
+
.. code-block:: python
|
|
4568
|
+
|
|
4569
|
+
# JSON input template you can fill out and use as your body input.
|
|
4570
|
+
body = {}
|
|
4571
|
+
"""
|
|
4572
|
+
|
|
4573
|
+
@overload
|
|
4574
|
+
async def update_notification_channel(
|
|
4575
|
+
self, channel_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
4576
|
+
) -> JSON:
|
|
4577
|
+
"""Update notification channel.
|
|
4578
|
+
|
|
4579
|
+
Update a notification channel by id.
|
|
4580
|
+
|
|
4581
|
+
:param channel_id: A unique ULID identifier for a notification channel. Required.
|
|
4582
|
+
:type channel_id: str
|
|
4583
|
+
:param body: The notification channel to update. Required.
|
|
4584
|
+
:type body: IO[bytes]
|
|
4585
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
4586
|
+
Default value is "application/json".
|
|
4587
|
+
:paramtype content_type: str
|
|
4588
|
+
:return: JSON object
|
|
4589
|
+
:rtype: JSON
|
|
4590
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4591
|
+
"""
|
|
4592
|
+
|
|
4593
|
+
@distributed_trace_async
|
|
4594
|
+
async def update_notification_channel(self, channel_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
4595
|
+
"""Update notification channel.
|
|
4596
|
+
|
|
4597
|
+
Update a notification channel by id.
|
|
4598
|
+
|
|
4599
|
+
:param channel_id: A unique ULID identifier for a notification channel. Required.
|
|
4600
|
+
:type channel_id: str
|
|
4601
|
+
:param body: The notification channel to update. Is either a JSON type or a IO[bytes] type.
|
|
4602
|
+
Required.
|
|
4603
|
+
:type body: JSON or IO[bytes]
|
|
4604
|
+
:return: JSON object
|
|
4605
|
+
:rtype: JSON
|
|
4606
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4607
|
+
|
|
4608
|
+
Example:
|
|
4609
|
+
.. code-block:: python
|
|
4610
|
+
|
|
4611
|
+
# JSON input template you can fill out and use as your body input.
|
|
4612
|
+
body = {}
|
|
4613
|
+
"""
|
|
4614
|
+
error_map = {
|
|
4615
|
+
409: ResourceExistsError,
|
|
4616
|
+
304: ResourceNotModifiedError,
|
|
4617
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4618
|
+
404: lambda response: ResourceNotFoundError(response=response),
|
|
4619
|
+
}
|
|
4620
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4621
|
+
|
|
4622
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
4623
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4624
|
+
|
|
4625
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
4626
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
4627
|
+
|
|
4628
|
+
content_type = content_type or "application/json"
|
|
4629
|
+
_json = None
|
|
4630
|
+
_content = None
|
|
4631
|
+
if isinstance(body, (IOBase, bytes)):
|
|
4632
|
+
_content = body
|
|
4633
|
+
else:
|
|
4634
|
+
_json = body
|
|
4635
|
+
|
|
4636
|
+
_request = build_update_notification_channel_request(
|
|
4637
|
+
channel_id=channel_id,
|
|
4638
|
+
content_type=content_type,
|
|
4639
|
+
json=_json,
|
|
4640
|
+
content=_content,
|
|
4641
|
+
headers=_headers,
|
|
4642
|
+
params=_params,
|
|
4643
|
+
)
|
|
4644
|
+
_request.url = self._client.format_url(_request.url)
|
|
4645
|
+
|
|
4646
|
+
_stream = False
|
|
4647
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4648
|
+
_request, stream=_stream, **kwargs
|
|
4649
|
+
)
|
|
4650
|
+
|
|
4651
|
+
response = pipeline_response.http_response
|
|
4652
|
+
|
|
4653
|
+
if response.status_code not in [200]:
|
|
4654
|
+
if _stream:
|
|
4655
|
+
await response.read() # Load the body in memory and close the socket
|
|
4656
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4657
|
+
raise HttpResponseError(response=response)
|
|
4658
|
+
|
|
4659
|
+
if response.content:
|
|
4660
|
+
deserialized = response.json()
|
|
4661
|
+
else:
|
|
4662
|
+
deserialized = None
|
|
4663
|
+
|
|
4664
|
+
if cls:
|
|
4665
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
4666
|
+
|
|
4667
|
+
return cast(JSON, deserialized) # type: ignore
|
|
4668
|
+
|
|
4669
|
+
@distributed_trace_async
|
|
4670
|
+
async def list_notification_rules(
|
|
4671
|
+
self,
|
|
4672
|
+
*,
|
|
4673
|
+
limit: int = 1000,
|
|
4674
|
+
offset: int = 0,
|
|
4675
|
+
order_by: str = "id",
|
|
4676
|
+
include_disabled: bool = False,
|
|
4677
|
+
feature: Optional[List[str]] = None,
|
|
4678
|
+
**kwargs: Any
|
|
4679
|
+
) -> List[JSON]:
|
|
4680
|
+
"""List notification rules.
|
|
4681
|
+
|
|
4682
|
+
List all notification rules.
|
|
4683
|
+
|
|
4684
|
+
:keyword limit: Number of entries to return. Default value is 1000.
|
|
4685
|
+
:paramtype limit: int
|
|
4686
|
+
:keyword offset: Number of entries to skip. Default value is 0.
|
|
4687
|
+
:paramtype offset: int
|
|
4688
|
+
:keyword order_by: Order by field. Known values are: "id", "type", "createdAt", and
|
|
4689
|
+
"updatedAt". Default value is "id".
|
|
4690
|
+
:paramtype order_by: str
|
|
4691
|
+
:keyword include_disabled: Include disabled entries. Default value is False.
|
|
4692
|
+
:paramtype include_disabled: bool
|
|
4693
|
+
:keyword feature: Filtering by multiple features.
|
|
4694
|
+
|
|
4695
|
+
Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
|
|
4696
|
+
:paramtype feature: list[str]
|
|
4697
|
+
:return: list of JSON object
|
|
4698
|
+
:rtype: list[JSON]
|
|
4699
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4700
|
+
|
|
4701
|
+
Example:
|
|
4702
|
+
.. code-block:: python
|
|
4703
|
+
|
|
4704
|
+
# response body for status code(s): 200
|
|
4705
|
+
response == [
|
|
4706
|
+
{}
|
|
4707
|
+
]
|
|
4708
|
+
"""
|
|
4709
|
+
error_map = {
|
|
4710
|
+
404: ResourceNotFoundError,
|
|
4711
|
+
409: ResourceExistsError,
|
|
4712
|
+
304: ResourceNotModifiedError,
|
|
4713
|
+
400: HttpResponseError,
|
|
4714
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4715
|
+
}
|
|
4716
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4717
|
+
|
|
4718
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
4719
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4720
|
+
|
|
4721
|
+
cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
|
|
4722
|
+
|
|
4723
|
+
_request = build_list_notification_rules_request(
|
|
4724
|
+
limit=limit,
|
|
4725
|
+
offset=offset,
|
|
4726
|
+
order_by=order_by,
|
|
4727
|
+
include_disabled=include_disabled,
|
|
4728
|
+
feature=feature,
|
|
4729
|
+
headers=_headers,
|
|
4730
|
+
params=_params,
|
|
4731
|
+
)
|
|
4732
|
+
_request.url = self._client.format_url(_request.url)
|
|
4733
|
+
|
|
4734
|
+
_stream = False
|
|
4735
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4736
|
+
_request, stream=_stream, **kwargs
|
|
4737
|
+
)
|
|
4738
|
+
|
|
4739
|
+
response = pipeline_response.http_response
|
|
4740
|
+
|
|
4741
|
+
if response.status_code not in [200]:
|
|
4742
|
+
if _stream:
|
|
4743
|
+
await response.read() # Load the body in memory and close the socket
|
|
4744
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4745
|
+
raise HttpResponseError(response=response)
|
|
4746
|
+
|
|
4747
|
+
if response.content:
|
|
4748
|
+
deserialized = response.json()
|
|
4749
|
+
else:
|
|
4750
|
+
deserialized = None
|
|
4751
|
+
|
|
4752
|
+
if cls:
|
|
4753
|
+
return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
|
|
4754
|
+
|
|
4755
|
+
return cast(List[JSON], deserialized) # type: ignore
|
|
4756
|
+
|
|
4757
|
+
@overload
|
|
4758
|
+
async def create_notification_rule(
|
|
4759
|
+
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
4760
|
+
) -> JSON:
|
|
4761
|
+
"""Create a notification rule.
|
|
4762
|
+
|
|
4763
|
+
Create a new notification rule.
|
|
4764
|
+
|
|
4765
|
+
:param body: The notification rule to create. Required.
|
|
4766
|
+
:type body: JSON
|
|
4767
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
4768
|
+
Default value is "application/json".
|
|
4769
|
+
:paramtype content_type: str
|
|
4770
|
+
:return: JSON object
|
|
4771
|
+
:rtype: JSON
|
|
4772
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4773
|
+
|
|
4774
|
+
Example:
|
|
4775
|
+
.. code-block:: python
|
|
4776
|
+
|
|
4777
|
+
# JSON input template you can fill out and use as your body input.
|
|
4778
|
+
body = {}
|
|
4779
|
+
|
|
4780
|
+
# response body for status code(s): 409
|
|
4781
|
+
response == {
|
|
4782
|
+
"detail": "str", # A human-readable explanation specific to this occurrence
|
|
4783
|
+
of the problem. Required.
|
|
4784
|
+
"status": 0, # The HTTP status code generated by the origin server for this
|
|
4785
|
+
occurrence of the problem. Required.
|
|
4786
|
+
"title": "str", # A a short, human-readable summary of the problem type.
|
|
4787
|
+
Required.
|
|
4788
|
+
"type": "str", # Type contains a URI that identifies the problem type.
|
|
4789
|
+
Required.
|
|
4790
|
+
"extensions": {
|
|
4791
|
+
"conflictingEntityId": "str" # The id of the conflicting entity.
|
|
4792
|
+
Required.
|
|
4793
|
+
},
|
|
4794
|
+
"instance": "str" # Optional. A URI reference that identifies the specific
|
|
4795
|
+
occurrence of the problem.
|
|
4796
|
+
}
|
|
4797
|
+
"""
|
|
4798
|
+
|
|
4799
|
+
@overload
|
|
4800
|
+
async def create_notification_rule(
|
|
4801
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
4802
|
+
) -> JSON:
|
|
4803
|
+
"""Create a notification rule.
|
|
4804
|
+
|
|
4805
|
+
Create a new notification rule.
|
|
4806
|
+
|
|
4807
|
+
:param body: The notification rule to create. Required.
|
|
4808
|
+
:type body: IO[bytes]
|
|
4809
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
4810
|
+
Default value is "application/json".
|
|
4811
|
+
:paramtype content_type: str
|
|
4812
|
+
:return: JSON object
|
|
4813
|
+
:rtype: JSON
|
|
4814
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4815
|
+
|
|
4816
|
+
Example:
|
|
4817
|
+
.. code-block:: python
|
|
4818
|
+
|
|
4819
|
+
# response body for status code(s): 409
|
|
4820
|
+
response == {
|
|
4821
|
+
"detail": "str", # A human-readable explanation specific to this occurrence
|
|
4822
|
+
of the problem. Required.
|
|
4823
|
+
"status": 0, # The HTTP status code generated by the origin server for this
|
|
4824
|
+
occurrence of the problem. Required.
|
|
4825
|
+
"title": "str", # A a short, human-readable summary of the problem type.
|
|
4826
|
+
Required.
|
|
4827
|
+
"type": "str", # Type contains a URI that identifies the problem type.
|
|
4828
|
+
Required.
|
|
4829
|
+
"extensions": {
|
|
4830
|
+
"conflictingEntityId": "str" # The id of the conflicting entity.
|
|
4831
|
+
Required.
|
|
4832
|
+
},
|
|
4833
|
+
"instance": "str" # Optional. A URI reference that identifies the specific
|
|
4834
|
+
occurrence of the problem.
|
|
4835
|
+
}
|
|
4836
|
+
"""
|
|
4837
|
+
|
|
4838
|
+
@distributed_trace_async
|
|
4839
|
+
async def create_notification_rule(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
4840
|
+
"""Create a notification rule.
|
|
4841
|
+
|
|
4842
|
+
Create a new notification rule.
|
|
4843
|
+
|
|
4844
|
+
:param body: The notification rule to create. Is either a JSON type or a IO[bytes] type.
|
|
4845
|
+
Required.
|
|
4846
|
+
:type body: JSON or IO[bytes]
|
|
4847
|
+
:return: JSON object
|
|
4848
|
+
:rtype: JSON
|
|
4849
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4850
|
+
|
|
4851
|
+
Example:
|
|
4852
|
+
.. code-block:: python
|
|
4853
|
+
|
|
4854
|
+
# JSON input template you can fill out and use as your body input.
|
|
4855
|
+
body = {}
|
|
4856
|
+
|
|
4857
|
+
# response body for status code(s): 409
|
|
4858
|
+
response == {
|
|
4859
|
+
"detail": "str", # A human-readable explanation specific to this occurrence
|
|
4860
|
+
of the problem. Required.
|
|
4861
|
+
"status": 0, # The HTTP status code generated by the origin server for this
|
|
4862
|
+
occurrence of the problem. Required.
|
|
4863
|
+
"title": "str", # A a short, human-readable summary of the problem type.
|
|
4864
|
+
Required.
|
|
4865
|
+
"type": "str", # Type contains a URI that identifies the problem type.
|
|
4866
|
+
Required.
|
|
4867
|
+
"extensions": {
|
|
4868
|
+
"conflictingEntityId": "str" # The id of the conflicting entity.
|
|
4869
|
+
Required.
|
|
4870
|
+
},
|
|
4871
|
+
"instance": "str" # Optional. A URI reference that identifies the specific
|
|
4872
|
+
occurrence of the problem.
|
|
4873
|
+
}
|
|
4874
|
+
"""
|
|
4875
|
+
error_map = {
|
|
4876
|
+
404: ResourceNotFoundError,
|
|
4877
|
+
409: ResourceExistsError,
|
|
4878
|
+
304: ResourceNotModifiedError,
|
|
4879
|
+
400: HttpResponseError,
|
|
4880
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4881
|
+
}
|
|
4882
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4883
|
+
|
|
4884
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
4885
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4886
|
+
|
|
4887
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
4888
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
4889
|
+
|
|
4890
|
+
content_type = content_type or "application/json"
|
|
4891
|
+
_json = None
|
|
4892
|
+
_content = None
|
|
4893
|
+
if isinstance(body, (IOBase, bytes)):
|
|
4894
|
+
_content = body
|
|
4895
|
+
else:
|
|
4896
|
+
_json = body
|
|
4897
|
+
|
|
4898
|
+
_request = build_create_notification_rule_request(
|
|
4899
|
+
content_type=content_type,
|
|
4900
|
+
json=_json,
|
|
4901
|
+
content=_content,
|
|
4902
|
+
headers=_headers,
|
|
4903
|
+
params=_params,
|
|
4904
|
+
)
|
|
4905
|
+
_request.url = self._client.format_url(_request.url)
|
|
4906
|
+
|
|
4907
|
+
_stream = False
|
|
4908
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4909
|
+
_request, stream=_stream, **kwargs
|
|
4910
|
+
)
|
|
4911
|
+
|
|
4912
|
+
response = pipeline_response.http_response
|
|
4913
|
+
|
|
4914
|
+
if response.status_code not in [201, 409]:
|
|
4915
|
+
if _stream:
|
|
4916
|
+
await response.read() # Load the body in memory and close the socket
|
|
4917
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4918
|
+
raise HttpResponseError(response=response)
|
|
4919
|
+
|
|
4920
|
+
if response.status_code == 201:
|
|
4921
|
+
if response.content:
|
|
4922
|
+
deserialized = response.json()
|
|
4923
|
+
else:
|
|
4924
|
+
deserialized = None
|
|
4925
|
+
|
|
4926
|
+
if response.status_code == 409:
|
|
4927
|
+
if response.content:
|
|
4928
|
+
deserialized = response.json()
|
|
4929
|
+
else:
|
|
4930
|
+
deserialized = None
|
|
4931
|
+
|
|
4932
|
+
if cls:
|
|
4933
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
4934
|
+
|
|
4935
|
+
return cast(JSON, deserialized) # type: ignore
|
|
4936
|
+
|
|
4937
|
+
@distributed_trace_async
|
|
4938
|
+
async def get_notification_rule(self, rule_id: str, **kwargs: Any) -> JSON:
|
|
4939
|
+
"""Get notification rule.
|
|
4940
|
+
|
|
4941
|
+
Get a notification rule by id.
|
|
4942
|
+
|
|
4943
|
+
:param rule_id: A unique ULID identifier for a notification rule. Required.
|
|
4944
|
+
:type rule_id: str
|
|
4945
|
+
:return: JSON object
|
|
4946
|
+
:rtype: JSON
|
|
4947
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
4948
|
+
"""
|
|
4949
|
+
error_map = {
|
|
4950
|
+
409: ResourceExistsError,
|
|
4951
|
+
304: ResourceNotModifiedError,
|
|
4952
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
4953
|
+
404: lambda response: ResourceNotFoundError(response=response),
|
|
4954
|
+
}
|
|
4955
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
4956
|
+
|
|
4957
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
4958
|
+
_params = kwargs.pop("params", {}) or {}
|
|
4959
|
+
|
|
4960
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
4961
|
+
|
|
4962
|
+
_request = build_get_notification_rule_request(
|
|
4963
|
+
rule_id=rule_id,
|
|
4964
|
+
headers=_headers,
|
|
4965
|
+
params=_params,
|
|
4966
|
+
)
|
|
4967
|
+
_request.url = self._client.format_url(_request.url)
|
|
4968
|
+
|
|
4969
|
+
_stream = False
|
|
4970
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
4971
|
+
_request, stream=_stream, **kwargs
|
|
4972
|
+
)
|
|
4973
|
+
|
|
4974
|
+
response = pipeline_response.http_response
|
|
4975
|
+
|
|
4976
|
+
if response.status_code not in [200]:
|
|
4977
|
+
if _stream:
|
|
4978
|
+
await response.read() # Load the body in memory and close the socket
|
|
4979
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
4980
|
+
raise HttpResponseError(response=response)
|
|
4981
|
+
|
|
4982
|
+
if response.content:
|
|
4983
|
+
deserialized = response.json()
|
|
4984
|
+
else:
|
|
4985
|
+
deserialized = None
|
|
4986
|
+
|
|
4987
|
+
if cls:
|
|
4988
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
4989
|
+
|
|
4990
|
+
return cast(JSON, deserialized) # type: ignore
|
|
4991
|
+
|
|
4992
|
+
@distributed_trace_async
|
|
4993
|
+
async def delete_notification_rule( # pylint: disable=inconsistent-return-statements
|
|
4994
|
+
self, rule_id: str, **kwargs: Any
|
|
4995
|
+
) -> None:
|
|
4996
|
+
"""Delete a notification rule.
|
|
4997
|
+
|
|
4998
|
+
Delete notification rule by id.
|
|
4999
|
+
|
|
5000
|
+
:param rule_id: A unique ULID identifier for a notification rule. Required.
|
|
5001
|
+
:type rule_id: str
|
|
5002
|
+
:return: None
|
|
5003
|
+
:rtype: None
|
|
5004
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
5005
|
+
"""
|
|
5006
|
+
error_map = {
|
|
5007
|
+
409: ResourceExistsError,
|
|
5008
|
+
304: ResourceNotModifiedError,
|
|
5009
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
5010
|
+
404: lambda response: ResourceNotFoundError(response=response),
|
|
5011
|
+
}
|
|
5012
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
5013
|
+
|
|
5014
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
5015
|
+
_params = kwargs.pop("params", {}) or {}
|
|
5016
|
+
|
|
5017
|
+
cls: ClsType[None] = kwargs.pop("cls", None)
|
|
5018
|
+
|
|
5019
|
+
_request = build_delete_notification_rule_request(
|
|
5020
|
+
rule_id=rule_id,
|
|
5021
|
+
headers=_headers,
|
|
5022
|
+
params=_params,
|
|
5023
|
+
)
|
|
5024
|
+
_request.url = self._client.format_url(_request.url)
|
|
5025
|
+
|
|
5026
|
+
_stream = False
|
|
5027
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
5028
|
+
_request, stream=_stream, **kwargs
|
|
5029
|
+
)
|
|
5030
|
+
|
|
5031
|
+
response = pipeline_response.http_response
|
|
5032
|
+
|
|
5033
|
+
if response.status_code not in [204]:
|
|
5034
|
+
if _stream:
|
|
5035
|
+
await response.read() # Load the body in memory and close the socket
|
|
5036
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
5037
|
+
raise HttpResponseError(response=response)
|
|
5038
|
+
|
|
5039
|
+
if cls:
|
|
5040
|
+
return cls(pipeline_response, None, {}) # type: ignore
|
|
5041
|
+
|
|
5042
|
+
@overload
|
|
5043
|
+
async def update_notification_rule(
|
|
5044
|
+
self, rule_id: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
5045
|
+
) -> JSON:
|
|
5046
|
+
"""Update a notification rule.
|
|
5047
|
+
|
|
5048
|
+
Update a notification rule by id.
|
|
5049
|
+
|
|
5050
|
+
:param rule_id: A unique ULID identifier for a notification rule. Required.
|
|
5051
|
+
:type rule_id: str
|
|
5052
|
+
:param body: The notification rule to update. Required.
|
|
5053
|
+
:type body: JSON
|
|
5054
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
|
5055
|
+
Default value is "application/json".
|
|
5056
|
+
:paramtype content_type: str
|
|
5057
|
+
:return: JSON object
|
|
5058
|
+
:rtype: JSON
|
|
5059
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
5060
|
+
|
|
5061
|
+
Example:
|
|
5062
|
+
.. code-block:: python
|
|
5063
|
+
|
|
5064
|
+
# JSON input template you can fill out and use as your body input.
|
|
5065
|
+
body = {}
|
|
5066
|
+
"""
|
|
5067
|
+
|
|
5068
|
+
@overload
|
|
5069
|
+
async def update_notification_rule(
|
|
5070
|
+
self, rule_id: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
5071
|
+
) -> JSON:
|
|
5072
|
+
"""Update a notification rule.
|
|
5073
|
+
|
|
5074
|
+
Update a notification rule by id.
|
|
5075
|
+
|
|
5076
|
+
:param rule_id: A unique ULID identifier for a notification rule. Required.
|
|
5077
|
+
:type rule_id: str
|
|
5078
|
+
:param body: The notification rule to update. Required.
|
|
5079
|
+
:type body: IO[bytes]
|
|
5080
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
|
5081
|
+
Default value is "application/json".
|
|
5082
|
+
:paramtype content_type: str
|
|
5083
|
+
:return: JSON object
|
|
5084
|
+
:rtype: JSON
|
|
5085
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
5086
|
+
"""
|
|
5087
|
+
|
|
5088
|
+
@distributed_trace_async
|
|
5089
|
+
async def update_notification_rule(self, rule_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
5090
|
+
"""Update a notification rule.
|
|
5091
|
+
|
|
5092
|
+
Update a notification rule by id.
|
|
5093
|
+
|
|
5094
|
+
:param rule_id: A unique ULID identifier for a notification rule. Required.
|
|
5095
|
+
:type rule_id: str
|
|
5096
|
+
:param body: The notification rule to update. Is either a JSON type or a IO[bytes] type.
|
|
5097
|
+
Required.
|
|
5098
|
+
:type body: JSON or IO[bytes]
|
|
5099
|
+
:return: JSON object
|
|
5100
|
+
:rtype: JSON
|
|
5101
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
5102
|
+
|
|
5103
|
+
Example:
|
|
5104
|
+
.. code-block:: python
|
|
5105
|
+
|
|
5106
|
+
# JSON input template you can fill out and use as your body input.
|
|
5107
|
+
body = {}
|
|
5108
|
+
"""
|
|
5109
|
+
error_map = {
|
|
5110
|
+
409: ResourceExistsError,
|
|
5111
|
+
304: ResourceNotModifiedError,
|
|
5112
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
5113
|
+
404: lambda response: ResourceNotFoundError(response=response),
|
|
5114
|
+
}
|
|
5115
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
5116
|
+
|
|
5117
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
5118
|
+
_params = kwargs.pop("params", {}) or {}
|
|
5119
|
+
|
|
5120
|
+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
|
5121
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
5122
|
+
|
|
5123
|
+
content_type = content_type or "application/json"
|
|
5124
|
+
_json = None
|
|
5125
|
+
_content = None
|
|
5126
|
+
if isinstance(body, (IOBase, bytes)):
|
|
5127
|
+
_content = body
|
|
5128
|
+
else:
|
|
5129
|
+
_json = body
|
|
5130
|
+
|
|
5131
|
+
_request = build_update_notification_rule_request(
|
|
5132
|
+
rule_id=rule_id,
|
|
5133
|
+
content_type=content_type,
|
|
5134
|
+
json=_json,
|
|
5135
|
+
content=_content,
|
|
5136
|
+
headers=_headers,
|
|
5137
|
+
params=_params,
|
|
5138
|
+
)
|
|
5139
|
+
_request.url = self._client.format_url(_request.url)
|
|
5140
|
+
|
|
5141
|
+
_stream = False
|
|
5142
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
5143
|
+
_request, stream=_stream, **kwargs
|
|
5144
|
+
)
|
|
5145
|
+
|
|
5146
|
+
response = pipeline_response.http_response
|
|
5147
|
+
|
|
5148
|
+
if response.status_code not in [200]:
|
|
5149
|
+
if _stream:
|
|
5150
|
+
await response.read() # Load the body in memory and close the socket
|
|
5151
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
5152
|
+
raise HttpResponseError(response=response)
|
|
5153
|
+
|
|
5154
|
+
if response.content:
|
|
5155
|
+
deserialized = response.json()
|
|
5156
|
+
else:
|
|
5157
|
+
deserialized = None
|
|
5158
|
+
|
|
5159
|
+
if cls:
|
|
5160
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
5161
|
+
|
|
5162
|
+
return cast(JSON, deserialized) # type: ignore
|
|
5163
|
+
|
|
5164
|
+
@distributed_trace_async
|
|
5165
|
+
async def list_notification_events(
|
|
5166
|
+
self,
|
|
5167
|
+
*,
|
|
5168
|
+
limit: int = 1000,
|
|
5169
|
+
offset: int = 0,
|
|
5170
|
+
order_by: str = "id",
|
|
5171
|
+
feature: Optional[List[str]] = None,
|
|
5172
|
+
subject: Optional[List[str]] = None,
|
|
5173
|
+
**kwargs: Any
|
|
5174
|
+
) -> List[JSON]:
|
|
5175
|
+
"""List notification evens.
|
|
5176
|
+
|
|
5177
|
+
List all notification events.
|
|
5178
|
+
|
|
5179
|
+
:keyword limit: Number of entries to return. Default value is 1000.
|
|
5180
|
+
:paramtype limit: int
|
|
5181
|
+
:keyword offset: Number of entries to skip. Default value is 0.
|
|
5182
|
+
:paramtype offset: int
|
|
5183
|
+
:keyword order_by: Order by field. Known values are: "id" and "createdAt". Default value is
|
|
5184
|
+
"id".
|
|
5185
|
+
:paramtype order_by: str
|
|
5186
|
+
:keyword feature: Filtering by multiple features.
|
|
5187
|
+
|
|
5188
|
+
Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
|
|
5189
|
+
:paramtype feature: list[str]
|
|
5190
|
+
:keyword subject: Filtering by multiple subjects.
|
|
5191
|
+
|
|
5192
|
+
Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
|
|
5193
|
+
:paramtype subject: list[str]
|
|
5194
|
+
:return: list of JSON object
|
|
5195
|
+
:rtype: list[JSON]
|
|
5196
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
5197
|
+
|
|
5198
|
+
Example:
|
|
5199
|
+
.. code-block:: python
|
|
5200
|
+
|
|
5201
|
+
# response body for status code(s): 200
|
|
5202
|
+
response == [
|
|
5203
|
+
{
|
|
5204
|
+
"createdAt": "2020-02-20 00:00:00", # Timestamp when the
|
|
5205
|
+
notification event was created. Required.
|
|
5206
|
+
"deliveryStatus": [
|
|
5207
|
+
{
|
|
5208
|
+
"channel": {
|
|
5209
|
+
"id": "str", # A unique identifier for the
|
|
5210
|
+
notification channel. Required.
|
|
5211
|
+
"type": "str" # The type of the notification
|
|
5212
|
+
channel. Required. "WEBHOOK"
|
|
5213
|
+
},
|
|
5214
|
+
"state": "str", # Required. Known values are:
|
|
5215
|
+
"SUCCESS", "FAILED", and "SENDING".
|
|
5216
|
+
"updatedAt": "2020-02-20 00:00:00" # Required.
|
|
5217
|
+
}
|
|
5218
|
+
],
|
|
5219
|
+
"id": "str", # A unique identifier for the notification event.
|
|
5220
|
+
Required.
|
|
5221
|
+
"payload": {},
|
|
5222
|
+
"rule": {
|
|
5223
|
+
"id": "str", # A unique identifier for the notification
|
|
5224
|
+
rule. Required.
|
|
5225
|
+
"type": "str" # The type of the notification event.
|
|
5226
|
+
Required. "entitlements.balance.threshold"
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5229
|
+
]
|
|
5230
|
+
"""
|
|
5231
|
+
error_map = {
|
|
5232
|
+
404: ResourceNotFoundError,
|
|
5233
|
+
409: ResourceExistsError,
|
|
5234
|
+
304: ResourceNotModifiedError,
|
|
5235
|
+
400: HttpResponseError,
|
|
5236
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
5237
|
+
}
|
|
5238
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
5239
|
+
|
|
5240
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
5241
|
+
_params = kwargs.pop("params", {}) or {}
|
|
5242
|
+
|
|
5243
|
+
cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
|
|
5244
|
+
|
|
5245
|
+
_request = build_list_notification_events_request(
|
|
5246
|
+
limit=limit,
|
|
5247
|
+
offset=offset,
|
|
5248
|
+
order_by=order_by,
|
|
5249
|
+
feature=feature,
|
|
5250
|
+
subject=subject,
|
|
5251
|
+
headers=_headers,
|
|
5252
|
+
params=_params,
|
|
5253
|
+
)
|
|
5254
|
+
_request.url = self._client.format_url(_request.url)
|
|
5255
|
+
|
|
5256
|
+
_stream = False
|
|
5257
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
5258
|
+
_request, stream=_stream, **kwargs
|
|
5259
|
+
)
|
|
5260
|
+
|
|
5261
|
+
response = pipeline_response.http_response
|
|
5262
|
+
|
|
5263
|
+
if response.status_code not in [200]:
|
|
5264
|
+
if _stream:
|
|
5265
|
+
await response.read() # Load the body in memory and close the socket
|
|
5266
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
5267
|
+
raise HttpResponseError(response=response)
|
|
5268
|
+
|
|
5269
|
+
if response.content:
|
|
5270
|
+
deserialized = response.json()
|
|
5271
|
+
else:
|
|
5272
|
+
deserialized = None
|
|
5273
|
+
|
|
5274
|
+
if cls:
|
|
5275
|
+
return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
|
|
5276
|
+
|
|
5277
|
+
return cast(List[JSON], deserialized) # type: ignore
|
|
5278
|
+
|
|
5279
|
+
@distributed_trace_async
|
|
5280
|
+
async def get_notification_event(self, event_id: str, **kwargs: Any) -> JSON:
|
|
5281
|
+
"""Get notification event.
|
|
5282
|
+
|
|
5283
|
+
Get a notification event by id.
|
|
5284
|
+
|
|
5285
|
+
:param event_id: A unique ULID identifier for a notification event. Required.
|
|
5286
|
+
:type event_id: str
|
|
5287
|
+
:return: JSON object
|
|
5288
|
+
:rtype: JSON
|
|
5289
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
|
5290
|
+
"""
|
|
5291
|
+
error_map = {
|
|
5292
|
+
409: ResourceExistsError,
|
|
5293
|
+
304: ResourceNotModifiedError,
|
|
5294
|
+
401: lambda response: ClientAuthenticationError(response=response),
|
|
5295
|
+
404: lambda response: ResourceNotFoundError(response=response),
|
|
5296
|
+
}
|
|
5297
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
5298
|
+
|
|
5299
|
+
_headers = kwargs.pop("headers", {}) or {}
|
|
5300
|
+
_params = kwargs.pop("params", {}) or {}
|
|
5301
|
+
|
|
5302
|
+
cls: ClsType[JSON] = kwargs.pop("cls", None)
|
|
5303
|
+
|
|
5304
|
+
_request = build_get_notification_event_request(
|
|
5305
|
+
event_id=event_id,
|
|
5306
|
+
headers=_headers,
|
|
5307
|
+
params=_params,
|
|
5308
|
+
)
|
|
5309
|
+
_request.url = self._client.format_url(_request.url)
|
|
5310
|
+
|
|
5311
|
+
_stream = False
|
|
5312
|
+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
|
|
5313
|
+
_request, stream=_stream, **kwargs
|
|
5314
|
+
)
|
|
5315
|
+
|
|
5316
|
+
response = pipeline_response.http_response
|
|
5317
|
+
|
|
5318
|
+
if response.status_code not in [200]:
|
|
5319
|
+
if _stream:
|
|
5320
|
+
await response.read() # Load the body in memory and close the socket
|
|
5321
|
+
map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
|
|
5322
|
+
raise HttpResponseError(response=response)
|
|
5323
|
+
|
|
5324
|
+
if response.content:
|
|
5325
|
+
deserialized = response.json()
|
|
5326
|
+
else:
|
|
5327
|
+
deserialized = None
|
|
5328
|
+
|
|
5329
|
+
if cls:
|
|
5330
|
+
return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
|
|
5331
|
+
|
|
5332
|
+
return cast(JSON, deserialized) # type: ignore
|