openmeter 1.0.0b144__py3-none-any.whl → 1.0.0b145__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.

@@ -703,6 +703,33 @@ def build_delete_entitlement_request(subject_id_or_key: str, entitlement_id: str
703
703
  return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs)
704
704
 
705
705
 
706
+ def build_override_entitlement_request(
707
+ subject_id_or_key: str, entitlement_id_or_feature_key: str, **kwargs: Any
708
+ ) -> HttpRequest:
709
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
710
+
711
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
712
+ accept = _headers.pop("Accept", "application/json, application/problem+json")
713
+
714
+ # Construct URL
715
+ _url = "/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/override"
716
+ path_format_arguments = {
717
+ "subjectIdOrKey": _SERIALIZER.url("subject_id_or_key", subject_id_or_key, "str"),
718
+ "entitlementIdOrFeatureKey": _SERIALIZER.url(
719
+ "entitlement_id_or_feature_key", entitlement_id_or_feature_key, "str"
720
+ ),
721
+ }
722
+
723
+ _url: str = _url.format(**path_format_arguments) # type: ignore
724
+
725
+ # Construct headers
726
+ if content_type is not None:
727
+ _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
728
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
729
+
730
+ return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs)
731
+
732
+
706
733
  def build_list_entitlement_grants_request(
707
734
  subject_id_or_key: str,
708
735
  entitlement_id_or_feature_key: str,
@@ -1159,6 +1186,23 @@ def build_list_notification_events_request(
1159
1186
  return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
1160
1187
 
1161
1188
 
1189
+ def build_create_notification_event_request(**kwargs: Any) -> HttpRequest:
1190
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1191
+
1192
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1193
+ accept = _headers.pop("Accept", "application/json, application/problem+json")
1194
+
1195
+ # Construct URL
1196
+ _url = "/api/v1/notification/events"
1197
+
1198
+ # Construct headers
1199
+ if content_type is not None:
1200
+ _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
1201
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
1202
+
1203
+ return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs)
1204
+
1205
+
1162
1206
  def build_get_notification_event_request(event_id: str, **kwargs: Any) -> HttpRequest:
1163
1207
  _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1164
1208
 
@@ -1178,6 +1222,23 @@ def build_get_notification_event_request(event_id: str, **kwargs: Any) -> HttpRe
1178
1222
  return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs)
1179
1223
 
1180
1224
 
1225
+ def build_receive_svix_operational_event_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long
1226
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1227
+
1228
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1229
+ accept = _headers.pop("Accept", "application/problem+json")
1230
+
1231
+ # Construct URL
1232
+ _url = "/api/v1/notification/webhook/svix"
1233
+
1234
+ # Construct headers
1235
+ if content_type is not None:
1236
+ _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
1237
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
1238
+
1239
+ return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs)
1240
+
1241
+
1181
1242
  class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-methods
1182
1243
  @distributed_trace
