openmeter 1.0.0b122__tar.gz → 1.0.0b124__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of openmeter might be problematic. Click here for more details.

Files changed (21) hide show
  1. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/PKG-INFO +1 -1
  2. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/pyproject.toml +1 -1
  3. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_operations/_operations.py +169 -137
  4. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/_operations/_operations.py +107 -134
  5. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/README.md +0 -0
  6. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/__init__.py +0 -0
  7. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_client.py +0 -0
  8. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_configuration.py +0 -0
  9. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_operations/__init__.py +0 -0
  10. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_operations/_patch.py +0 -0
  11. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_patch.py +0 -0
  12. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_serialization.py +0 -0
  13. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/_vendor.py +0 -0
  14. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/__init__.py +0 -0
  15. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/_client.py +0 -0
  16. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/_configuration.py +0 -0
  17. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/_operations/__init__.py +0 -0
  18. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/_operations/_patch.py +0 -0
  19. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/_patch.py +0 -0
  20. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/aio/_vendor.py +0 -0
  21. {openmeter-1.0.0b122 → openmeter-1.0.0b124}/src/openmeter/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openmeter
3
- Version: 1.0.0b122
3
+ Version: 1.0.0b124
4
4
  Summary: Client for OpenMeter: Real-Time and Scalable Usage Metering
5
5
  Home-page: https://openmeter.io
6
6
  License: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "openmeter"
3
- version = "v1.0.0-beta.122"
3
+ version = "v1.0.0-beta.124"
4
4
  description = "Client for OpenMeter: Real-Time and Scalable Usage Metering"
5
5
  authors = ["Andras Toth <4157749+tothandras@users.noreply.github.com>"]
6
6
  license = "Apache-2.0"
