openmeter 1.0.0b114__py3-none-any.whl → 1.0.0b116__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openmeter might be problematic. Click here for more details.
- openmeter/_operations/_operations.py +371 -130
- openmeter/aio/_operations/_operations.py +370 -129
- {openmeter-1.0.0b114.dist-info → openmeter-1.0.0b116.dist-info}/METADATA +1 -1
- {openmeter-1.0.0b114.dist-info → openmeter-1.0.0b116.dist-info}/RECORD +5 -5
- {openmeter-1.0.0b114.dist-info → openmeter-1.0.0b116.dist-info}/WHEEL +0 -0
|
@@ -410,7 +410,7 @@ def build_list_entitlements_request(
|
|
|
410
410
|
|
|
411
411
|
|
|
412
412
|
def build_list_features_request(
|
|
413
|
-
*, limit: int = 1000, offset: int = 0, order_by: str = "
|
|
413
|
+
*, limit: int = 1000, offset: int = 0, order_by: str = "updatedAt", include_archived: bool = False, **kwargs: Any
|
|
414
414
|
) -> HttpRequest:
|
|
415
415
|
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
|
416
416
|
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
|
|
@@ -2613,7 +2613,8 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2613
2613
|
) -> List[JSON]:
|
|
2614
2614
|
"""List entitlements.
|
|
2615
2615
|
|
|
2616
|
-
List entitlements.
|
|
2616
|
+
List all entitlements regardless of subject. This endpoint is intended for administrative
|
|
2617
|
+
purposes.
|
|
2617
2618
|
|
|
2618
2619
|
:keyword limit: Number of entries to return. Default value is 1000.
|
|
2619
2620
|
:paramtype limit: int
|
|
@@ -2638,6 +2639,7 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2638
2639
|
404: ResourceNotFoundError,
|
|
2639
2640
|
409: ResourceExistsError,
|
|
2640
2641
|
304: ResourceNotModifiedError,
|
|
2642
|
+
400: HttpResponseError,
|
|
2641
2643
|
401: lambda response: ClientAuthenticationError(response=response),
|
|
2642
2644
|
}
|
|
2643
2645
|
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
@@ -2681,19 +2683,25 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2681
2683
|
|
|
2682
2684
|
@distributed_trace
|
|
2683
2685
|
def list_features(
|
|
2684
|
-
self,
|
|
2686
|
+
self,
|
|
2687
|
+
*,
|
|
2688
|
+
limit: int = 1000,
|
|
2689
|
+
offset: int = 0,
|
|
2690
|
+
order_by: str = "updatedAt",
|
|
2691
|
+
include_archived: bool = False,
|
|
2692
|
+
**kwargs: Any
|
|
2685
2693
|
) -> List[JSON]:
|
|
2686
2694
|
# pylint: disable=line-too-long
|
|
2687
2695
|
"""List features.
|
|
2688
2696
|
|
|
2689
|
-
List features.
|
|
2697
|
+
List all features.
|
|
2690
2698
|
|
|
2691
2699
|
:keyword limit: Number of entries to return. Default value is 1000.
|
|
2692
2700
|
:paramtype limit: int
|
|
2693
2701
|
:keyword offset: Number of entries to skip. Default value is 0.
|
|
2694
2702
|
:paramtype offset: int
|
|
2695
2703
|
:keyword order_by: Order by field. Known values are: "id", "createdAt", and "updatedAt".
|
|
2696
|
-
Default value is "
|
|
2704
|
+
Default value is "updatedAt".
|
|
2697
2705
|
:paramtype order_by: str
|
|
2698
2706
|
:keyword include_archived: Include archived features. Default value is False.
|
|
2699
2707
|
:paramtype include_archived: bool
|
|
@@ -2710,26 +2718,32 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2710
2718
|
"createdAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
2711
2719
|
was created. Required.
|
|
2712
2720
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
2713
|
-
"key": "str", # The
|
|
2714
|
-
|
|
2721
|
+
"key": "str", # The key is an immutable unique identifier of the
|
|
2722
|
+
feature used throughout the API, for example when interacting with a
|
|
2723
|
+
subject's entitlements. The key has to be unique across all active features,
|
|
2724
|
+
but archived features can share the same key. The key should consist of
|
|
2725
|
+
lowercase alphanumeric characters and dashes. Required.
|
|
2715
2726
|
"name": "str", # The name of the feature. Required.
|
|
2716
2727
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
2717
|
-
was last updated.
|
|
2728
|
+
was last updated. The initial value is the same as createdAt. Required.
|
|
2718
2729
|
"archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is
|
|
2719
|
-
archived,
|
|
2730
|
+
archived, no new entitlements can be created for it.
|
|
2720
2731
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
|
|
2721
|
-
the resource was deleted.
|
|
2732
|
+
the resource was deleted.
|
|
2722
2733
|
"metadata": {
|
|
2723
2734
|
"str": "str" # Optional. Additional metadata for the
|
|
2724
|
-
feature
|
|
2735
|
+
feature, useful for syncing with external systems and annotating custom
|
|
2736
|
+
fields.
|
|
2725
2737
|
},
|
|
2726
2738
|
"meterGroupByFilters": {
|
|
2727
2739
|
"str": "str" # Optional. Optional meter group by filters.
|
|
2728
|
-
Useful if the meter scope is broader than what feature tracks.
|
|
2740
|
+
Useful if the meter scope is broader than what feature tracks. Example
|
|
2741
|
+
scenario would be a meter tracking all token use with groupBy fields for
|
|
2742
|
+
the model, then the feature could filter for model=gpt-4.
|
|
2729
2743
|
},
|
|
2730
2744
|
"meterSlug": "str" # Optional. The meter that the feature is
|
|
2731
|
-
associated with and
|
|
2732
|
-
|
|
2745
|
+
associated with and and based on which usage is calculated. The meter
|
|
2746
|
+
selected must have SUM or COUNT aggregation.
|
|
2733
2747
|
}
|
|
2734
2748
|
]
|
|
2735
2749
|
"""
|
|
@@ -2737,6 +2751,7 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2737
2751
|
404: ResourceNotFoundError,
|
|
2738
2752
|
409: ResourceExistsError,
|
|
2739
2753
|
304: ResourceNotModifiedError,
|
|
2754
|
+
400: HttpResponseError,
|
|
2740
2755
|
401: lambda response: ClientAuthenticationError(response=response),
|
|
2741
2756
|
}
|
|
2742
2757
|
error_map.update(kwargs.pop("error_map", {}) or {})
|
|
@@ -2782,9 +2797,15 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2782
2797
|
@overload
|
|
2783
2798
|
def create_feature(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON:
|
|
2784
2799
|
# pylint: disable=line-too-long
|
|
2785
|
-
"""Create feature.
|
|
2800
|
+
"""Create a feature.
|
|
2786
2801
|
|
|
2787
|
-
|
|
2802
|
+
Features are either metered or static. A feature is metered if meterSlug is provided at
|
|
2803
|
+
creation.
|
|
2804
|
+
For metered features you can pass additional filters that will be applied when calculating
|
|
2805
|
+
feature usage, based on the meter's groupBy fields. Only meters with SUM and COUNT aggregation
|
|
2806
|
+
are supported for features.
|
|
2807
|
+
|
|
2808
|
+
Features cannot be updated later, only archived.
|
|
2788
2809
|
|
|
2789
2810
|
:param body: The feature to create. Required.
|
|
2790
2811
|
:type body: JSON
|
|
@@ -2800,19 +2821,25 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2800
2821
|
|
|
2801
2822
|
# JSON input template you can fill out and use as your body input.
|
|
2802
2823
|
body = {
|
|
2803
|
-
"key": "str", # The
|
|
2804
|
-
|
|
2824
|
+
"key": "str", # The key is an immutable unique identifier of the feature
|
|
2825
|
+
used throughout the API, for example when interacting with a subject's
|
|
2826
|
+
entitlements. The key has to be unique across all active features, but archived
|
|
2827
|
+
features can share the same key. The key should consist of lowercase alphanumeric
|
|
2828
|
+
characters and dashes. Required.
|
|
2805
2829
|
"name": "str", # The name of the feature. Required.
|
|
2806
2830
|
"metadata": {
|
|
2807
|
-
"str": "str" # Optional. Additional metadata for the feature
|
|
2831
|
+
"str": "str" # Optional. Additional metadata for the feature, useful
|
|
2832
|
+
for syncing with external systems and annotating custom fields.
|
|
2808
2833
|
},
|
|
2809
2834
|
"meterGroupByFilters": {
|
|
2810
2835
|
"str": "str" # Optional. Optional meter group by filters. Useful if
|
|
2811
|
-
the meter scope is broader than what feature tracks.
|
|
2836
|
+
the meter scope is broader than what feature tracks. Example scenario would
|
|
2837
|
+
be a meter tracking all token use with groupBy fields for the model, then the
|
|
2838
|
+
feature could filter for model=gpt-4.
|
|
2812
2839
|
},
|
|
2813
2840
|
"meterSlug": "str" # Optional. The meter that the feature is associated with
|
|
2814
|
-
and
|
|
2815
|
-
|
|
2841
|
+
and and based on which usage is calculated. The meter selected must have SUM or
|
|
2842
|
+
COUNT aggregation.
|
|
2816
2843
|
}
|
|
2817
2844
|
|
|
2818
2845
|
# response body for status code(s): 201
|
|
@@ -2820,34 +2847,46 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2820
2847
|
"createdAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
2821
2848
|
created. Required.
|
|
2822
2849
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
2823
|
-
"key": "str", # The
|
|
2824
|
-
|
|
2850
|
+
"key": "str", # The key is an immutable unique identifier of the feature
|
|
2851
|
+
used throughout the API, for example when interacting with a subject's
|
|
2852
|
+
entitlements. The key has to be unique across all active features, but archived
|
|
2853
|
+
features can share the same key. The key should consist of lowercase alphanumeric
|
|
2854
|
+
characters and dashes. Required.
|
|
2825
2855
|
"name": "str", # The name of the feature. Required.
|
|
2826
2856
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
2827
|
-
last updated.
|
|
2857
|
+
last updated. The initial value is the same as createdAt. Required.
|
|
2828
2858
|
"archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is archived,
|
|
2829
|
-
|
|
2859
|
+
no new entitlements can be created for it.
|
|
2830
2860
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time the
|
|
2831
|
-
resource was deleted.
|
|
2861
|
+
resource was deleted.
|
|
2832
2862
|
"metadata": {
|
|
2833
|
-
"str": "str" # Optional. Additional metadata for the feature
|
|
2863
|
+
"str": "str" # Optional. Additional metadata for the feature, useful
|
|
2864
|
+
for syncing with external systems and annotating custom fields.
|
|
2834
2865
|
},
|
|
2835
2866
|
"meterGroupByFilters": {
|
|
2836
2867
|
"str": "str" # Optional. Optional meter group by filters. Useful if
|
|
2837
|
-
the meter scope is broader than what feature tracks.
|
|
2868
|
+
the meter scope is broader than what feature tracks. Example scenario would
|
|
2869
|
+
be a meter tracking all token use with groupBy fields for the model, then the
|
|
2870
|
+
feature could filter for model=gpt-4.
|
|
2838
2871
|
},
|
|
2839
2872
|
"meterSlug": "str" # Optional. The meter that the feature is associated with
|
|
2840
|
-
and
|
|
2841
|
-
|
|
2873
|
+
and and based on which usage is calculated. The meter selected must have SUM or
|
|
2874
|
+
COUNT aggregation.
|
|
2842
2875
|
}
|
|
2843
2876
|
"""
|
|
2844
2877
|
|
|
2845
2878
|
@overload
|
|
2846
2879
|
def create_feature(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> JSON:
|
|
2847
2880
|
# pylint: disable=line-too-long
|
|
2848
|
-
"""Create feature.
|
|
2881
|
+
"""Create a feature.
|
|
2882
|
+
|
|
2883
|
+
Features are either metered or static. A feature is metered if meterSlug is provided at
|
|
2884
|
+
creation.
|
|
2885
|
+
For metered features you can pass additional filters that will be applied when calculating
|
|
2886
|
+
feature usage, based on the meter's groupBy fields. Only meters with SUM and COUNT aggregation
|
|
2887
|
+
are supported for features.
|
|
2849
2888
|
|
|
2850
|
-
|
|
2889
|
+
Features cannot be updated later, only archived.
|
|
2851
2890
|
|
|
2852
2891
|
:param body: The feature to create. Required.
|
|
2853
2892
|
:type body: IO[bytes]
|
|
@@ -2866,34 +2905,46 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2866
2905
|
"createdAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
2867
2906
|
created. Required.
|
|
2868
2907
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
2869
|
-
"key": "str", # The
|
|
2870
|
-
|
|
2908
|
+
"key": "str", # The key is an immutable unique identifier of the feature
|
|
2909
|
+
used throughout the API, for example when interacting with a subject's
|
|
2910
|
+
entitlements. The key has to be unique across all active features, but archived
|
|
2911
|
+
features can share the same key. The key should consist of lowercase alphanumeric
|
|
2912
|
+
characters and dashes. Required.
|
|
2871
2913
|
"name": "str", # The name of the feature. Required.
|
|
2872
2914
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
2873
|
-
last updated.
|
|
2915
|
+
last updated. The initial value is the same as createdAt. Required.
|
|
2874
2916
|
"archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is archived,
|
|
2875
|
-
|
|
2917
|
+
no new entitlements can be created for it.
|
|
2876
2918
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time the
|
|
2877
|
-
resource was deleted.
|
|
2919
|
+
resource was deleted.
|
|
2878
2920
|
"metadata": {
|
|
2879
|
-
"str": "str" # Optional. Additional metadata for the feature
|
|
2921
|
+
"str": "str" # Optional. Additional metadata for the feature, useful
|
|
2922
|
+
for syncing with external systems and annotating custom fields.
|
|
2880
2923
|
},
|
|
2881
2924
|
"meterGroupByFilters": {
|
|
2882
2925
|
"str": "str" # Optional. Optional meter group by filters. Useful if
|
|
2883
|
-
the meter scope is broader than what feature tracks.
|
|
2926
|
+
the meter scope is broader than what feature tracks. Example scenario would
|
|
2927
|
+
be a meter tracking all token use with groupBy fields for the model, then the
|
|
2928
|
+
feature could filter for model=gpt-4.
|
|
2884
2929
|
},
|
|
2885
2930
|
"meterSlug": "str" # Optional. The meter that the feature is associated with
|
|
2886
|
-
and
|
|
2887
|
-
|
|
2931
|
+
and and based on which usage is calculated. The meter selected must have SUM or
|
|
2932
|
+
COUNT aggregation.
|
|
2888
2933
|
}
|
|
2889
2934
|
"""
|
|
2890
2935
|
|
|
2891
2936
|
@distributed_trace
|
|
2892
2937
|
def create_feature(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
2893
2938
|
# pylint: disable=line-too-long
|
|
2894
|
-
"""Create feature.
|
|
2939
|
+
"""Create a feature.
|
|
2940
|
+
|
|
2941
|
+
Features are either metered or static. A feature is metered if meterSlug is provided at
|
|
2942
|
+
creation.
|
|
2943
|
+
For metered features you can pass additional filters that will be applied when calculating
|
|
2944
|
+
feature usage, based on the meter's groupBy fields. Only meters with SUM and COUNT aggregation
|
|
2945
|
+
are supported for features.
|
|
2895
2946
|
|
|
2896
|
-
|
|
2947
|
+
Features cannot be updated later, only archived.
|
|
2897
2948
|
|
|
2898
2949
|
:param body: The feature to create. Is either a JSON type or a IO[bytes] type. Required.
|
|
2899
2950
|
:type body: JSON or IO[bytes]
|
|
@@ -2906,19 +2957,25 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2906
2957
|
|
|
2907
2958
|
# JSON input template you can fill out and use as your body input.
|
|
2908
2959
|
body = {
|
|
2909
|
-
"key": "str", # The
|
|
2910
|
-
|
|
2960
|
+
"key": "str", # The key is an immutable unique identifier of the feature
|
|
2961
|
+
used throughout the API, for example when interacting with a subject's
|
|
2962
|
+
entitlements. The key has to be unique across all active features, but archived
|
|
2963
|
+
features can share the same key. The key should consist of lowercase alphanumeric
|
|
2964
|
+
characters and dashes. Required.
|
|
2911
2965
|
"name": "str", # The name of the feature. Required.
|
|
2912
2966
|
"metadata": {
|
|
2913
|
-
"str": "str" # Optional. Additional metadata for the feature
|
|
2967
|
+
"str": "str" # Optional. Additional metadata for the feature, useful
|
|
2968
|
+
for syncing with external systems and annotating custom fields.
|
|
2914
2969
|
},
|
|
2915
2970
|
"meterGroupByFilters": {
|
|
2916
2971
|
"str": "str" # Optional. Optional meter group by filters. Useful if
|
|
2917
|
-
the meter scope is broader than what feature tracks.
|
|
2972
|
+
the meter scope is broader than what feature tracks. Example scenario would
|
|
2973
|
+
be a meter tracking all token use with groupBy fields for the model, then the
|
|
2974
|
+
feature could filter for model=gpt-4.
|
|
2918
2975
|
},
|
|
2919
2976
|
"meterSlug": "str" # Optional. The meter that the feature is associated with
|
|
2920
|
-
and
|
|
2921
|
-
|
|
2977
|
+
and and based on which usage is calculated. The meter selected must have SUM or
|
|
2978
|
+
COUNT aggregation.
|
|
2922
2979
|
}
|
|
2923
2980
|
|
|
2924
2981
|
# response body for status code(s): 201
|
|
@@ -2926,25 +2983,31 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
2926
2983
|
"createdAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
2927
2984
|
created. Required.
|
|
2928
2985
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
2929
|
-
"key": "str", # The
|
|
2930
|
-
|
|
2986
|
+
"key": "str", # The key is an immutable unique identifier of the feature
|
|
2987
|
+
used throughout the API, for example when interacting with a subject's
|
|
2988
|
+
entitlements. The key has to be unique across all active features, but archived
|
|
2989
|
+
features can share the same key. The key should consist of lowercase alphanumeric
|
|
2990
|
+
characters and dashes. Required.
|
|
2931
2991
|
"name": "str", # The name of the feature. Required.
|
|
2932
2992
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
2933
|
-
last updated.
|
|
2993
|
+
last updated. The initial value is the same as createdAt. Required.
|
|
2934
2994
|
"archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is archived,
|
|
2935
|
-
|
|
2995
|
+
no new entitlements can be created for it.
|
|
2936
2996
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time the
|
|
2937
|
-
resource was deleted.
|
|
2997
|
+
resource was deleted.
|
|
2938
2998
|
"metadata": {
|
|
2939
|
-
"str": "str" # Optional. Additional metadata for the feature
|
|
2999
|
+
"str": "str" # Optional. Additional metadata for the feature, useful
|
|
3000
|
+
for syncing with external systems and annotating custom fields.
|
|
2940
3001
|
},
|
|
2941
3002
|
"meterGroupByFilters": {
|
|
2942
3003
|
"str": "str" # Optional. Optional meter group by filters. Useful if
|
|
2943
|
-
the meter scope is broader than what feature tracks.
|
|
3004
|
+
the meter scope is broader than what feature tracks. Example scenario would
|
|
3005
|
+
be a meter tracking all token use with groupBy fields for the model, then the
|
|
3006
|
+
feature could filter for model=gpt-4.
|
|
2944
3007
|
},
|
|
2945
3008
|
"meterSlug": "str" # Optional. The meter that the feature is associated with
|
|
2946
|
-
and
|
|
2947
|
-
|
|
3009
|
+
and and based on which usage is calculated. The meter selected must have SUM or
|
|
3010
|
+
COUNT aggregation.
|
|
2948
3011
|
}
|
|
2949
3012
|
"""
|
|
2950
3013
|
error_map = {
|
|
@@ -3008,7 +3071,7 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3008
3071
|
# pylint: disable=line-too-long
|
|
3009
3072
|
"""Get feature.
|
|
3010
3073
|
|
|
3011
|
-
Get feature by id.
|
|
3074
|
+
Get a feature by id.
|
|
3012
3075
|
|
|
3013
3076
|
:param feature_id: A unique ULID identifier for a feature. Required.
|
|
3014
3077
|
:type feature_id: str
|
|
@@ -3024,25 +3087,31 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3024
3087
|
"createdAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
3025
3088
|
created. Required.
|
|
3026
3089
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
3027
|
-
"key": "str", # The
|
|
3028
|
-
|
|
3090
|
+
"key": "str", # The key is an immutable unique identifier of the feature
|
|
3091
|
+
used throughout the API, for example when interacting with a subject's
|
|
3092
|
+
entitlements. The key has to be unique across all active features, but archived
|
|
3093
|
+
features can share the same key. The key should consist of lowercase alphanumeric
|
|
3094
|
+
characters and dashes. Required.
|
|
3029
3095
|
"name": "str", # The name of the feature. Required.
|
|
3030
3096
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
3031
|
-
last updated.
|
|
3097
|
+
last updated. The initial value is the same as createdAt. Required.
|
|
3032
3098
|
"archivedAt": "2020-02-20 00:00:00", # Optional. If the feature is archived,
|
|
3033
|
-
|
|
3099
|
+
no new entitlements can be created for it.
|
|
3034
3100
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time the
|
|
3035
|
-
resource was deleted.
|
|
3101
|
+
resource was deleted.
|
|
3036
3102
|
"metadata": {
|
|
3037
|
-
"str": "str" # Optional. Additional metadata for the feature
|
|
3103
|
+
"str": "str" # Optional. Additional metadata for the feature, useful
|
|
3104
|
+
for syncing with external systems and annotating custom fields.
|
|
3038
3105
|
},
|
|
3039
3106
|
"meterGroupByFilters": {
|
|
3040
3107
|
"str": "str" # Optional. Optional meter group by filters. Useful if
|
|
3041
|
-
the meter scope is broader than what feature tracks.
|
|
3108
|
+
the meter scope is broader than what feature tracks. Example scenario would
|
|
3109
|
+
be a meter tracking all token use with groupBy fields for the model, then the
|
|
3110
|
+
feature could filter for model=gpt-4.
|
|
3042
3111
|
},
|
|
3043
3112
|
"meterSlug": "str" # Optional. The meter that the feature is associated with
|
|
3044
|
-
and
|
|
3045
|
-
|
|
3113
|
+
and and based on which usage is calculated. The meter selected must have SUM or
|
|
3114
|
+
COUNT aggregation.
|
|
3046
3115
|
}
|
|
3047
3116
|
"""
|
|
3048
3117
|
error_map = {
|
|
@@ -3090,9 +3159,12 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3090
3159
|
|
|
3091
3160
|
@distributed_trace
|
|
3092
3161
|
def delete_feature(self, feature_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements
|
|
3093
|
-
"""
|
|
3162
|
+
"""Archive a feature.
|
|
3094
3163
|
|
|
3095
|
-
|
|
3164
|
+
Once a feature is archived it cannot be unarchived. If a feature is archived, new entitlements
|
|
3165
|
+
cannot be created for it, but archiving the feature does not affect existing entitlements. This
|
|
3166
|
+
means, if you want to create a new feature with the same key, and then create entitlements for
|
|
3167
|
+
it, the previous entitlements have to be deleted first on a per subject basis.
|
|
3096
3168
|
|
|
3097
3169
|
:param feature_id: A unique ULID identifier for a feature. Required.
|
|
3098
3170
|
:type feature_id: str
|
|
@@ -3149,7 +3221,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3149
3221
|
# pylint: disable=line-too-long
|
|
3150
3222
|
"""List grants.
|
|
3151
3223
|
|
|
3152
|
-
List all grants.
|
|
3224
|
+
List all grants for all the subjects and entitlements. This endpoint is intended for
|
|
3225
|
+
administrative purposes only. To fetch the grants of a specific entitlement please use the
|
|
3226
|
+
/api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
|
|
3153
3227
|
|
|
3154
3228
|
:keyword limit: Number of entries to return. Default value is 1000.
|
|
3155
3229
|
:paramtype limit: int
|
|
@@ -3188,9 +3262,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3188
3262
|
},
|
|
3189
3263
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
3190
3264
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
3191
|
-
was last updated.
|
|
3265
|
+
was last updated. The initial value is the same as createdAt. Required.
|
|
3192
3266
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
|
|
3193
|
-
the resource was deleted.
|
|
3267
|
+
the resource was deleted.
|
|
3194
3268
|
"expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date
|
|
3195
3269
|
of the grant.
|
|
3196
3270
|
"maxRolloverAmount": 0, # Optional. Default value is 0. Grants are
|
|
@@ -3278,9 +3352,17 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3278
3352
|
|
|
3279
3353
|
@distributed_trace
|
|
3280
3354
|
def void_grant(self, grant_id: str, **kwargs: Any) -> Optional[JSON]:
|
|
3281
|
-
"""
|
|
3355
|
+
"""Void a grant.
|
|
3282
3356
|
|
|
3283
|
-
|
|
3357
|
+
Voiding a grant means it is no longer valid, it doesn't take part in further balance
|
|
3358
|
+
calculations. Voiding a grant does not retroactively take effect, meaning any usage that has
|
|
3359
|
+
already been attributed to the grant will remain, but future usage cannot be burnt down from
|
|
3360
|
+
the grant.
|
|
3361
|
+
|
|
3362
|
+
For example, if you have a single grant for your metered entitlement with an initial amount of
|
|
3363
|
+
100, and so far 60 usage has been metered, the grant (and the entitlement itself) would have a
|
|
3364
|
+
balance of 40. If you then void that grant, balance becomes 0, but the 60 previous usage will
|
|
3365
|
+
not be affected.
|
|
3284
3366
|
|
|
3285
3367
|
:param grant_id: A unique identifier for a grant. Required.
|
|
3286
3368
|
:type grant_id: str
|
|
@@ -3359,9 +3441,26 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3359
3441
|
def create_entitlement(
|
|
3360
3442
|
self, subject_id_or_key: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
|
|
3361
3443
|
) -> JSON:
|
|
3362
|
-
"""Create entitlement.
|
|
3444
|
+
"""Create an entitlement.
|
|
3445
|
+
|
|
3446
|
+
OpenMeter has three types of entitlements: metered, boolean, and static. The type property
|
|
3447
|
+
determines the type of entitlement. The underlying feature has to be compatible with the
|
|
3448
|
+
entitlement type specified in the request (e.g., a metered entitlement needs a feature
|
|
3449
|
+
associated with a meter).
|
|
3450
|
+
|
|
3363
3451
|
|
|
3364
|
-
|
|
3452
|
+
* Boolean entitlements define static feature access, e.g. "Can use SSO authentication".
|
|
3453
|
+
* Static entitlements let you pass along a configuration while granting access, e.g. "Using
|
|
3454
|
+
this feature with X Y settings" (passed in the config).
|
|
3455
|
+
* Metered entitlements have many use cases, from setting up usage-based access to implementing
|
|
3456
|
+
complex credit systems. Example: The customer can use 10000 AI tokens during the usage period
|
|
3457
|
+
of the entitlement.
|
|
3458
|
+
|
|
3459
|
+
A given subject can only have one active (non-deleted) entitlement per featureKey. If you try
|
|
3460
|
+
to create a new entitlement for a featureKey that already has an active entitlement, the
|
|
3461
|
+
request will fail with a 409 error.
|
|
3462
|
+
|
|
3463
|
+
Once an entitlement is created you cannot modify it, only delete it.
|
|
3365
3464
|
|
|
3366
3465
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3367
3466
|
:type subject_id_or_key: str
|
|
@@ -3403,9 +3502,26 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3403
3502
|
def create_entitlement(
|
|
3404
3503
|
self, subject_id_or_key: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
|
3405
3504
|
) -> JSON:
|
|
3406
|
-
"""Create entitlement.
|
|
3505
|
+
"""Create an entitlement.
|
|
3506
|
+
|
|
3507
|
+
OpenMeter has three types of entitlements: metered, boolean, and static. The type property
|
|
3508
|
+
determines the type of entitlement. The underlying feature has to be compatible with the
|
|
3509
|
+
entitlement type specified in the request (e.g., a metered entitlement needs a feature
|
|
3510
|
+
associated with a meter).
|
|
3407
3511
|
|
|
3408
|
-
|
|
3512
|
+
|
|
3513
|
+
* Boolean entitlements define static feature access, e.g. "Can use SSO authentication".
|
|
3514
|
+
* Static entitlements let you pass along a configuration while granting access, e.g. "Using
|
|
3515
|
+
this feature with X Y settings" (passed in the config).
|
|
3516
|
+
* Metered entitlements have many use cases, from setting up usage-based access to implementing
|
|
3517
|
+
complex credit systems. Example: The customer can use 10000 AI tokens during the usage period
|
|
3518
|
+
of the entitlement.
|
|
3519
|
+
|
|
3520
|
+
A given subject can only have one active (non-deleted) entitlement per featureKey. If you try
|
|
3521
|
+
to create a new entitlement for a featureKey that already has an active entitlement, the
|
|
3522
|
+
request will fail with a 409 error.
|
|
3523
|
+
|
|
3524
|
+
Once an entitlement is created you cannot modify it, only delete it.
|
|
3409
3525
|
|
|
3410
3526
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3411
3527
|
:type subject_id_or_key: str
|
|
@@ -3442,9 +3558,26 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3442
3558
|
|
|
3443
3559
|
@distributed_trace
|
|
3444
3560
|
def create_entitlement(self, subject_id_or_key: str, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON:
|
|
3445
|
-
"""Create entitlement.
|
|
3561
|
+
"""Create an entitlement.
|
|
3562
|
+
|
|
3563
|
+
OpenMeter has three types of entitlements: metered, boolean, and static. The type property
|
|
3564
|
+
determines the type of entitlement. The underlying feature has to be compatible with the
|
|
3565
|
+
entitlement type specified in the request (e.g., a metered entitlement needs a feature
|
|
3566
|
+
associated with a meter).
|
|
3567
|
+
|
|
3568
|
+
|
|
3569
|
+
* Boolean entitlements define static feature access, e.g. "Can use SSO authentication".
|
|
3570
|
+
* Static entitlements let you pass along a configuration while granting access, e.g. "Using
|
|
3571
|
+
this feature with X Y settings" (passed in the config).
|
|
3572
|
+
* Metered entitlements have many use cases, from setting up usage-based access to implementing
|
|
3573
|
+
complex credit systems. Example: The customer can use 10000 AI tokens during the usage period
|
|
3574
|
+
of the entitlement.
|
|
3446
3575
|
|
|
3447
|
-
|
|
3576
|
+
A given subject can only have one active (non-deleted) entitlement per featureKey. If you try
|
|
3577
|
+
to create a new entitlement for a featureKey that already has an active entitlement, the
|
|
3578
|
+
request will fail with a 409 error.
|
|
3579
|
+
|
|
3580
|
+
Once an entitlement is created you cannot modify it, only delete it.
|
|
3448
3581
|
|
|
3449
3582
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3450
3583
|
:type subject_id_or_key: str
|
|
@@ -3546,9 +3679,10 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3546
3679
|
def list_subject_entitlements(
|
|
3547
3680
|
self, subject_id_or_key: str, *, include_deleted: bool = False, **kwargs: Any
|
|
3548
3681
|
) -> List[JSON]:
|
|
3549
|
-
"""List entitlements.
|
|
3682
|
+
"""List entitlements of a subject.
|
|
3550
3683
|
|
|
3551
|
-
List all entitlements for a subject.
|
|
3684
|
+
List all entitlements for a subject. For checking entitlement access, use the /value endpoint
|
|
3685
|
+
instead.
|
|
3552
3686
|
|
|
3553
3687
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3554
3688
|
:type subject_id_or_key: str
|
|
@@ -3612,9 +3746,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3612
3746
|
|
|
3613
3747
|
@distributed_trace
|
|
3614
3748
|
def get_entitlement(self, subject_id_or_key: str, entitlement_id: str, **kwargs: Any) -> JSON:
|
|
3615
|
-
"""Get entitlement.
|
|
3749
|
+
"""Get an entitlement.
|
|
3616
3750
|
|
|
3617
|
-
Get entitlement by id.
|
|
3751
|
+
Get entitlement by id. For checking entitlement access, use the /value endpoint instead.
|
|
3618
3752
|
|
|
3619
3753
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3620
3754
|
:type subject_id_or_key: str
|
|
@@ -3681,9 +3815,15 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3681
3815
|
def delete_entitlement( # pylint: disable=inconsistent-return-statements
|
|
3682
3816
|
self, subject_id_or_key: str, entitlement_id: str, **kwargs: Any
|
|
3683
3817
|
) -> None:
|
|
3684
|
-
"""Delete entitlement.
|
|
3818
|
+
"""Delete an entitlement.
|
|
3685
3819
|
|
|
3686
|
-
|
|
3820
|
+
Deleting an entitlement revokes access to the associated feature. As a single subject can only
|
|
3821
|
+
have one entitlement per featureKey, when "migrating" features you have to delete the old
|
|
3822
|
+
entitlements as well.
|
|
3823
|
+
As access and status checks can be historical queries, deleting an entitlement populates the
|
|
3824
|
+
deletedAt timestamp. When queried for a time before that, the entitlement is still considered
|
|
3825
|
+
active, you cannot have retroactive changes to access, which is important for, among other
|
|
3826
|
+
things, auditing.
|
|
3687
3827
|
|
|
3688
3828
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3689
3829
|
:type subject_id_or_key: str
|
|
@@ -3743,7 +3883,8 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3743
3883
|
# pylint: disable=line-too-long
|
|
3744
3884
|
"""List grants for an entitlement.
|
|
3745
3885
|
|
|
3746
|
-
List all grants for an entitlement.
|
|
3886
|
+
List all grants issued for an entitlement. This endpoint is intended for administrative
|
|
3887
|
+
purposes.
|
|
3747
3888
|
|
|
3748
3889
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3749
3890
|
:type subject_id_or_key: str
|
|
@@ -3782,9 +3923,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3782
3923
|
},
|
|
3783
3924
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
3784
3925
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource
|
|
3785
|
-
was last updated.
|
|
3926
|
+
was last updated. The initial value is the same as createdAt. Required.
|
|
3786
3927
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time
|
|
3787
|
-
the resource was deleted.
|
|
3928
|
+
the resource was deleted.
|
|
3788
3929
|
"expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date
|
|
3789
3930
|
of the grant.
|
|
3790
3931
|
"maxRolloverAmount": 0, # Optional. Default value is 0. Grants are
|
|
@@ -3881,9 +4022,29 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3881
4022
|
**kwargs: Any
|
|
3882
4023
|
) -> JSON:
|
|
3883
4024
|
# pylint: disable=line-too-long
|
|
3884
|
-
"""Create grant.
|
|
4025
|
+
"""Create a grant.
|
|
4026
|
+
|
|
4027
|
+
Grants define a behavior of granting usage for a metered entitlement. They can have complicated
|
|
4028
|
+
recurrence and rollover rules, thanks to which you can define a wide range of access patterns
|
|
4029
|
+
with a single grant, in most cases you don't have to periodically create new grants. You can
|
|
4030
|
+
only issue grants for active metered entitlements.
|
|
4031
|
+
|
|
4032
|
+
A grant defines a given amount of usage that can be consumed for the entitlement. The grant is
|
|
4033
|
+
in effect between its effective date and its expiration date. Specifying both is mandatory for
|
|
4034
|
+
new grants.
|
|
4035
|
+
|
|
4036
|
+
Grants have a priority setting that determines their order of use. Lower numbers have higher
|
|
4037
|
+
priority, with 0 being the highest priority.
|
|
4038
|
+
|
|
4039
|
+
Grants can have a recurrence setting intended to automate the manual reissuing of grants. For
|
|
4040
|
+
example, a daily recurrence is equal to reissuing that same grant every day (ignoring rollover
|
|
4041
|
+
settings).
|
|
3885
4042
|
|
|
3886
|
-
|
|
4043
|
+
Rollover settings define what happens to the remaining balance of a grant at a reset.
|
|
4044
|
+
Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
|
|
4045
|
+
|
|
4046
|
+
Grants cannot be changed once created, only deleted. This is to ensure that balance is
|
|
4047
|
+
deterministic regardless of when it is queried.
|
|
3887
4048
|
|
|
3888
4049
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
3889
4050
|
:type subject_id_or_key: str
|
|
@@ -3962,9 +4123,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
3962
4123
|
},
|
|
3963
4124
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
3964
4125
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
3965
|
-
last updated.
|
|
4126
|
+
last updated. The initial value is the same as createdAt. Required.
|
|
3966
4127
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time the
|
|
3967
|
-
resource was deleted.
|
|
4128
|
+
resource was deleted.
|
|
3968
4129
|
"expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date of the
|
|
3969
4130
|
grant.
|
|
3970
4131
|
"maxRolloverAmount": 0, # Optional. Default value is 0. Grants are rolled
|
|
@@ -4015,9 +4176,29 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4015
4176
|
**kwargs: Any
|
|
4016
4177
|
) -> JSON:
|
|
4017
4178
|
# pylint: disable=line-too-long
|
|
4018
|
-
"""Create grant.
|
|
4179
|
+
"""Create a grant.
|
|
4180
|
+
|
|
4181
|
+
Grants define a behavior of granting usage for a metered entitlement. They can have complicated
|
|
4182
|
+
recurrence and rollover rules, thanks to which you can define a wide range of access patterns
|
|
4183
|
+
with a single grant, in most cases you don't have to periodically create new grants. You can
|
|
4184
|
+
only issue grants for active metered entitlements.
|
|
4185
|
+
|
|
4186
|
+
A grant defines a given amount of usage that can be consumed for the entitlement. The grant is
|
|
4187
|
+
in effect between its effective date and its expiration date. Specifying both is mandatory for
|
|
4188
|
+
new grants.
|
|
4189
|
+
|
|
4190
|
+
Grants have a priority setting that determines their order of use. Lower numbers have higher
|
|
4191
|
+
priority, with 0 being the highest priority.
|
|
4192
|
+
|
|
4193
|
+
Grants can have a recurrence setting intended to automate the manual reissuing of grants. For
|
|
4194
|
+
example, a daily recurrence is equal to reissuing that same grant every day (ignoring rollover
|
|
4195
|
+
settings).
|
|
4196
|
+
|
|
4197
|
+
Rollover settings define what happens to the remaining balance of a grant at a reset.
|
|
4198
|
+
Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
|
|
4019
4199
|
|
|
4020
|
-
|
|
4200
|
+
Grants cannot be changed once created, only deleted. This is to ensure that balance is
|
|
4201
|
+
deterministic regardless of when it is queried.
|
|
4021
4202
|
|
|
4022
4203
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
4023
4204
|
:type subject_id_or_key: str
|
|
@@ -4052,9 +4233,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4052
4233
|
},
|
|
4053
4234
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
4054
4235
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
4055
|
-
last updated.
|
|
4236
|
+
last updated. The initial value is the same as createdAt. Required.
|
|
4056
4237
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time the
|
|
4057
|
-
resource was deleted.
|
|
4238
|
+
resource was deleted.
|
|
4058
4239
|
"expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date of the
|
|
4059
4240
|
grant.
|
|
4060
4241
|
"maxRolloverAmount": 0, # Optional. Default value is 0. Grants are rolled
|
|
@@ -4099,9 +4280,29 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4099
4280
|
self, subject_id_or_key: str, entitlement_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any
|
|
4100
4281
|
) -> JSON:
|
|
4101
4282
|
# pylint: disable=line-too-long
|
|
4102
|
-
"""Create grant.
|
|
4283
|
+
"""Create a grant.
|
|
4103
4284
|
|
|
4104
|
-
|
|
4285
|
+
Grants define a behavior of granting usage for a metered entitlement. They can have complicated
|
|
4286
|
+
recurrence and rollover rules, thanks to which you can define a wide range of access patterns
|
|
4287
|
+
with a single grant, in most cases you don't have to periodically create new grants. You can
|
|
4288
|
+
only issue grants for active metered entitlements.
|
|
4289
|
+
|
|
4290
|
+
A grant defines a given amount of usage that can be consumed for the entitlement. The grant is
|
|
4291
|
+
in effect between its effective date and its expiration date. Specifying both is mandatory for
|
|
4292
|
+
new grants.
|
|
4293
|
+
|
|
4294
|
+
Grants have a priority setting that determines their order of use. Lower numbers have higher
|
|
4295
|
+
priority, with 0 being the highest priority.
|
|
4296
|
+
|
|
4297
|
+
Grants can have a recurrence setting intended to automate the manual reissuing of grants. For
|
|
4298
|
+
example, a daily recurrence is equal to reissuing that same grant every day (ignoring rollover
|
|
4299
|
+
settings).
|
|
4300
|
+
|
|
4301
|
+
Rollover settings define what happens to the remaining balance of a grant at a reset.
|
|
4302
|
+
Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
|
|
4303
|
+
|
|
4304
|
+
Grants cannot be changed once created, only deleted. This is to ensure that balance is
|
|
4305
|
+
deterministic regardless of when it is queried.
|
|
4105
4306
|
|
|
4106
4307
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
4107
4308
|
:type subject_id_or_key: str
|
|
@@ -4177,9 +4378,9 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4177
4378
|
},
|
|
4178
4379
|
"id": "str", # Readonly unique ULID identifier. Required.
|
|
4179
4380
|
"updatedAt": "2020-02-20 00:00:00", # The date and time the resource was
|
|
4180
|
-
last updated.
|
|
4381
|
+
last updated. The initial value is the same as createdAt. Required.
|
|
4181
4382
|
"deletedAt": "2020-02-20 00:00:00", # Optional. The date and time the
|
|
4182
|
-
resource was deleted.
|
|
4383
|
+
resource was deleted.
|
|
4183
4384
|
"expiresAt": "2020-02-20 00:00:00", # Optional. The expiration date of the
|
|
4184
4385
|
grant.
|
|
4185
4386
|
"maxRolloverAmount": 0, # Optional. Default value is 0. Grants are rolled
|
|
@@ -4285,9 +4486,14 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4285
4486
|
time: Optional[datetime.datetime] = None,
|
|
4286
4487
|
**kwargs: Any
|
|
4287
4488
|
) -> JSON:
|
|
4288
|
-
|
|
4489
|
+
# pylint: disable=line-too-long
|
|
4490
|
+
"""Get the current value and access of an entitlement.
|
|
4289
4491
|
|
|
4290
|
-
|
|
4492
|
+
This endpoint should be used for access checks and enforcement. All entitlement types share the
|
|
4493
|
+
hasAccess property in their value response, but multiple other properties are returned based on
|
|
4494
|
+
the entitlement type.
|
|
4495
|
+
|
|
4496
|
+
For convenience reasons, /value works with both entitlementId and featureKey.
|
|
4291
4497
|
|
|
4292
4498
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
4293
4499
|
:type subject_id_or_key: str
|
|
@@ -4306,14 +4512,20 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4306
4512
|
|
|
4307
4513
|
# response body for status code(s): 200
|
|
4308
4514
|
response == {
|
|
4309
|
-
"hasAccess": bool, # Whether the subject has access to the feature.
|
|
4310
|
-
Required.
|
|
4311
|
-
"balance": 0.0, # Optional.
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
"
|
|
4316
|
-
|
|
4515
|
+
"hasAccess": bool, # Whether the subject has access to the feature. Shared
|
|
4516
|
+
accross all entitlement types. Required.
|
|
4517
|
+
"balance": 0.0, # Optional. Only available for metered entitlements. Metered
|
|
4518
|
+
entitlements are built around a balance calculation where feature usage is
|
|
4519
|
+
deducted from the issued grants. Balance represents the remaining balance of the
|
|
4520
|
+
entitlement, it's value never turns negative.
|
|
4521
|
+
"config": "str", # Optional. Only available for static entitlements. The
|
|
4522
|
+
JSON parsable config of the entitlement.
|
|
4523
|
+
"overage": 0.0, # Optional. Only available for metered entitlements. Overage
|
|
4524
|
+
represents the usage that wasn't covered by grants, e.g. if the subject had a
|
|
4525
|
+
total feature usage of 100 in the period but they were only granted 80, there
|
|
4526
|
+
would be 20 overage.
|
|
4527
|
+
"usage": 0.0 # Optional. Only available for metered entitlements. Returns
|
|
4528
|
+
the total feature usage in the current period.
|
|
4317
4529
|
}
|
|
4318
4530
|
"""
|
|
4319
4531
|
error_map = {
|
|
@@ -4377,10 +4589,14 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4377
4589
|
# pylint: disable=line-too-long
|
|
4378
4590
|
"""Get the balance history of a specific entitlement.
|
|
4379
4591
|
|
|
4380
|
-
|
|
4592
|
+
Returns historical balance and usage data for the entitlement. The queried history can span
|
|
4593
|
+
accross multiple reset events.
|
|
4594
|
+
|
|
4595
|
+
BurndownHistory returns a continous history of segments, where the segments are seperated by
|
|
4596
|
+
events that changed either the grant burndown priority or the usage period.
|
|
4381
4597
|
|
|
4382
|
-
|
|
4383
|
-
|
|
4598
|
+
WindowedHistory returns windowed usage data for the period enriched with balance information
|
|
4599
|
+
and the list of grants that were being burnt down in that window.
|
|
4384
4600
|
|
|
4385
4601
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
4386
4602
|
:type subject_id_or_key: str
|
|
@@ -4522,9 +4738,16 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4522
4738
|
**kwargs: Any
|
|
4523
4739
|
) -> None:
|
|
4524
4740
|
# pylint: disable=line-too-long
|
|
4525
|
-
"""Reset entitlement.
|
|
4741
|
+
"""Reset an entitlement.
|
|
4526
4742
|
|
|
4527
|
-
Reset the
|
|
4743
|
+
Reset marks the start of a new usage period for the entitlement and initiates grant rollover.
|
|
4744
|
+
At the start of a period usage is zerod out and grants are rolled over based on their rollover
|
|
4745
|
+
settings. It would typically be synced with the subjects billing period to enforce usage based
|
|
4746
|
+
on their subscription.
|
|
4747
|
+
|
|
4748
|
+
Usage is automatically reset for metered entitlements based on their usage period, but this
|
|
4749
|
+
endpoint allows to manually reset it at any time. When doing so the period anchor of the
|
|
4750
|
+
entitlement can be changed if needed.
|
|
4528
4751
|
|
|
4529
4752
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
4530
4753
|
:type subject_id_or_key: str
|
|
@@ -4546,10 +4769,12 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4546
4769
|
body = {
|
|
4547
4770
|
"effectiveAt": "2020-02-20 00:00:00", # Optional. The time at which the
|
|
4548
4771
|
reset takes effect, defaults to now. The reset cannot be in the future. The
|
|
4549
|
-
provided value is truncated to the
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4772
|
+
provided value is truncated to the minute due to how historical meter data is
|
|
4773
|
+
stored.
|
|
4774
|
+
"retainAnchor": bool # Optional. Determines whether the usage period anchor
|
|
4775
|
+
is retained or reset to the effectiveAt time. * If true, the usage period
|
|
4776
|
+
anchor is retained. * If false, the usage period anchor is reset to the
|
|
4777
|
+
effectiveAt time.
|
|
4553
4778
|
}
|
|
4554
4779
|
"""
|
|
4555
4780
|
|
|
@@ -4563,9 +4788,16 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4563
4788
|
content_type: str = "application/json",
|
|
4564
4789
|
**kwargs: Any
|
|
4565
4790
|
) -> None:
|
|
4566
|
-
"""Reset entitlement.
|
|
4791
|
+
"""Reset an entitlement.
|
|
4792
|
+
|
|
4793
|
+
Reset marks the start of a new usage period for the entitlement and initiates grant rollover.
|
|
4794
|
+
At the start of a period usage is zerod out and grants are rolled over based on their rollover
|
|
4795
|
+
settings. It would typically be synced with the subjects billing period to enforce usage based
|
|
4796
|
+
on their subscription.
|
|
4567
4797
|
|
|
4568
|
-
|
|
4798
|
+
Usage is automatically reset for metered entitlements based on their usage period, but this
|
|
4799
|
+
endpoint allows to manually reset it at any time. When doing so the period anchor of the
|
|
4800
|
+
entitlement can be changed if needed.
|
|
4569
4801
|
|
|
4570
4802
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
4571
4803
|
:type subject_id_or_key: str
|
|
@@ -4586,9 +4818,16 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4586
4818
|
self, subject_id_or_key: str, entitlement_id: str, body: Union[JSON, IO[bytes]], **kwargs: Any
|
|
4587
4819
|
) -> None:
|
|
4588
4820
|
# pylint: disable=line-too-long
|
|
4589
|
-
"""Reset entitlement.
|
|
4821
|
+
"""Reset an entitlement.
|
|
4822
|
+
|
|
4823
|
+
Reset marks the start of a new usage period for the entitlement and initiates grant rollover.
|
|
4824
|
+
At the start of a period usage is zerod out and grants are rolled over based on their rollover
|
|
4825
|
+
settings. It would typically be synced with the subjects billing period to enforce usage based
|
|
4826
|
+
on their subscription.
|
|
4590
4827
|
|
|
4591
|
-
|
|
4828
|
+
Usage is automatically reset for metered entitlements based on their usage period, but this
|
|
4829
|
+
endpoint allows to manually reset it at any time. When doing so the period anchor of the
|
|
4830
|
+
entitlement can be changed if needed.
|
|
4592
4831
|
|
|
4593
4832
|
:param subject_id_or_key: A unique identifier for a subject. Required.
|
|
4594
4833
|
:type subject_id_or_key: str
|
|
@@ -4607,10 +4846,12 @@ class ClientOperationsMixin(ClientMixinABC): # pylint: disable=too-many-public-
|
|
|
4607
4846
|
body = {
|
|
4608
4847
|
"effectiveAt": "2020-02-20 00:00:00", # Optional. The time at which the
|
|
4609
4848
|
reset takes effect, defaults to now. The reset cannot be in the future. The
|
|
4610
|
-
provided value is truncated to the
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4849
|
+
provided value is truncated to the minute due to how historical meter data is
|
|
4850
|
+
stored.
|
|
4851
|
+
"retainAnchor": bool # Optional. Determines whether the usage period anchor
|
|
4852
|
+
is retained or reset to the effectiveAt time. * If true, the usage period
|
|
4853
|
+
anchor is retained. * If false, the usage period anchor is reset to the
|
|
4854
|
+
effectiveAt time.
|
|
4614
4855
|
}
|
|
4615
4856
|
"""
|
|
4616
4857
|
error_map = {
|