1183
1244
  def list_events(
@@ -4294,191 +4355,91 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
4294
4355
  if cls:
4295
4356
  return cls(pipeline_response, None, {}) # type: ignore
4296
4357
 
4297
- @distributed_trace
4298
- def list_entitlement_grants(
4358
+ @overload
4359
+ def override_entitlement(
4299
4360
  self,
4300
4361
  subject_id_or_key: str,
4301
4362
  entitlement_id_or_feature_key: str,
4363
+ body: JSON,
4302
4364
  *,
4303
- include_deleted: bool = False,
4304
- order_by: str = "updatedAt",
4365
+ content_type: str = "application/json",
4305
4366
  **kwargs: Any
4306
- ) -> List[JSON]:
4307
- # pylint: disable=line-too-long
4308
- """List grants for an entitlement.
4367
+ ) -> JSON:
4368
+ """Override an entitlement.
4309
4369
 
4310
- List all grants issued for an entitlement. The entitlement can be defined either by its id or
4311
- featureKey.
4370
+ Overriding an entitlement creates a new entitlement from the provided inputs and soft deletes
4371
+ the previous entitlement for the provided subject-feature pair. If the previous entitlement is
4372
+ already deleted or otherwise doesnt exist, the override will fail.
4373
+
4374
+ This endpoint is useful for upgrades, downgrades, or other changes to entitlements that require
4375
+ a new entitlement to be created with zero downtime.
4312
4376
 
4313
4377
  :param subject_id_or_key: A unique identifier for a subject. Required.
4314
4378
  :type subject_id_or_key: str
4315
4379
  :param entitlement_id_or_feature_key: The id of the entitlement or the key of the feature.
4316
4380
  Required.
4317
4381
  :type entitlement_id_or_feature_key: str
4318
- :keyword include_deleted: Include deleted entries. Default value is False.
4319
- :paramtype include_deleted: bool
4320
- :keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
4321
- Default value is "updatedAt".
4322
- :paramtype order_by: str
4323
- :return: list of JSON object
4324
- :rtype: list[JSON]
4382
+ :param body: The entitlement to create. Required.
4383
+ :type body: JSON
4384
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
4385
+ Default value is "application/json".
4386
+ :paramtype content_type: str
4387
+ :return: JSON object
4388
+ :rtype: JSON
4325
4389
  :raises ~azure.core.exceptions.HttpResponseError:
4326
4390
 
4327
4391
  Example:
4328
4392
  .. code-block:: python
4329
4393
 
4330
- # response body for status code(s): 200
4331
- response == [
4332
- {
4333
- "amount": 0.0, # The amount to grant. Should be a positive number.
4394
+ # JSON input template you can fill out and use as your body input.
4395
+ body = {}
4396
+
4397
+ # response body for status code(s): 409
4398
+ response == {
4399
+ "detail": "str", # A human-readable explanation specific to this occurrence
4400
+ of the problem. Required.
4401
+ "status": 0, # The HTTP status code generated by the origin server for this
4402
+ occurrence of the problem. Required.
4403
+ "title": "str", # A a short, human-readable summary of the problem type.
4404
+ Required.
4405
+ "type": "str", # Type contains a URI that identifies the problem type.
4406
+ Required.
4407
+ "extensions": {
4408
+ "conflictingEntityId": "str" # The id of the conflicting entity.
4334
4409
  Required.
4335
- "createdAt": "2020-02-20 00:00:00", # The date and time the resource
4336
- was created. Required.
4337
- "effectiveAt": "2020-02-20 00:00:00", # Effective date for grants
4338
- and anchor for recurring grants. Provided value will be ceiled to metering
4339
- windowSize (minute). Required.
4340
- "entitlementId": "str", # The unique entitlement ULID that the grant
4341
- is associated with. Required.
4342
- "expiration": {
4343
- "count": 0, # The expiration period count like 12 months.
4344
- Required.
4345
- "duration": "str" # The expiration period duration like
4346
- month. Required. Known values are: "HOUR", "DAY", "WEEK", "MONTH", and
4347
- "YEAR".
4348
- },
4349
- "id": "str", # Readonly unique ULID identifier. Required.
4350
- "updatedAt": "2020-02-20 00:00:00", # The date and time the resource
4351
- was last updated. The initial value is the same as createdAt. Required.
4352
- "deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
4353
- the resource was deleted.
4354
- "expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date
4355
- of the grant.
4356
- "maxRolloverAmount": 0, # Optional. Default value is 0. Grants are
4357
- rolled over at reset, after which they can have a different balance compared
4358
- to what they had before the reset. Balance after the reset is calculated as:
4359
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
4360
- MinRolloverAmount)).
4361
- "metadata": {
4362
- "str": "str" # Optional. Dictionary of :code:`<string>`.
4363
- },
4364
- "minRolloverAmount": 0, # Optional. Default value is 0. Grants are
4365
- rolled over at reset, after which they can have a different balance compared
4366
- to what they had before the reset. Balance after the reset is calculated as:
4367
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
4368
- MinRolloverAmount)).
4369
- "nextRecurrence": "2020-02-20 00:00:00", # Optional. The next time
4370
- the grant will recurr.
4371
- "priority": 1, # Optional. Default value is 1. The priority of the
4372
- grant. Grants with higher priority are applied first. Priority is a positive
4373
- decimal numbers. With lower numbers indicating higher importance. For
4374
- example, a priority of 1 is more urgent than a priority of 2. When there are
4375
- several grants available for the same subject, the system selects the grant
4376
- with the highest priority. In cases where grants share the same priority
4377
- level, the grant closest to its expiration will be used first. In the case of
4378
- two grants have identical priorities and expiration dates, the system will
4379
- use the grant that was created first.
4380
- "recurrence": {
4381
- "anchor": "2020-02-20 00:00:00", # An arbitrary anchor to
4382
- base the recurring period on. Required.
4383
- "interval": "str" # List of pre-defined periods that can be
4384
- used for recurring & scheduling. DAY: Every day WEEK: Every
4385
- week MONTH: Every month YEAR: Every year. Required. Known values
4386
- are: "DAY", "WEEK", "MONTH", and "YEAR".
4387
- },
4388
- "voidedAt": "2020-02-20 00:00:00" # Optional. The date and time the
4389
- grant was voided (cannot be used after that).
4390
- }
4391
- ]
4410
+ },
4411
+ "instance": "str" # Optional. A URI reference that identifies the specific
4412
+ occurrence of the problem.
4413
+ }
4392
4414
  """
4393
- error_map = {
4394
- 404: ResourceNotFoundError,
4395
- 409: ResourceExistsError,
4396
- 304: ResourceNotModifiedError,
4397
- 401: lambda response: ClientAuthenticationError(response=response),
4398
- }
4399
- error_map.update(kwargs.pop("error_map", {}) or {})
4400
-
4401
- _headers = kwargs.pop("headers", {}) or {}
4402
- _params = kwargs.pop("params", {}) or {}
4403
-
4404
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
4405
-
4406
- _request = build_list_entitlement_grants_request(
4407
- subject_id_or_key=subject_id_or_key,
4408
- entitlement_id_or_feature_key=entitlement_id_or_feature_key,
4409
- include_deleted=include_deleted,
4410
- order_by=order_by,
4411
- headers=_headers,
4412
- params=_params,
4413
- )
4414
- _request.url = self._client.format_url(_request.url)
4415
-
4416
- _stream = False
4417
- pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
4418
- _request, stream=_stream, **kwargs
4419
- )
4420
-
4421
- response = pipeline_response.http_response
4422
-
4423
- if response.status_code not in [200]:
4424
- if _stream:
4425
- response.read() # Load the body in memory and close the socket
4426
- map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
4427
- raise HttpResponseError(response=response)
4428
-
4429
- if response.content:
4430
- deserialized = response.json()
4431
- else:
4432
- deserialized = None
4433
-
4434
- if cls:
4435
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
4436
-
4437
- return cast(List[JSON], deserialized) # type: ignore
4438
4415
 
4439
4416
  @overload
4440
- def create_grant(
4417
+ def override_entitlement(
4441
4418
  self,
4442
4419
  subject_id_or_key: str,
4443
4420
  entitlement_id_or_feature_key: str,
4444
- body: JSON,
4421
+ body: IO[bytes],
4445
4422
  *,
4446
4423
  content_type: str = "application/json",
4447
4424
  **kwargs: Any
4448
4425
  ) -> JSON:
4449
- # pylint: disable=line-too-long
4450
- """Create a grant.
4451
-
4452
- Grants define a behavior of granting usage for a metered entitlement. They can have complicated
4453
- recurrence and rollover rules, thanks to which you can define a wide range of access patterns
4454
- with a single grant, in most cases you don't have to periodically create new grants. You can
4455
- only issue grants for active metered entitlements.
4456
-
4457
- A grant defines a given amount of usage that can be consumed for the entitlement. The grant is
4458
- in effect between its effective date and its expiration date. Specifying both is mandatory for
4459
- new grants.
4460
-
4461
- Grants have a priority setting that determines their order of use. Lower numbers have higher
4462
- priority, with 0 being the highest priority.
4463
-
4464
- Grants can have a recurrence setting intended to automate the manual reissuing of grants. For
4465
- example, a daily recurrence is equal to reissuing that same grant every day (ignoring rollover
4466
- settings).
4426
+ """Override an entitlement.
4467
4427
 
4468
- Rollover settings define what happens to the remaining balance of a grant at a reset.
4469
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
4428
+ Overriding an entitlement creates a new entitlement from the provided inputs and soft deletes
4429
+ the previous entitlement for the provided subject-feature pair. If the previous entitlement is
4430
+ already deleted or otherwise doesnt exist, the override will fail.
4470
4431
 
4471
- Grants cannot be changed once created, only deleted. This is to ensure that balance is
4472
- deterministic regardless of when it is queried.
4432
+ This endpoint is useful for upgrades, downgrades, or other changes to entitlements that require
4433
+ a new entitlement to be created with zero downtime.
4473
4434
 
4474
4435
  :param subject_id_or_key: A unique identifier for a subject. Required.
4475
4436
  :type subject_id_or_key: str
4476
4437
  :param entitlement_id_or_feature_key: The id of the entitlement or the key of the feature.
4477
4438
  Required.
4478
4439
  :type entitlement_id_or_feature_key: str
4479
- :param body: The grant to create. Required.
4480
- :type body: JSON
4481
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
4440
+ :param body: The entitlement to create. Required.
4441
+ :type body: IO[bytes]
4442
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
4482
4443
  Default value is "application/json".
4483
4444
  :paramtype content_type: str
4484
4445
  :return: JSON object
@@ -4488,22 +4449,348 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
4488
4449
  Example:
4489
4450
  .. code-block:: python
4490
4451
 
4491
- # JSON input template you can fill out and use as your body input.
4492
- body = {
4493
- "amount": 0.0, # The amount to grant. Should be a positive number. Required.
4494
- "effectiveAt": "2020-02-20 00:00:00", # Effective date for grants and anchor
4495
- for recurring grants. Provided value will be ceiled to metering windowSize
4496
- (minute). Required.
4497
- "expiration": {
4498
- "count": 0, # The expiration period count like 12 months. Required.
4499
- "duration": "str" # The expiration period duration like month.
4500
- Required. Known values are: "HOUR", "DAY", "WEEK", "MONTH", and "YEAR".
4501
- },
4502
- "maxRolloverAmount": 0, # Optional. Default value is 0. Grants are rolled
4503
- over at reset, after which they can have a different balance compared to what
4504
- they had before the reset. Balance after the reset is calculated as:
4505
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
4506
- MinRolloverAmount)).
4452
+ # response body for status code(s): 409
4453
+ response == {
4454
+ "detail": "str", # A human-readable explanation specific to this occurrence
4455
+ of the problem. Required.
4456
+ "status": 0, # The HTTP status code generated by the origin server for this
4457
+ occurrence of the problem. Required.
4458
+ "title": "str", # A a short, human-readable summary of the problem type.
4459
+ Required.
4460
+ "type": "str", # Type contains a URI that identifies the problem type.
4461
+ Required.
4462
+ "extensions": {
4463
+ "conflictingEntityId": "str" # The id of the conflicting entity.
4464
+ Required.
4465
+ },
4466
+ "instance": "str" # Optional. A URI reference that identifies the specific
4467
+ occurrence of the problem.
4468
+ }
4469
+ """
4470
+
4471
+ @distributed_trace
4472
+ def override_entitlement(
4473
+ self, subject_id_or_key: str, entitlement_id_or_feature_key: str, body: Union[JSON, IO[bytes]], **kwargs: Any
4474
+ ) -> JSON:
4475
+ """Override an entitlement.
4476
+
4477
+ Overriding an entitlement creates a new entitlement from the provided inputs and soft deletes
4478
+ the previous entitlement for the provided subject-feature pair. If the previous entitlement is
4479
+ already deleted or otherwise doesnt exist, the override will fail.
4480
+
4481
+ This endpoint is useful for upgrades, downgrades, or other changes to entitlements that require
4482
+ a new entitlement to be created with zero downtime.
4483
+
4484
+ :param subject_id_or_key: A unique identifier for a subject. Required.
4485
+ :type subject_id_or_key: str
4486
+ :param entitlement_id_or_feature_key: The id of the entitlement or the key of the feature.
4487
+ Required.
4488
+ :type entitlement_id_or_feature_key: str
4489
+ :param body: The entitlement to create. Is either a JSON type or a IO[bytes] type. Required.
4490
+ :type body: JSON or IO[bytes]
4491
+ :return: JSON object
4492
+ :rtype: JSON
4493
+ :raises ~azure.core.exceptions.HttpResponseError:
4494
+
4495
+ Example:
4496
+ .. code-block:: python
4497
+
4498
+ # JSON input template you can fill out and use as your body input.
4499
+ body = {}
4500
+
4501
+ # response body for status code(s): 409
4502
+ response == {
4503
+ "detail": "str", # A human-readable explanation specific to this occurrence
4504
+ of the problem. Required.
4505
+ "status": 0, # The HTTP status code generated by the origin server for this
4506
+ occurrence of the problem. Required.
4507
+ "title": "str", # A a short, human-readable summary of the problem type.
4508
+ Required.
4509
+ "type": "str", # Type contains a URI that identifies the problem type.
4510
+ Required.
4511
+ "extensions": {
4512
+ "conflictingEntityId": "str" # The id of the conflicting entity.
4513
+ Required.
4514
+ },
4515
+ "instance": "str" # Optional. A URI reference that identifies the specific
4516
+ occurrence of the problem.
4517
+ }
4518
+ """
4519
+ error_map = {
4520
+ 409: ResourceExistsError,
4521
+ 304: ResourceNotModifiedError,
4522
+ 400: HttpResponseError,
4523
+ 401: lambda response: ClientAuthenticationError(response=response),
4524
+ 404: lambda response: ResourceNotFoundError(response=response),
4525
+ 501: HttpResponseError,
4526
+ }
4527
+ error_map.update(kwargs.pop("error_map", {}) or {})
4528
+
4529
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
4530
+ _params = kwargs.pop("params", {}) or {}
4531
+
4532
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
4533
+ cls: ClsType[JSON] = kwargs.pop("cls", None)
4534
+
4535
+ content_type = content_type or "application/json"
4536
+ _json = None
4537
+ _content = None
4538
+ if isinstance(body, (IOBase, bytes)):
4539
+ _content = body
4540
+ else:
4541
+ _json = body
4542
+
4543
+ _request = build_override_entitlement_request(
4544
+ subject_id_or_key=subject_id_or_key,
4545
+ entitlement_id_or_feature_key=entitlement_id_or_feature_key,
4546
+ content_type=content_type,
4547
+ json=_json,
4548
+ content=_content,
4549
+ headers=_headers,
4550
+ params=_params,
4551
+ )
4552
+ _request.url = self._client.format_url(_request.url)
4553
+
4554
+ _stream = False
4555
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
4556
+ _request, stream=_stream, **kwargs
4557
+ )
4558
+
4559
+ response = pipeline_response.http_response
4560
+
4561
+ if response.status_code not in [201, 409]:
4562
+ if _stream:
4563
+ response.read() # Load the body in memory and close the socket
4564
+ map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
4565
+ raise HttpResponseError(response=response)
4566
+
4567
+ if response.status_code == 201:
4568
+ if response.content:
4569
+ deserialized = response.json()
4570
+ else:
4571
+ deserialized = None
4572
+
4573
+ if response.status_code == 409:
4574
+ if response.content:
4575
+ deserialized = response.json()
4576
+ else:
4577
+ deserialized = None
4578
+
4579
+ if cls:
4580
+ return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
4581
+
4582
+ return cast(JSON, deserialized) # type: ignore
4583
+
4584
+ @distributed_trace
4585
+ def list_entitlement_grants(
4586
+ self,
4587
+ subject_id_or_key: str,
4588
+ entitlement_id_or_feature_key: str,
4589
+ *,
4590
+ include_deleted: bool = False,
4591
+ order_by: str = "updatedAt",
4592
+ **kwargs: Any
4593
+ ) -> List[JSON]:
4594
+ # pylint: disable=line-too-long
4595
+ """List grants for an entitlement.
4596
+
4597
+ List all grants issued for an entitlement. The entitlement can be defined either by its id or
4598
+ featureKey.
4599
+
4600
+ :param subject_id_or_key: A unique identifier for a subject. Required.
4601
+ :type subject_id_or_key: str
4602
+ :param entitlement_id_or_feature_key: The id of the entitlement or the key of the feature.
4603
+ Required.
4604
+ :type entitlement_id_or_feature_key: str
4605
+ :keyword include_deleted: Include deleted entries. Default value is False.
4606
+ :paramtype include_deleted: bool
4607
+ :keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
4608
+ Default value is "updatedAt".
4609
+ :paramtype order_by: str
4610
+ :return: list of JSON object
4611
+ :rtype: list[JSON]
4612
+ :raises ~azure.core.exceptions.HttpResponseError:
4613
+
4614
+ Example:
4615
+ .. code-block:: python
4616
+
4617
+ # response body for status code(s): 200
4618
+ response == [
4619
+ {
4620
+ "amount": 0.0, # The amount to grant. Should be a positive number.
4621
+ Required.
4622
+ "createdAt": "2020-02-20 00:00:00", # The date and time the resource
4623
+ was created. Required.
4624
+ "effectiveAt": "2020-02-20 00:00:00", # Effective date for grants
4625
+ and anchor for recurring grants. Provided value will be ceiled to metering
4626
+ windowSize (minute). Required.
4627
+ "entitlementId": "str", # The unique entitlement ULID that the grant
4628
+ is associated with. Required.
4629
+ "expiration": {
4630
+ "count": 0, # The expiration period count like 12 months.
4631
+ Required.
4632
+ "duration": "str" # The expiration period duration like
4633
+ month. Required. Known values are: "HOUR", "DAY", "WEEK", "MONTH", and
4634
+ "YEAR".
4635
+ },
4636
+ "id": "str", # Readonly unique ULID identifier. Required.
4637
+ "updatedAt": "2020-02-20 00:00:00", # The date and time the resource
4638
+ was last updated. The initial value is the same as createdAt. Required.
4639
+ "deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
4640
+ the resource was deleted.
4641
+ "expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date
4642
+ of the grant.
4643
+ "maxRolloverAmount": 0, # Optional. Default value is 0. Grants are
4644
+ rolled over at reset, after which they can have a different balance compared
4645
+ to what they had before the reset. Balance after the reset is calculated as:
4646
+ Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
4647
+ MinRolloverAmount)).
4648
+ "metadata": {
4649
+ "str": "str" # Optional. Dictionary of :code:`<string>`.
4650
+ },
4651
+ "minRolloverAmount": 0, # Optional. Default value is 0. Grants are
4652
+ rolled over at reset, after which they can have a different balance compared
4653
+ to what they had before the reset. Balance after the reset is calculated as:
4654
+ Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
4655
+ MinRolloverAmount)).
4656
+ "nextRecurrence": "2020-02-20 00:00:00", # Optional. The next time
4657
+ the grant will recurr.
4658
+ "priority": 1, # Optional. Default value is 1. The priority of the
4659
+ grant. Grants with higher priority are applied first. Priority is a positive
4660
+ decimal numbers. With lower numbers indicating higher importance. For
4661
+ example, a priority of 1 is more urgent than a priority of 2. When there are
4662
+ several grants available for the same subject, the system selects the grant
4663
+ with the highest priority. In cases where grants share the same priority
4664
+ level, the grant closest to its expiration will be used first. In the case of
4665
+ two grants have identical priorities and expiration dates, the system will
4666
+ use the grant that was created first.
4667
+ "recurrence": {
4668
+ "anchor": "2020-02-20 00:00:00", # An arbitrary anchor to
4669
+ base the recurring period on. Required.
4670
+ "interval": "str" # List of pre-defined periods that can be
4671
+ used for recurring & scheduling. DAY: Every day WEEK: Every
4672
+ week MONTH: Every month YEAR: Every year. Required. Known values
4673
+ are: "DAY", "WEEK", "MONTH", and "YEAR".
4674
+ },
4675
+ "voidedAt": "2020-02-20 00:00:00" # Optional. The date and time the
4676
+ grant was voided (cannot be used after that).
4677
+ }
4678
+ ]
4679
+ """
4680
+ error_map = {
4681
+ 404: ResourceNotFoundError,
4682
+ 409: ResourceExistsError,
4683
+ 304: ResourceNotModifiedError,
4684
+ 401: lambda response: ClientAuthenticationError(response=response),
4685
+ }
4686
+ error_map.update(kwargs.pop("error_map", {}) or {})
4687
+
4688
+ _headers = kwargs.pop("headers", {}) or {}
4689
+ _params = kwargs.pop("params", {}) or {}
4690
+
4691
+ cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
4692
+
4693
+ _request = build_list_entitlement_grants_request(
4694
+ subject_id_or_key=subject_id_or_key,
4695
+ entitlement_id_or_feature_key=entitlement_id_or_feature_key,
4696
+ include_deleted=include_deleted,
4697
+ order_by=order_by,
4698
+ headers=_headers,
4699
+ params=_params,
4700
+ )
4701
+ _request.url = self._client.format_url(_request.url)
4702
+
4703
+ _stream = False
4704
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
4705
+ _request, stream=_stream, **kwargs
4706
+ )
4707
+
4708
+ response = pipeline_response.http_response
4709
+
4710
+ if response.status_code not in [200]:
4711
+ if _stream:
4712
+ response.read() # Load the body in memory and close the socket
4713
+ map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
4714
+ raise HttpResponseError(response=response)
4715
+
4716
+ if response.content:
4717
+ deserialized = response.json()
4718
+ else:
4719
+ deserialized = None
4720
+
4721
+ if cls:
4722
+ return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
4723
+
4724
+ return cast(List[JSON], deserialized) # type: ignore
4725
+
4726
+ @overload
4727
+ def create_grant(
4728
+ self,
4729
+ subject_id_or_key: str,
4730
+ entitlement_id_or_feature_key: str,
4731
+ body: JSON,
4732
+ *,
4733
+ content_type: str = "application/json",
4734
+ **kwargs: Any
4735
+ ) -> JSON:
4736
+ # pylint: disable=line-too-long
4737
+ """Create a grant.
4738
+
4739
+ Grants define a behavior of granting usage for a metered entitlement. They can have complicated
4740
+ recurrence and rollover rules, thanks to which you can define a wide range of access patterns
4741
+ with a single grant, in most cases you don't have to periodically create new grants. You can
4742
+ only issue grants for active metered entitlements.
4743
+
4744
+ A grant defines a given amount of usage that can be consumed for the entitlement. The grant is
4745
+ in effect between its effective date and its expiration date. Specifying both is mandatory for
4746
+ new grants.
4747
+
4748
+ Grants have a priority setting that determines their order of use. Lower numbers have higher
4749
+ priority, with 0 being the highest priority.
4750
+
4751
+ Grants can have a recurrence setting intended to automate the manual reissuing of grants. For
4752
+ example, a daily recurrence is equal to reissuing that same grant every day (ignoring rollover
4753
+ settings).
4754
+
4755
+ Rollover settings define what happens to the remaining balance of a grant at a reset.
4756
+ Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
4757
+
4758
+ Grants cannot be changed once created, only deleted. This is to ensure that balance is
4759
+ deterministic regardless of when it is queried.
4760
+
4761
+ :param subject_id_or_key: A unique identifier for a subject. Required.
4762
+ :type subject_id_or_key: str
4763
+ :param entitlement_id_or_feature_key: The id of the entitlement or the key of the feature.
4764
+ Required.
4765
+ :type entitlement_id_or_feature_key: str
4766
+ :param body: The grant to create. Required.
4767
+ :type body: JSON
4768
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
4769
+ Default value is "application/json".
4770
+ :paramtype content_type: str
4771
+ :return: JSON object
4772
+ :rtype: JSON
4773
+ :raises ~azure.core.exceptions.HttpResponseError:
4774
+
4775
+ Example:
4776
+ .. code-block:: python
4777
+
4778
+ # JSON input template you can fill out and use as your body input.
4779
+ body = {
4780
+ "amount": 0.0, # The amount to grant. Should be a positive number. Required.
4781
+ "effectiveAt": "2020-02-20 00:00:00", # Effective date for grants and anchor
4782
+ for recurring grants. Provided value will be ceiled to metering windowSize
4783
+ (minute). Required.
4784
+ "expiration": {
4785
+ "count": 0, # The expiration period count like 12 months. Required.
4786
+ "duration": "str" # The expiration period duration like month.
4787
+ Required. Known values are: "HOUR", "DAY", "WEEK", "MONTH", and "YEAR".
4788
+ },
4789
+ "maxRolloverAmount": 0, # Optional. Default value is 0. Grants are rolled
4790
+ over at reset, after which they can have a different balance compared to what
4791
+ they had before the reset. Balance after the reset is calculated as:
4792
+ Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
4793
+ MinRolloverAmount)).
4507
4794
  "metadata": {
4508
4795
  "str": "str" # Optional. Dictionary of :code:`<string>`.
4509
4796
  },
@@ -6332,14 +6619,308 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6332
6619
  """