@@ -385,7 +385,17 @@ def build_query_portal_meter_request(
385
385
 
386
386
 
387
387
  def build_list_entitlements_request(
388
- *, limit: int = 1000, offset: int = 0, order_by: str = "createdAt", **kwargs: Any
388
+ *,
389
+ page: int = 1,
390
+ page_size: int = 100,
391
+ limit: int = 1000,
392
+ offset: int = 0,
393
+ subject: Optional[List[str]] = None,
394
+ feature: Optional[List[str]] = None,
395
+ entitlement_type: Optional[List[str]] = None,
396
+ order: str = "ASC",
397
+ order_by: str = "createdAt",
398
+ **kwargs: Any
389
399
  ) -> HttpRequest:
390
400
  _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
391
401
  _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
@@ -396,10 +406,22 @@ def build_list_entitlements_request(
396
406
  _url = "/api/v1/entitlements"
397
407
 
398
408
  # Construct parameters
409
+ if page is not None:
410
+ _params["page"] = _SERIALIZER.query("page", page, "int", minimum=1)
411
+ if page_size is not None:
412
+ _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int", maximum=1000, minimum=1)
399
413
  if limit is not None:
400
414
  _params["limit"] = _SERIALIZER.query("limit", limit, "int", maximum=1000, minimum=1)
401
415
  if offset is not None:
402
416
  _params["offset"] = _SERIALIZER.query("offset", offset, "int", minimum=0)
417
+ if subject is not None:
418
+ _params["subject"] = _SERIALIZER.query("subject", subject, "[str]")
419
+ if feature is not None:
420
+ _params["feature"] = _SERIALIZER.query("feature", feature, "[str]")
421
+ if entitlement_type is not None:
422
+ _params["entitlementType"] = _SERIALIZER.query("entitlement_type", entitlement_type, "[str]")
423
+ if order is not None:
424
+ _params["order"] = _SERIALIZER.query("order", order, "str")
403
425
  if order_by is not None:
404
426
  _params["orderBy"] = _SERIALIZER.query("order_by", order_by, "str")
405
427
 
@@ -410,7 +432,16 @@ def build_list_entitlements_request(
410
432
 
411
433
 
412
434
  def build_list_features_request(
413
- *, limit: int = 1000, offset: int = 0, order_by: str = "updatedAt", include_archived: bool = False, **kwargs: Any
435
+ *,
436
+ page: int = 1,
437
+ page_size: int = 100,
438
+ limit: int = 1000,
439
+ offset: int = 0,
440
+ meter_slug: Optional[List[str]] = None,
441
+ order: str = "ASC",
442
+ order_by: str = "updatedAt",
443
+ include_archived: bool = False,
444
+ **kwargs: Any
414
445
  ) -> HttpRequest:
415
446
  _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
416
447
  _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
@@ -421,10 +452,18 @@ def build_list_features_request(
421
452
  _url = "/api/v1/features"
422
453
 
423
454
  # Construct parameters
455
+ if page is not None:
456
+ _params["page"] = _SERIALIZER.query("page", page, "int", minimum=1)
457
+ if page_size is not None:
458
+ _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int", maximum=1000, minimum=1)
424
459
  if limit is not None:
425
460
  _params["limit"] = _SERIALIZER.query("limit", limit, "int", maximum=1000, minimum=1)
426
461
  if offset is not None:
427
462
  _params["offset"] = _SERIALIZER.query("offset", offset, "int", minimum=0)
463
+ if meter_slug is not None:
464
+ _params["meterSlug"] = _SERIALIZER.query("meter_slug", meter_slug, "[str]")
465
+ if order is not None:
466
+ _params["order"] = _SERIALIZER.query("order", order, "str")
428
467
  if order_by is not None:
429
468
  _params["orderBy"] = _SERIALIZER.query("order_by", order_by, "str")
430
469
  if include_archived is not None:
@@ -492,7 +531,17 @@ def build_delete_feature_request(feature_id: str, **kwargs: Any) -> HttpRequest:
492
531
 
493
532
 
494
533
  def build_list_grants_request(
495
- *, limit: int = 1000, offset: int = 0, order_by: str = "updatedAt", include_deleted: bool = False, **kwargs: Any
534
+ *,
535
+ page: int = 1,
536
+ page_size: int = 100,
537
+ limit: int = 1000,
538
+ offset: int = 0,
539
+ subject: Optional[List[str]] = None,
540
+ feature: Optional[List[str]] = None,
541
+ order: str = "ASC",
542
+ order_by: str = "updatedAt",
543
+ include_deleted: bool = False,
544
+ **kwargs: Any
496
545
  ) -> HttpRequest:
497
546
  _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
498
547
  _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
@@ -503,10 +552,20 @@ def build_list_grants_request(
503
552
  _url = "/api/v1/grants"
504
553
 
505
554
  # Construct parameters
555
+ if page is not None:
556
+ _params["page"] = _SERIALIZER.query("page", page, "int", minimum=1)
557
+ if page_size is not None:
558
+ _params["pageSize"] = _SERIALIZER.query("page_size", page_size, "int", maximum=1000, minimum=1)
506
559
  if limit is not None:
507
560
  _params["limit"] = _SERIALIZER.query("limit", limit, "int", maximum=1000, minimum=1)
508
561
  if offset is not None:
509
562
  _params["offset"] = _SERIALIZER.query("offset", offset, "int", minimum=0)
563
+ if subject is not None:
564
+ _params["subject"] = _SERIALIZER.query("subject", subject, "[str]")
565
+ if feature is not None:
566
+ _params["feature"] = _SERIALIZER.query("feature", feature, "[str]")
567
+ if order is not None:
568
+ _params["order"] = _SERIALIZER.query("order", order, "str")
510
569
  if order_by is not None:
511
570
  _params["orderBy"] = _SERIALIZER.query("order_by", order_by, "str")
512
571
  if include_deleted is not None:
@@ -2889,31 +2948,55 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2889
2948
 
2890
2949
  @distributed_trace
2891
2950
  def list_entitlements(
2892
- self, *, limit: int = 1000, offset: int = 0, order_by: str = "createdAt", **kwargs: Any
2893
- ) -> List[JSON]:
2951
+ self,
2952
+ *,
2953
+ page: int = 1,
2954
+ page_size: int = 100,
2955
+ limit: int = 1000,
2956
+ offset: int = 0,
2957
+ subject: Optional[List[str]] = None,
2958
+ feature: Optional[List[str]] = None,
2959
+ entitlement_type: Optional[List[str]] = None,
2960
+ order: str = "ASC",
2961
+ order_by: str = "createdAt",
2962
+ **kwargs: Any
2963
+ ) -> Any:
2894
2964
  """List entitlements.
2895
2965
 
2896
2966
  List all entitlements regardless of subject. This endpoint is intended for administrative
2897
2967
  purposes.
2968
+ If page is provided that takes precedence and the paginated response is returned.
2898
2969
 
2970
+ :keyword page: Page number to return. Default value is 1.
2971
+ :paramtype page: int
2972
+ :keyword page_size: Number of entries to return per page. Default value is 100.
2973
+ :paramtype page_size: int
2899
2974
  :keyword limit: Number of entries to return. Default value is 1000.
2900
2975
  :paramtype limit: int
2901
2976
  :keyword offset: Number of entries to skip. Default value is 0.
2902
2977
  :paramtype offset: int
2978
+ :keyword subject: Filtering by multiple subjects.
2979
+
2980
+ Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
2981
+ :paramtype subject: list[str]
2982
+ :keyword feature: Filtering by multiple features.
2983
+
2984
+ Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
2985
+ :paramtype feature: list[str]
2986
+ :keyword entitlement_type: Filtering by multiple entitlement types.
2987
+
2988
+ Usage: ``?entitlementType=metered&entitlementType=static``. Default value is None.
2989
+ :paramtype entitlement_type: list[str]
2990
+ :keyword order: Order by field.
2991
+
2992
+ Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
2993
+ :paramtype order: str
2903
2994
  :keyword order_by: Order by field. Known values are: "createdAt" and "updatedAt". Default value
2904
2995
  is "createdAt".
2905
2996
  :paramtype order_by: str
2906
- :return: list of JSON object
2907
- :rtype: list[JSON]
2997
+ :return: any
2998
+ :rtype: any
2908
2999
  :raises ~azure.core.exceptions.HttpResponseError:
2909
-
2910
- Example:
2911
- .. code-block:: python
2912
-
2913
- # response body for status code(s): 200
2914
- response == [
2915
- {}
2916
- ]
2917
3000
  """
2918
3001
  error_map = {
2919
3002
  404: ResourceNotFoundError,
@@ -2927,11 +3010,17 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2927
3010
  _headers = kwargs.pop("headers", {}) or {}
2928
3011
  _params = kwargs.pop("params", {}) or {}
2929
3012
 
2930
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
3013
+ cls: ClsType[Any] = kwargs.pop("cls", None)
2931
3014
 
2932
3015
  _request = build_list_entitlements_request(
3016
+ page=page,
3017
+ page_size=page_size,
2933
3018
  limit=limit,
2934
3019
  offset=offset,
3020
+ subject=subject,
3021
+ feature=feature,
3022
+ entitlement_type=entitlement_type,
3023
+ order=order,
2935
3024
  order_by=order_by,
2936
3025
  headers=_headers,
2937
3026
  params=_params,
@@ -2957,75 +3046,53 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2957
3046
  deserialized = None
2958
3047
 
2959
3048
  if cls:
2960
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
3049
+ return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
2961
3050
 
2962
- return cast(List[JSON], deserialized) # type: ignore
3051
+ return cast(Any, deserialized) # type: ignore
2963
3052
 
2964
3053
  @distributed_trace
2965
3054
  def list_features(
2966
3055
  self,
2967
3056
  *,
3057
+ page: int = 1,
3058
+ page_size: int = 100,
2968
3059
  limit: int = 1000,
2969
3060
  offset: int = 0,
3061
+ meter_slug: Optional[List[str]] = None,
3062
+ order: str = "ASC",
2970
3063
  order_by: str = "updatedAt",
2971
3064
  include_archived: bool = False,
2972
3065
  **kwargs: Any
2973
- ) -> List[JSON]:
2974
- # pylint: disable=line-too-long
3066
+ ) -> Any:
2975
3067
  """List features.
2976
3068
 
2977
- List all features.
3069
+ List all features. If page is provided that takes precedence and the paginated response is
3070
+ returned.
2978
3071
 
3072
+ :keyword page: Page number to return. Default value is 1.
3073
+ :paramtype page: int
3074
+ :keyword page_size: Number of entries to return per page. Default value is 100.
3075
+ :paramtype page_size: int
2979
3076
  :keyword limit: Number of entries to return. Default value is 1000.
2980
3077
  :paramtype limit: int
2981
3078
  :keyword offset: Number of entries to skip. Default value is 0.
2982
3079
  :paramtype offset: int
3080
+ :keyword meter_slug: Filtering by multiple meterSlug.
3081
+
3082
+ Usage: ``?meterSlug=meter-1&meterSlug=meter-2``. Default value is None.
3083
+ :paramtype meter_slug: list[str]
3084
+ :keyword order: Order by field.
3085
+
3086
+ Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
3087
+ :paramtype order: str
2983
3088
  :keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
2984
3089
  Default value is "updatedAt".
2985
3090
  :paramtype order_by: str
2986
3091
  :keyword include_archived: Include archived features. Default value is False.
2987
3092
  :paramtype include_archived: bool
2988
- :return: list of JSON object
2989
- :rtype: list[JSON]
3093
+ :return: any
3094
+ :rtype: any
2990
3095
  :raises ~azure.core.exceptions.HttpResponseError:
2991
-
2992
- Example:
2993
- .. code-block:: python
2994
-
2995
- # response body for status code(s): 200
2996
- response == [
2997
- {
2998
- "createdAt": "2020-02-20 00:00:00", # The date and time the resource
2999
- was created. Required.
3000
- "id": "str", # Readonly unique ULID identifier. Required.
3001
- "key": "str", # The key is an immutable unique identifier of the
3002
- feature used throughout the API, for example when interacting with a
3003
- subject's entitlements. The key has to be unique across all active features,
3004
- but archived features can share the same key. The key should consist of
3005
- lowercase alphanumeric characters and dashes. Required.
3006
- "name": "str", # The name of the feature. Required.
3007
- "updatedAt": "2020-02-20 00:00:00", # The date and time the resource
3008
- was last updated. The initial value is the same as createdAt. Required.
3009
- "archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is
3010
- archived, no new entitlements can be created for it.
3011
- "deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
3012
- the resource was deleted.
3013
- "metadata": {
3014
- "str": "str" # Optional. Additional metadata for the
3015
- feature, useful for syncing with external systems and annotating custom
3016
- fields.
3017
- },
3018
- "meterGroupByFilters": {
3019
- "str": "str" # Optional. Optional meter group by filters.
3020
- Useful if the meter scope is broader than what feature tracks. Example
3021
- scenario would be a meter tracking all token use with groupBy fields for
3022
- the model, then the feature could filter for model=gpt-4.
3023
- },
3024
- "meterSlug": "str" # Optional. The meter that the feature is
3025
- associated with and and based on which usage is calculated. The meter
3026
- selected must have SUM or COUNT aggregation.
3027
- }
3028
- ]
3029
3096
  """
3030
3097
  error_map = {
3031
3098
  404: ResourceNotFoundError,
@@ -3039,11 +3106,15 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
3039
3106
  _headers = kwargs.pop("headers", {}) or {}
3040
3107
  _params = kwargs.pop("params", {}) or {}
3041
3108
 
3042
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
3109
+ cls: ClsType[Any] = kwargs.pop("cls", None)
3043
3110
 
3044
3111
  _request = build_list_features_request(
3112
+ page=page,
3113
+ page_size=page_size,
3045
3114
  limit=limit,
3046
3115
  offset=offset,
3116
+ meter_slug=meter_slug,
3117
+ order=order,
3047
3118
  order_by=order_by,
3048
3119
  include_archived=include_archived,
3049
3120
  headers=_headers,
@@ -3070,9 +3141,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
3070
3141
  deserialized = None
3071
3142
 
3072
3143
  if cls:
3073
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
3144
+ return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
3074
3145
 
3075
- return cast(List[JSON], deserialized) # type: ignore
3146
+ return cast(Any, deserialized) # type: ignore
3076
3147
 
3077
3148
  @overload
3078
3149
  def create_feature(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
@@ -3492,97 +3563,53 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
3492
3563
  def list_grants(
3493
3564
  self,
3494
3565
  *,
3566
+ page: int = 1,
3567
+ page_size: int = 100,
3495
3568
  limit: int = 1000,
3496
3569
  offset: int = 0,
3570
+ subject: Optional[List[str]] = None,
3571
+ feature: Optional[List[str]] = None,
3572
+ order: str = "ASC",
3497
3573
  order_by: str = "updatedAt",
3498
3574
  include_deleted: bool = False,
3499
3575
  **kwargs: Any
3500
- ) -> List[JSON]:
3501
- # pylint: disable=line-too-long
3576
+ ) -> Any:
3502
3577
  """List grants.
3503
3578
 
3504
3579
  List all grants for all the subjects and entitlements. This endpoint is intended for
3505
3580
  administrative purposes only. To fetch the grants of a specific entitlement please use the
3506
3581
  /api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
3507
3582
 
3583
+ If page is provided that takes precedence and the paginated response is returned.
3584
+
3585
+ :keyword page: Page number to return. Default value is 1.
3586
+ :paramtype page: int
3587
+ :keyword page_size: Number of entries to return per page. Default value is 100.
3588
+ :paramtype page_size: int
3508
3589
  :keyword limit: Number of entries to return. Default value is 1000.
3509
3590
  :paramtype limit: int
3510
3591
  :keyword offset: Number of entries to skip. Default value is 0.
3511
3592
  :paramtype offset: int
3593
+ :keyword subject: Filtering by multiple subjects.
3594
+
3595
+ Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
3596
+ :paramtype subject: list[str]
3597
+ :keyword feature: Filtering by multiple features.
3598
+
3599
+ Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
3600
+ :paramtype feature: list[str]
3601
+ :keyword order: Order by field.
3602
+
3603
+ Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
3604
+ :paramtype order: str
3512
3605
  :keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
3513
3606
  Default value is "updatedAt".
3514
3607
  :paramtype order_by: str
3515
3608
  :keyword include_deleted: Include deleted entries. Default value is False.
3516
3609
  :paramtype include_deleted: bool
3517
- :return: list of JSON object
3518
- :rtype: list[JSON]
3610
+ :return: any
3611
+ :rtype: any
3519
3612
  :raises ~azure.core.exceptions.HttpResponseError:
3520
-
3521
- Example:
3522
- .. code-block:: python
3523
-
3524
- # response body for status code(s): 200
3525
- response == [
3526
- {
3527
- "amount": 0.0, # The amount to grant. Should be a positive number.
3528
- Required.
3529
- "createdAt": "2020-02-20 00:00:00", # The date and time the resource
3530
- was created. Required.
3531
- "effectiveAt": "2020-02-20 00:00:00", # Effective date for grants
3532
- and anchor for recurring grants. Provided value will be ceiled to metering
3533
- windowSize (minute). Required.
3534
- "entitlementId": "str", # The unique entitlement ULID that the grant
3535
- is associated with. Required.
3536
- "expiration": {
3537
- "count": 0, # The expiration period count like 12 months.
3538
- Required.
3539
- "duration": "str" # The expiration period duration like
3540
- month. Required. Known values are: "HOUR", "DAY", "WEEK", "MONTH", and
3541
- "YEAR".
3542
- },
3543
- "id": "str", # Readonly unique ULID identifier. Required.
3544
- "updatedAt": "2020-02-20 00:00:00", # The date and time the resource
3545
- was last updated. The initial value is the same as createdAt. Required.
3546
- "deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
3547
- the resource was deleted.
3548
- "expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date
3549
- of the grant.
3550
- "maxRolloverAmount": 0, # Optional. Default value is 0. Grants are
3551
- rolled over at reset, after which they can have a different balance compared
3552
- to what they had before the reset. Balance after the reset is calculated as:
3553
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
3554
- MinRolloverAmount)).
3555
- "metadata": {
3556
- "str": "str" # Optional. Dictionary of :code:`<string>`.
3557
- },
3558
- "minRolloverAmount": 0, # Optional. Default value is 0. Grants are
3559
- rolled over at reset, after which they can have a different balance compared
3560
- to what they had before the reset. Balance after the reset is calculated as:
3561
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
3562
- MinRolloverAmount)).
3563
- "nextRecurrence": "2020-02-20 00:00:00", # Optional. The next time
3564
- the grant will recurr.
3565
- "priority": 1, # Optional. Default value is 1. The priority of the
3566
- grant. Grants with higher priority are applied first. Priority is a positive
3567
- decimal numbers. With lower numbers indicating higher importance. For
3568
- example, a priority of 1 is more urgent than a priority of 2. When there are
3569
- several grants available for the same subject, the system selects the grant
3570
- with the highest priority. In cases where grants share the same priority
3571
- level, the grant closest to its expiration will be used first. In the case of
3572
- two grants have identical priorities and expiration dates, the system will
3573
- use the grant that was created first.
3574
- "recurrence": {
3575
- "anchor": "2020-02-20 00:00:00", # An arbitrary anchor to
3576
- base the recurring period on. Required.
3577
- "interval": "str" # List of pre-defined periods that can be
3578
- used for recurring & scheduling. DAY: Every day WEEK: Every
3579
- week MONTH: Every month YEAR: Every year. Required. Known values
3580
- are: "DAY", "WEEK", "MONTH", and "YEAR".
3581
- },
3582
- "voidedAt": "2020-02-20 00:00:00" # Optional. The date and time the
3583
- grant was voided (cannot be used after that).
3584
- }
3585
- ]
3586
3613
  """
3587
3614
  error_map = {
3588
3615
  404: ResourceNotFoundError,
@@ -3595,11 +3622,16 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
3595
3622
  _headers = kwargs.pop("headers", {}) or {}
3596
3623
  _params = kwargs.pop("params", {}) or {}
3597
3624
 
3598
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
3625
+ cls: ClsType[Any] = kwargs.pop("cls", None)
3599
3626
 
3600
3627
  _request = build_list_grants_request(
3628
+ page=page,
3629
+ page_size=page_size,
3601
3630
  limit=limit,
3602
3631
  offset=offset,
3632
+ subject=subject,
3633
+ feature=feature,
3634
+ order=order,
3603
3635
  order_by=order_by,
3604
3636
  include_deleted=include_deleted,
3605
3637
  headers=_headers,
@@ -3626,9 +3658,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
3626
3658
  deserialized = None
3627
3659
 
3628
3660
  if cls:
3629
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
3661
+ return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
3630
3662
 
3631
- return cast(List[JSON], deserialized) # type: ignore
3663
+ return cast(Any, deserialized) # type: ignore
3632
3664
 
3633
3665
  @distributed_trace
3634
3666
  def void_grant(self, grant_id: str, **kwargs: Any) -> Optional[JSON]:
@@ -1904,31 +1904,55 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
1904
1904
 
1905
1905
  @distributed_trace_async
1906
1906
  async def list_entitlements(
1907
- self, *, limit: int = 1000, offset: int = 0, order_by: str = "createdAt", **kwargs: Any
1908
- ) -> List[JSON]:
1907
+ self,
1908
+ *,
1909
+ page: int = 1,
1910
+ page_size: int = 100,
1911
+ limit: int = 1000,
1912
+ offset: int = 0,
1913
+ subject: Optional[List[str]] = None,
1914
+ feature: Optional[List[str]] = None,
1915
+ entitlement_type: Optional[List[str]] = None,
1916
+ order: str = "ASC",
1917
+ order_by: str = "createdAt",
1918
+ **kwargs: Any
1919
+ ) -> Any:
1909
1920
  """List entitlements.
1910
1921
 
1911
1922
  List all entitlements regardless of subject. This endpoint is intended for administrative
1912
1923
  purposes.
1924
+ If page is provided that takes precedence and the paginated response is returned.
1913
1925
 
1926
+ :keyword page: Page number to return. Default value is 1.
1927
+ :paramtype page: int
1928
+ :keyword page_size: Number of entries to return per page. Default value is 100.
1929
+ :paramtype page_size: int
1914
1930
  :keyword limit: Number of entries to return. Default value is 1000.
1915
1931
  :paramtype limit: int
1916
1932
  :keyword offset: Number of entries to skip. Default value is 0.
1917
1933
  :paramtype offset: int
1934
+ :keyword subject: Filtering by multiple subjects.
1935
+
1936
+ Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
1937
+ :paramtype subject: list[str]
1938
+ :keyword feature: Filtering by multiple features.
1939
+
1940
+ Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
1941
+ :paramtype feature: list[str]
1942
+ :keyword entitlement_type: Filtering by multiple entitlement types.
1943
+
1944
+ Usage: ``?entitlementType=metered&entitlementType=static``. Default value is None.
1945
+ :paramtype entitlement_type: list[str]
1946
+ :keyword order: Order by field.
1947
+
1948
+ Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
1949
+ :paramtype order: str
1918
1950
  :keyword order_by: Order by field. Known values are: "createdAt" and "updatedAt". Default value
1919
1951
  is "createdAt".
1920
1952
  :paramtype order_by: str
1921
- :return: list of JSON object
1922
- :rtype: list[JSON]
1953
+ :return: any
1954
+ :rtype: any
1923
1955
  :raises ~azure.core.exceptions.HttpResponseError:
1924
-
1925
- Example:
1926
- .. code-block:: python
1927
-
1928
- # response body for status code(s): 200
1929
- response == [
1930
- {}
1931
- ]
1932
1956
  """
1933
1957
  error_map = {
1934
1958
  404: ResourceNotFoundError,
@@ -1942,11 +1966,17 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
1942
1966
  _headers = kwargs.pop("headers", {}) or {}
1943
1967
  _params = kwargs.pop("params", {}) or {}
1944
1968
 
1945
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
1969
+ cls: ClsType[Any] = kwargs.pop("cls", None)
1946
1970
 
1947
1971
  _request = build_list_entitlements_request(
1972
+ page=page,
1973
+ page_size=page_size,
1948
1974
  limit=limit,
1949
1975
  offset=offset,
1976
+ subject=subject,
1977
+ feature=feature,
1978
+ entitlement_type=entitlement_type,
1979
+ order=order,
1950
1980
  order_by=order_by,
1951
1981
  headers=_headers,
1952
1982
  params=_params,
@@ -1972,75 +2002,53 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
1972
2002
  deserialized = None
1973
2003
 
1974
2004
  if cls:
1975
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
2005
+ return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
1976
2006
 
1977
- return cast(List[JSON], deserialized) # type: ignore
2007
+ return cast(Any, deserialized) # type: ignore
1978
2008
 
1979
2009
  @distributed_trace_async
1980
2010
  async def list_features(
1981
2011
  self,
1982
2012
  *,
2013
+ page: int = 1,
2014
+ page_size: int = 100,
1983
2015
  limit: int = 1000,
1984
2016
  offset: int = 0,
2017
+ meter_slug: Optional[List[str]] = None,
2018
+ order: str = "ASC",
1985
2019
  order_by: str = "updatedAt",
1986
2020
  include_archived: bool = False,
1987
2021
  **kwargs: Any
1988
- ) -> List[JSON]:
1989
- # pylint: disable=line-too-long
2022
+ ) -> Any:
1990
2023
  """List features.
1991
2024
 
1992
- List all features.
2025
+ List all features. If page is provided that takes precedence and the paginated response is
2026
+ returned.
1993
2027
 
2028
+ :keyword page: Page number to return. Default value is 1.
2029
+ :paramtype page: int
2030
+ :keyword page_size: Number of entries to return per page. Default value is 100.
2031
+ :paramtype page_size: int
1994
2032
  :keyword limit: Number of entries to return. Default value is 1000.
1995
2033
  :paramtype limit: int
1996
2034
  :keyword offset: Number of entries to skip. Default value is 0.
1997
2035
  :paramtype offset: int
2036
+ :keyword meter_slug: Filtering by multiple meterSlug.
2037
+
2038
+ Usage: ``?meterSlug=meter-1&meterSlug=meter-2``. Default value is None.
2039
+ :paramtype meter_slug: list[str]
2040
+ :keyword order: Order by field.
2041
+
2042
+ Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
2043
+ :paramtype order: str
1998
2044
  :keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
1999
2045
  Default value is "updatedAt".
2000
2046
  :paramtype order_by: str
2001
2047
  :keyword include_archived: Include archived features. Default value is False.
2002
2048
  :paramtype include_archived: bool
2003
- :return: list of JSON object
2004
- :rtype: list[JSON]
2049
+ :return: any
2050
+ :rtype: any
2005
2051
  :raises ~azure.core.exceptions.HttpResponseError:
2006
-
2007
- Example:
2008
- .. code-block:: python
2009
-
2010
- # response body for status code(s): 200
2011
- response == [
2012
- {
2013
- "createdAt": "2020-02-20 00:00:00", # The date and time the resource
2014
- was created. Required.
2015
- "id": "str", # Readonly unique ULID identifier. Required.
2016
- "key": "str", # The key is an immutable unique identifier of the
2017
- feature used throughout the API, for example when interacting with a
2018
- subject's entitlements. The key has to be unique across all active features,
2019
- but archived features can share the same key. The key should consist of
2020
- lowercase alphanumeric characters and dashes. Required.
2021
- "name": "str", # The name of the feature. Required.
2022
- "updatedAt": "2020-02-20 00:00:00", # The date and time the resource
2023
- was last updated. The initial value is the same as createdAt. Required.
2024
- "archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is
2025
- archived, no new entitlements can be created for it.
2026
- "deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
2027
- the resource was deleted.
2028
- "metadata": {
2029
- "str": "str" # Optional. Additional metadata for the
2030
- feature, useful for syncing with external systems and annotating custom
2031
- fields.
2032
- },
2033
- "meterGroupByFilters": {
2034
- "str": "str" # Optional. Optional meter group by filters.
2035
- Useful if the meter scope is broader than what feature tracks. Example
2036
- scenario would be a meter tracking all token use with groupBy fields for
2037
- the model, then the feature could filter for model=gpt-4.
2038
- },
2039
- "meterSlug": "str" # Optional. The meter that the feature is
2040
- associated with and and based on which usage is calculated. The meter
2041
- selected must have SUM or COUNT aggregation.
2042
- }
2043
- ]
2044
2052
  """
2045
2053
  error_map = {
2046
2054
  404: ResourceNotFoundError,
@@ -2054,11 +2062,15 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2054
2062
  _headers = kwargs.pop("headers", {}) or {}
2055
2063
  _params = kwargs.pop("params", {}) or {}
2056
2064
 
2057
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
2065
+ cls: ClsType[Any] = kwargs.pop("cls", None)
2058
2066
 
2059
2067
  _request = build_list_features_request(
2068
+ page=page,
2069
+ page_size=page_size,
2060
2070
  limit=limit,
2061
2071
  offset=offset,
2072
+ meter_slug=meter_slug,
2073
+ order=order,
2062
2074
  order_by=order_by,
2063
2075
  include_archived=include_archived,
2064
2076
  headers=_headers,
@@ -2085,9 +2097,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2085
2097
  deserialized = None
2086
2098
 
2087
2099
  if cls:
2088
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
2100
+ return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
2089
2101
 
2090
- return cast(List[JSON], deserialized) # type: ignore
2102
+ return cast(Any, deserialized) # type: ignore
2091
2103
 
2092
2104
  @overload
2093
2105
  async def create_feature(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
@@ -2509,97 +2521,53 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2509
2521
  async def list_grants(
2510
2522
  self,
2511
2523
  *,
2524
+ page: int = 1,
2525
+ page_size: int = 100,
2512
2526
  limit: int = 1000,
2513
2527
  offset: int = 0,
2528
+ subject: Optional[List[str]] = None,
2529
+ feature: Optional[List[str]] = None,
2530
+ order: str = "ASC",
2514
2531
  order_by: str = "updatedAt",
2515
2532
  include_deleted: bool = False,
2516
2533
  **kwargs: Any
2517
- ) -> List[JSON]:
2518
- # pylint: disable=line-too-long
2534
+ ) -> Any:
2519
2535
  """List grants.
2520
2536
 
2521
2537
  List all grants for all the subjects and entitlements. This endpoint is intended for
2522
2538
  administrative purposes only. To fetch the grants of a specific entitlement please use the
2523
2539
  /api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
2524
2540
 
2541
+ If page is provided that takes precedence and the paginated response is returned.
2542
+
2543
+ :keyword page: Page number to return. Default value is 1.
2544
+ :paramtype page: int
2545
+ :keyword page_size: Number of entries to return per page. Default value is 100.
2546
+ :paramtype page_size: int
2525
2547
  :keyword limit: Number of entries to return. Default value is 1000.
2526
2548
  :paramtype limit: int
2527
2549
  :keyword offset: Number of entries to skip. Default value is 0.
2528
2550
  :paramtype offset: int
2551
+ :keyword subject: Filtering by multiple subjects.
2552
+
2553
+ Usage: ``?subject=customer-1&subject=customer-2``. Default value is None.
2554
+ :paramtype subject: list[str]
2555
+ :keyword feature: Filtering by multiple features.
2556
+
2557
+ Usage: ``?feature=feature-1&feature=feature-2``. Default value is None.
2558
+ :paramtype feature: list[str]
2559
+ :keyword order: Order by field.
2560
+
2561
+ Usage: ``?order=ASC``. Known values are: "ASC" and "DESC". Default value is "ASC".
2562
+ :paramtype order: str
2529
2563
  :keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
2530
2564
  Default value is "updatedAt".
2531
2565
  :paramtype order_by: str
2532
2566
  :keyword include_deleted: Include deleted entries. Default value is False.
2533
2567
  :paramtype include_deleted: bool
2534
- :return: list of JSON object
2535
- :rtype: list[JSON]
2568
+ :return: any
2569
+ :rtype: any
2536
2570
  :raises ~azure.core.exceptions.HttpResponseError:
2537
-
2538
- Example:
2539
- .. code-block:: python
2540
-
2541
- # response body for status code(s): 200
2542
- response == [
2543
- {
2544
- "amount": 0.0, # The amount to grant. Should be a positive number.
2545
- Required.
2546
- "createdAt": "2020-02-20 00:00:00", # The date and time the resource
2547
- was created. Required.
2548
- "effectiveAt": "2020-02-20 00:00:00", # Effective date for grants
2549
- and anchor for recurring grants. Provided value will be ceiled to metering
2550
- windowSize (minute). Required.
2551
- "entitlementId": "str", # The unique entitlement ULID that the grant
2552
- is associated with. Required.
2553
- "expiration": {
2554
- "count": 0, # The expiration period count like 12 months.
2555
- Required.
2556
- "duration": "str" # The expiration period duration like
2557
- month. Required. Known values are: "HOUR", "DAY", "WEEK", "MONTH", and
2558
- "YEAR".
2559
- },
2560
- "id": "str", # Readonly unique ULID identifier. Required.
2561
- "updatedAt": "2020-02-20 00:00:00", # The date and time the resource
2562
- was last updated. The initial value is the same as createdAt. Required.
2563
- "deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
2564
- the resource was deleted.
2565
- "expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date
2566
- of the grant.
2567
- "maxRolloverAmount": 0, # Optional. Default value is 0. Grants are
2568
- rolled over at reset, after which they can have a different balance compared
2569
- to what they had before the reset. Balance after the reset is calculated as:
2570
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
2571
- MinRolloverAmount)).
2572
- "metadata": {
2573
- "str": "str" # Optional. Dictionary of :code:`<string>`.
2574
- },
2575
- "minRolloverAmount": 0, # Optional. Default value is 0. Grants are
2576
- rolled over at reset, after which they can have a different balance compared
2577
- to what they had before the reset. Balance after the reset is calculated as:
2578
- Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset,
2579
- MinRolloverAmount)).
2580
- "nextRecurrence": "2020-02-20 00:00:00", # Optional. The next time
2581
- the grant will recurr.
2582
- "priority": 1, # Optional. Default value is 1. The priority of the
2583
- grant. Grants with higher priority are applied first. Priority is a positive
2584
- decimal numbers. With lower numbers indicating higher importance. For
2585
- example, a priority of 1 is more urgent than a priority of 2. When there are
2586
- several grants available for the same subject, the system selects the grant
2587
- with the highest priority. In cases where grants share the same priority
2588
- level, the grant closest to its expiration will be used first. In the case of
2589
- two grants have identical priorities and expiration dates, the system will
2590
- use the grant that was created first.
2591
- "recurrence": {
2592
- "anchor": "2020-02-20 00:00:00", # An arbitrary anchor to
2593
- base the recurring period on. Required.
2594
- "interval": "str" # List of pre-defined periods that can be
2595
- used for recurring & scheduling. DAY: Every day WEEK: Every
2596
- week MONTH: Every month YEAR: Every year. Required. Known values
2597
- are: "DAY", "WEEK", "MONTH", and "YEAR".
2598
- },
2599
- "voidedAt": "2020-02-20 00:00:00" # Optional. The date and time the
2600
- grant was voided (cannot be used after that).
2601
- }
2602
- ]
2603
2571
  """
2604
2572
  error_map = {
2605
2573
  404: ResourceNotFoundError,
@@ -2612,11 +2580,16 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2612
2580
  _headers = kwargs.pop("headers", {}) or {}
2613
2581
  _params = kwargs.pop("params", {}) or {}
2614
2582
 
2615
- cls: ClsType[List[JSON]] = kwargs.pop("cls", None)
2583
+ cls: ClsType[Any] = kwargs.pop("cls", None)
2616
2584
 
2617
2585
  _request = build_list_grants_request(
2586
+ page=page,
2587
+ page_size=page_size,
2618
2588
  limit=limit,
2619
2589
  offset=offset,
2590
+ subject=subject,
2591
+ feature=feature,
2592
+ order=order,
2620
2593
  order_by=order_by,
2621
2594
  include_deleted=include_deleted,
2622
2595
  headers=_headers,
@@ -2643,9 +2616,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
2643
2616
  deserialized = None
2644
2617
 
2645
2618
  if cls:
2646
- return cls(pipeline_response, cast(List[JSON], deserialized), {}) # type: ignore
2619
+ return cls(pipeline_response, cast(Any, deserialized), {}) # type: ignore
2647
2620
 
2648
- return cast(List[JSON], deserialized) # type: ignore
2621
+ return cast(Any, deserialized) # type: ignore
2649
2622
 
2650
2623
  @distributed_trace_async
2651
2624
  async def void_grant(self, grant_id: str, **kwargs: Any) -> Optional[JSON]:
File without changes