6333
6620
 
6334
6621
  @distributed_trace
6335
- def update_notification_rule(self, rule_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
6336
- """Update a notification rule.
6622
+ def update_notification_rule(self, rule_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
6623
+ """Update a notification rule.
6624
+
6625
+ Update a notification rule by id.
6626
+
6627
+ :param rule_id: A unique ULID identifier for a notification rule. Required.
6628
+ :type rule_id: str
6629
+ :param body: The notification rule to update. Is either a JSON type or a IO[bytes] type.
6630
+ Required.
6631
+ :type body: JSON or IO[bytes]
6632
+ :return: JSON object
6633
+ :rtype: JSON
6634
+ :raises ~azure.core.exceptions.HttpResponseError:
6635
+
6636
+ Example:
6637
+ .. code-block:: python
6638
+
6639
+ # JSON input template you can fill out and use as your body input.
6640
+ body = {}
6641
+ """
6642
+ error_map = {
6643
+ 409: ResourceExistsError,
6644
+ 304: ResourceNotModifiedError,
6645
+ 401: lambda response: ClientAuthenticationError(response=response),
6646
+ 404: lambda response: ResourceNotFoundError(response=response),
6647
+ }
6648
+ error_map.update(kwargs.pop("error_map", {}) or {})
6649
+
6650
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
6651
+ _params = kwargs.pop("params", {}) or {}
6652
+
6653
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
6654
+ cls: ClsType[JSON] = kwargs.pop("cls", None)
6655
+
6656
+ content_type = content_type or "application/json"
6657
+ _json = None
6658
+ _content = None
6659
+ if isinstance(body, (IOBase, bytes)):
6660
+ _content = body
6661
+ else:
6662
+ _json = body
6663
+
6664
+ _request = build_update_notification_rule_request(
6665
+ rule_id=rule_id,
6666
+ content_type=content_type,
6667
+ json=_json,
6668
+ content=_content,
6669
+ headers=_headers,
6670
+ params=_params,
6671
+ )
6672
+ _request.url = self._client.format_url(_request.url)
6673
+
6674
+ _stream = False
6675
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
6676
+ _request, stream=_stream, **kwargs
6677
+ )
6678
+
6679
+ response = pipeline_response.http_response
6680
+
6681
+ if response.status_code not in [200]:
6682
+ if _stream:
6683
+ response.read() # Load the body in memory and close the socket
6684
+ map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
6685
+ raise HttpResponseError(response=response)
6686
+
6687
+ if response.content:
6688
+ deserialized = response.json()
6689
+ else:
6690
+ deserialized = None
6691
+
6692
+ if cls:
6693
+ return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
6694
+
6695
+ return cast(JSON, deserialized) # type: ignore
6696
+
6697
+ @distributed_trace
6698
+ def list_notification_events(
6699
+ self,
6700
+ *,
6701
+ page: int = 1,
6702
+ page_size: int = 100,
6703
+ order_by: str = "createdAt",
6704
+ order: str = "ASC",
6705
+ from_parameter: Optional[datetime.datetime] = None,
6706
+ to: Optional[datetime.datetime] = None,
6707
+ feature: Optional[List[str]] = None,
6708
+ subject: Optional[List[str]] = None,
6709
+ **kwargs: Any
6710
+ ) -> JSON:
6711
+ """List notification evens.
6712
+
6713
+ List all notification events.
6714
+
6715
+ :keyword page: Page number to return. Default value is 1.
6716
+ :paramtype page: int
6717
+ :keyword page_size: Number of entries to return per page. Default value is 100.
6718
+ :paramtype page_size: int
6719
+ :keyword order_by: Order by field. Known values are: "id" and "createdAt". Default value is
6720
+ "createdAt".
6721
+ :paramtype order_by: str
6722
+ :keyword order: Order by field.
6723
+
6724
+ Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
6725
+ :paramtype order: str
6726
+ :keyword from_parameter: Start date-time in RFC 3339 format.
6727
+ Inclusive. Default value is None.
6728
+ :paramtype from_parameter: ~datetime.datetime
6729
+ :keyword to: End date-time in RFC 3339 format.
6730
+ Inclusive. Default value is None.
6731
+ :paramtype to: ~datetime.datetime
6732
+ :keyword feature: Filtering by multiple features.
6733
+
6734
+ Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
6735
+ :paramtype feature: list[str]
6736
+ :keyword subject: Filtering by multiple subjects.
6737
+
6738
+ Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
6739
+ :paramtype subject: list[str]
6740
+ :return: JSON object
6741
+ :rtype: JSON
6742
+ :raises ~azure.core.exceptions.HttpResponseError:
6743
+
6744
+ Example:
6745
+ .. code-block:: python
6746
+
6747
+ # response body for status code(s): 200
6748
+ response == {
6749
+ "items": [
6750
+ {
6751
+ "createdAt": "2020-02-20 00:00:00", # Timestamp when the
6752
+ notification event was created. Required.
6753
+ "deliveryStatus": [
6754
+ {
6755
+ "channel": {
6756
+ "id": "str", # A unique identifier
6757
+ for the notification channel. Required.
6758
+ "type": "str" # The type of the
6759
+ notification channel. Required. "WEBHOOK"
6760
+ },
6761
+ "state": "str", # Required. Known values
6762
+ are: "SUCCESS", "FAILED", "SENDING", and "PENDING".
6763
+ "updatedAt": "2020-02-20 00:00:00", #
6764
+ Required.
6765
+ "reason": "str" # Optional. The delivery
6766
+ status of the notification event. Required.
6767
+ }
6768
+ ],
6769
+ "id": "str", # A unique identifier for the notification
6770
+ event. Required.
6771
+ "payload": {},
6772
+ "rule": {},
6773
+ "type": "str" # The type of the notification event.
6774
+ Required. "entitlements.balance.threshold"
6775
+ }
6776
+ ],
6777
+ "page": 0, # Current page number. Required.
6778
+ "pageSize": 0, # Number of rules per page. Required.
6779
+ "totalCount": 0 # Total number of rules. Required.
6780
+ }
6781
+ """
6782
+ error_map = {
6783
+ 404: ResourceNotFoundError,
6784
+ 409: ResourceExistsError,
6785
+ 304: ResourceNotModifiedError,
6786
+ 400: HttpResponseError,
6787
+ 401: lambda response: ClientAuthenticationError(response=response),
6788
+ }
6789
+ error_map.update(kwargs.pop("error_map", {}) or {})
6790
+
6791
+ _headers = kwargs.pop("headers", {}) or {}
6792
+ _params = kwargs.pop("params", {}) or {}
6793
+
6794
+ cls: ClsType[JSON] = kwargs.pop("cls", None)
6795
+
6796
+ _request = build_list_notification_events_request(
6797
+ page=page,
6798
+ page_size=page_size,
6799
+ order_by=order_by,
6800
+ order=order,
6801
+ from_parameter=from_parameter,
6802
+ to=to,
6803
+ feature=feature,
6804
+ subject=subject,
6805
+ headers=_headers,
6806
+ params=_params,
6807
+ )
6808
+ _request.url = self._client.format_url(_request.url)
6809
+
6810
+ _stream = False
6811
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
6812
+ _request, stream=_stream, **kwargs
6813
+ )
6814
+
6815
+ response = pipeline_response.http_response
6816
+
6817
+ if response.status_code not in [200]:
6818
+ if _stream:
6819
+ response.read() # Load the body in memory and close the socket
6820
+ map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
6821
+ raise HttpResponseError(response=response)
6822
+
6823
+ if response.content:
6824
+ deserialized = response.json()
6825
+ else:
6826
+ deserialized = None
6827
+
6828
+ if cls:
6829
+ return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
6830
+
6831
+ return cast(JSON, deserialized) # type: ignore
6832
+
6833
+ @overload
6834
+ def create_notification_event(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
6835
+ """Create a notification event.
6836
+
6837
+ Create a new notification event.
6838
+
6839
+ :param body: The notification event to create. Required.
6840
+ :type body: JSON
6841
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
6842
+ Default value is "application/json".
6843
+ :paramtype content_type: str
6844
+ :return: JSON object
6845
+ :rtype: JSON
6846
+ :raises ~azure.core.exceptions.HttpResponseError:
6847
+
6848
+ Example:
6849
+ .. code-block:: python
6850
+
6851
+ # JSON input template you can fill out and use as your body input.
6852
+ body = {
6853
+ "payload": {},
6854
+ "ruleId": "str", # Required.
6855
+ "type": "str" # The type of the notification event. Required.
6856
+ "entitlements.balance.threshold"
6857
+ }
6858
+
6859
+ # response body for status code(s): 409
6860
+ response == {
6861
+ "detail": "str", # A human-readable explanation specific to this occurrence
6862
+ of the problem. Required.
6863
+ "status": 0, # The HTTP status code generated by the origin server for this
6864
+ occurrence of the problem. Required.
6865
+ "title": "str", # A a short, human-readable summary of the problem type.
6866
+ Required.
6867
+ "type": "str", # Type contains a URI that identifies the problem type.
6868
+ Required.
6869
+ "extensions": {
6870
+ "conflictingEntityId": "str" # The id of the conflicting entity.
6871
+ Required.
6872
+ },
6873
+ "instance": "str" # Optional. A URI reference that identifies the specific
6874
+ occurrence of the problem.
6875
+ }
6876
+ """
6877
+
6878
+ @overload
6879
+ def create_notification_event(
6880
+ self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
6881
+ ) -> JSON:
6882
+ """Create a notification event.
6883
+
6884
+ Create a new notification event.
6885
+
6886
+ :param body: The notification event to create. Required.
6887
+ :type body: IO[bytes]
6888
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
6889
+ Default value is "application/json".
6890
+ :paramtype content_type: str
6891
+ :return: JSON object
6892
+ :rtype: JSON
6893
+ :raises ~azure.core.exceptions.HttpResponseError:
6894
+
6895
+ Example:
6896
+ .. code-block:: python
6897
+
6898
+ # response body for status code(s): 409
6899
+ response == {
6900
+ "detail": "str", # A human-readable explanation specific to this occurrence
6901
+ of the problem. Required.
6902
+ "status": 0, # The HTTP status code generated by the origin server for this
6903
+ occurrence of the problem. Required.
6904
+ "title": "str", # A a short, human-readable summary of the problem type.
6905
+ Required.
6906
+ "type": "str", # Type contains a URI that identifies the problem type.
6907
+ Required.
6908
+ "extensions": {
6909
+ "conflictingEntityId": "str" # The id of the conflicting entity.
6910
+ Required.
6911
+ },
6912
+ "instance": "str" # Optional. A URI reference that identifies the specific
6913
+ occurrence of the problem.
6914
+ }
6915
+ """
6916
+
6917
+ @distributed_trace
6918
+ def create_notification_event(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
6919
+ """Create a notification event.
6337
6920
 
6338
- Update a notification rule by id.
6921
+ Create a new notification event.
6339
6922
 
6340
- :param rule_id: A unique ULID identifier for a notification rule. Required.
6341
- :type rule_id: str
6342
- :param body: The notification rule to update. Is either a JSON type or a IO[bytes] type.
6923
+ :param body: The notification event to create. Is either a JSON type or a IO[bytes] type.
6343
6924
  Required.
6344
6925
  :type body: JSON or IO[bytes]
6345
6926
  :return: JSON object
@@ -6350,13 +6931,38 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6350
6931
  .. code-block:: python
6351
6932
 
6352
6933
  # JSON input template you can fill out and use as your body input.
6353
- body = {}
6934
+ body = {
6935
+ "payload": {},
6936
+ "ruleId": "str", # Required.
6937
+ "type": "str" # The type of the notification event. Required.
6938
+ "entitlements.balance.threshold"
6939
+ }
6940
+
6941
+ # response body for status code(s): 409
6942
+ response == {
6943
+ "detail": "str", # A human-readable explanation specific to this occurrence
6944
+ of the problem. Required.
6945
+ "status": 0, # The HTTP status code generated by the origin server for this
6946
+ occurrence of the problem. Required.
6947
+ "title": "str", # A a short, human-readable summary of the problem type.
6948
+ Required.
6949
+ "type": "str", # Type contains a URI that identifies the problem type.
6950
+ Required.
6951
+ "extensions": {
6952
+ "conflictingEntityId": "str" # The id of the conflicting entity.
6953
+ Required.
6954
+ },
6955
+ "instance": "str" # Optional. A URI reference that identifies the specific
6956
+ occurrence of the problem.
6957
+ }
6354
6958
  """
6355
6959
  error_map = {
6960
+ 404: ResourceNotFoundError,
6356
6961
  409: ResourceExistsError,
6357
6962
  304: ResourceNotModifiedError,
6963
+ 400: HttpResponseError,
6358
6964
  401: lambda response: ClientAuthenticationError(response=response),
6359
- 404: lambda response: ResourceNotFoundError(response=response),
6965
+ 501: HttpResponseError,
6360
6966
  }
6361
6967
  error_map.update(kwargs.pop("error_map", {}) or {})
6362
6968
 
@@ -6374,8 +6980,7 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6374
6980
  else:
6375
6981
  _json = body
6376
6982
 
6377
- _request = build_update_notification_rule_request(
6378
- rule_id=rule_id,
6983
+ _request = build_create_notification_event_request(
6379
6984
  content_type=content_type,
6380
6985
  json=_json,
6381
6986
  content=_content,
@@ -6391,16 +6996,23 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6391
6996
 
6392
6997
  response = pipeline_response.http_response
6393
6998
 
6394
- if response.status_code not in [200]:
6999
+ if response.status_code not in [201, 409]:
6395
7000
  if _stream:
6396
7001
  response.read() # Load the body in memory and close the socket
6397
7002
  map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
6398
7003
  raise HttpResponseError(response=response)
6399
7004
 
6400
- if response.content:
6401
- deserialized = response.json()
6402
- else:
6403
- deserialized = None
7005
+ if response.status_code == 201:
7006
+ if response.content:
7007
+ deserialized = response.json()
7008
+ else:
7009
+ deserialized = None
7010
+
7011
+ if response.status_code == 409:
7012
+ if response.content:
7013
+ deserialized = response.json()
7014
+ else:
7015
+ deserialized = None
6404
7016
 
6405
7017
  if cls:
6406
7018
  return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
@@ -6408,92 +7020,22 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6408
7020
  return cast(JSON, deserialized) # type: ignore
6409
7021
 
6410
7022
  @distributed_trace
6411
- def list_notification_events(
6412
- self,
6413
- *,
6414
- page: int = 1,
6415
- page_size: int = 100,
6416
- order_by: str = "createdAt",
6417
- order: str = "ASC",
6418
- from_parameter: Optional[datetime.datetime] = None,
6419
- to: Optional[datetime.datetime] = None,
6420
- feature: Optional[List[str]] = None,
6421
- subject: Optional[List[str]] = None,
6422
- **kwargs: Any
6423
- ) -> JSON:
6424
- """List notification evens.
6425
-
6426
- List all notification events.
6427
-
6428
- :keyword page: Page number to return. Default value is 1.
6429
- :paramtype page: int
6430
- :keyword page_size: Number of entries to return per page. Default value is 100.
6431
- :paramtype page_size: int
6432
- :keyword order_by: Order by field. Known values are: "id" and "createdAt". Default value is
6433
- "createdAt".
6434
- :paramtype order_by: str
6435
- :keyword order: Order by field.
6436
-
6437
- Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
6438
- :paramtype order: str
6439
- :keyword from_parameter: Start date-time in RFC 3339 format.
6440
- Inclusive. Default value is None.
6441
- :paramtype from_parameter: ~datetime.datetime
6442
- :keyword to: End date-time in RFC 3339 format.
6443
- Inclusive. Default value is None.
6444
- :paramtype to: ~datetime.datetime
6445
- :keyword feature: Filtering by multiple features.
7023
+ def get_notification_event(self, event_id: str, **kwargs: Any) -> JSON:
7024
+ """Get notification event.
6446
7025
 
6447
- Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
6448
- :paramtype feature: list[str]
6449
- :keyword subject: Filtering by multiple subjects.
7026
+ Get a notification event by id.
6450
7027
 
6451
- Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
6452
- :paramtype subject: list[str]
7028
+ :param event_id: A unique ULID identifier for a notification event. Required.
7029
+ :type event_id: str
6453
7030
  :return: JSON object
6454
7031
  :rtype: JSON
6455
7032
  :raises ~azure.core.exceptions.HttpResponseError:
6456
-
6457
- Example:
6458
- .. code-block:: python
6459
-
6460
- # response body for status code(s): 200
6461
- response == {
6462
- "items": [
6463
- {
6464
- "createdAt": "2020-02-20 00:00:00", # Timestamp when the
6465
- notification event was created. Required.
6466
- "deliveryStatus": [
6467
- {
6468
- "channel": {
6469
- "id": "str", # A unique identifier
6470
- for the notification channel. Required.
6471
- "type": "str" # The type of the
6472
- notification channel. Required. "WEBHOOK"
6473
- },
6474
- "state": "str", # Required. Known values
6475
- are: "SUCCESS", "FAILED", and "SENDING".
6476
- "updatedAt": "2020-02-20 00:00:00" #
6477
- Required.
6478
- }
6479
- ],
6480
- "id": "str", # A unique identifier for the notification
6481
- event. Required.
6482
- "payload": {},
6483
- "rule": {}
6484
- }
6485
- ],
6486
- "page": 0, # Current page number. Required.
6487
- "pageSize": 0, # Number of rules per page. Required.
6488
- "totalCount": 0 # Total number of rules. Required.
6489
- }
6490
7033
  """
6491
7034
  error_map = {
6492
- 404: ResourceNotFoundError,
6493
7035
  409: ResourceExistsError,
6494
7036
  304: ResourceNotModifiedError,
6495
- 400: HttpResponseError,
6496
7037
  401: lambda response: ClientAuthenticationError(response=response),
7038
+ 404: lambda response: ResourceNotFoundError(response=response),
6497
7039
  }
6498
7040
  error_map.update(kwargs.pop("error_map", {}) or {})
6499
7041
 
@@ -6502,15 +7044,8 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6502
7044
 
6503
7045
  cls: ClsType[JSON] = kwargs.pop("cls", None)
6504
7046
 
6505
- _request = build_list_notification_events_request(
6506
- page=page,
6507
- page_size=page_size,
6508
- order_by=order_by,
6509
- order=order,
6510
- from_parameter=from_parameter,
6511
- to=to,
6512
- feature=feature,
6513
- subject=subject,
7047
+ _request = build_get_notification_event_request(
7048
+ event_id=event_id,
6514
7049
  headers=_headers,
6515
7050
  params=_params,
6516
7051
  )
@@ -6539,33 +7074,114 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6539
7074
 
6540
7075
  return cast(JSON, deserialized) # type: ignore
6541
7076
 
7077
+ @overload
7078
+ def receive_svix_operational_event( # pylint: disable=inconsistent-return-statements
7079
+ self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
7080
+ ) -> None:
7081
+ # pylint: disable=line-too-long
7082
+ """Receive Svix operational events.
7083
+
7084
+ Callback endpoint used by Svix to notify about operational events.
7085
+
7086
+ :param body: The operational event. Required.
7087
+ :type body: JSON
7088
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
7089
+ Default value is "application/json".
7090
+ :paramtype content_type: str
7091
+ :return: None
7092
+ :rtype: None
7093
+ :raises ~azure.core.exceptions.HttpResponseError:
7094
+
7095
+ Example:
7096
+ .. code-block:: python
7097
+
7098
+ # JSON input template you can fill out and use as your body input.
7099
+ body = {
7100
+ "data": {
7101
+ "str": {} # Dictionary of :code:`<any>`. Required.
7102
+ },
7103
+ "type": "str" # Required. Known values are: "endpoint.created",
7104
+ "endpoint.deleted", "endpoint.disabled", "endpoint.updated",
7105
+ "message.attempt.exhausted", "message.attempt.failing", and
7106
+ "message.attempt.recovered".
7107
+ }
7108
+ """
7109
+
7110
+ @overload
7111
+ def receive_svix_operational_event( # pylint: disable=inconsistent-return-statements
7112
+ self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
7113
+ ) -> None:
7114
+ """Receive Svix operational events.
7115
+
7116
+ Callback endpoint used by Svix to notify about operational events.
7117
+
7118
+ :param body: The operational event. Required.
7119
+ :type body: IO[bytes]
7120
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
7121
+ Default value is "application/json".
7122
+ :paramtype content_type: str
7123
+ :return: None
7124
+ :rtype: None
7125
+ :raises ~azure.core.exceptions.HttpResponseError:
7126
+ """
7127
+
6542
7128
  @distributed_trace
6543
- def get_notification_event(self, event_id: str, **kwargs: Any) -> JSON:
6544
- """Get notification event.
7129
+ def receive_svix_operational_event( # pylint: disable=inconsistent-return-statements
7130
+ self, body: Union[JSON, IO[bytes]], **kwargs: Any
7131
+ ) -> None:
7132
+ # pylint: disable=line-too-long
7133
+ """Receive Svix operational events.
6545
7134
 
6546
- Get a notification event by id.
7135
+ Callback endpoint used by Svix to notify about operational events.
6547
7136
 
6548
- :param event_id: A unique ULID identifier for a notification event. Required.
6549
- :type event_id: str
6550
- :return: JSON object
6551
- :rtype: JSON
7137
+ :param body: The operational event. Is either a JSON type or a IO[bytes] type. Required.
7138
+ :type body: JSON or IO[bytes]
7139
+ :return: None
7140
+ :rtype: None
6552
7141
  :raises ~azure.core.exceptions.HttpResponseError:
7142
+
7143
+ Example:
7144
+ .. code-block:: python
7145
+
7146
+ # JSON input template you can fill out and use as your body input.
7147
+ body = {
7148
+ "data": {
7149
+ "str": {} # Dictionary of :code:`<any>`. Required.
7150
+ },
7151
+ "type": "str" # Required. Known values are: "endpoint.created",
7152
+ "endpoint.deleted", "endpoint.disabled", "endpoint.updated",
7153
+ "message.attempt.exhausted", "message.attempt.failing", and
7154
+ "message.attempt.recovered".
7155
+ }
6553
7156
  """
6554
7157
  error_map = {
7158
+ 404: ResourceNotFoundError,
6555
7159
  409: ResourceExistsError,
6556
7160
  304: ResourceNotModifiedError,
7161
+ 400: HttpResponseError,
6557
7162
  401: lambda response: ClientAuthenticationError(response=response),
6558
- 404: lambda response: ResourceNotFoundError(response=response),
7163
+ 501: HttpResponseError,
6559
7164
  }
6560
7165
  error_map.update(kwargs.pop("error_map", {}) or {})
6561
7166
 
6562
- _headers = kwargs.pop("headers", {}) or {}
7167
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
6563
7168
  _params = kwargs.pop("params", {}) or {}
6564
7169
 
6565
- cls: ClsType[JSON] = kwargs.pop("cls", None)
7170
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
7171
+ cls: ClsType[None] = kwargs.pop("cls", None)
6566
7172
 
6567
- _request = build_get_notification_event_request(
6568
- event_id=event_id,
7173
+ content_type = content_type or "application/json"
7174
+ _json = None
7175
+ _content = None
7176
+ if isinstance(body, (IOBase, bytes)):
7177
+ _content = body
7178
+ else:
7179
+ _json = body
7180
+
7181
+ _request = build_receive_svix_operational_event_request(
7182
+ content_type=content_type,
7183
+ json=_json,
7184
+ content=_content,
6569
7185
  headers=_headers,
6570
7186
  params=_params,
6571
7187
  )
@@ -6578,18 +7194,11 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
6578
7194
 
6579
7195
  response = pipeline_response.http_response
6580
7196
 
6581
- if response.status_code not in [200]:
7197
+ if response.status_code not in [204]:
6582
7198
  if _stream:
6583
7199
  response.read() # Load the body in memory and close the socket
6584
7200
  map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore
6585
7201
  raise HttpResponseError(response=response)
6586
7202
 
6587
- if response.content:
6588
- deserialized = response.json()
6589
- else:
6590
- deserialized = None
6591
-
6592
7203
  if cls:
6593
- return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore
6594
-
6595
- return cast(JSON, deserialized) # type: ignore
7204
+ return cls(pipeline_response, None, {}) # type: ignore