openmeter 1.0.0b53__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openmeter might be problematic. Click here for more details.
- openmeter/__init__.py +89 -15
- openmeter/_base_client.py +2041 -0
- openmeter/_client.py +518 -70
- openmeter/_compat.py +221 -0
- openmeter/_constants.py +14 -0
- openmeter/_exceptions.py +108 -0
- openmeter/_files.py +127 -0
- openmeter/_models.py +777 -0
- openmeter/_qs.py +150 -0
- openmeter/_resource.py +43 -0
- openmeter/_response.py +820 -0
- openmeter/_streaming.py +333 -0
- openmeter/_types.py +222 -0
- openmeter/_utils/__init__.py +56 -0
- openmeter/_utils/_logs.py +25 -0
- openmeter/_utils/_proxy.py +63 -0
- openmeter/_utils/_reflection.py +42 -0
- openmeter/_utils/_streams.py +12 -0
- openmeter/_utils/_sync.py +81 -0
- openmeter/_utils/_transform.py +387 -0
- openmeter/_utils/_typing.py +120 -0
- openmeter/_utils/_utils.py +419 -0
- openmeter/_version.py +4 -0
- openmeter/lib/.keep +4 -0
- openmeter/py.typed +0 -1
- openmeter/resources/__init__.py +103 -0
- openmeter/resources/debug/__init__.py +33 -0
- openmeter/resources/debug/debug.py +102 -0
- openmeter/resources/debug/metrics.py +146 -0
- openmeter/resources/entitlements/__init__.py +47 -0
- openmeter/resources/entitlements/entitlements.py +450 -0
- openmeter/resources/entitlements/features.py +578 -0
- openmeter/resources/entitlements/grants.py +389 -0
- openmeter/resources/events.py +442 -0
- openmeter/resources/meters/__init__.py +33 -0
- openmeter/resources/meters/meters.py +666 -0
- openmeter/resources/meters/subjects.py +163 -0
- openmeter/resources/notifications/__init__.py +75 -0
- openmeter/resources/notifications/channels.py +686 -0
- openmeter/resources/notifications/events.py +365 -0
- openmeter/resources/notifications/notifications.py +198 -0
- openmeter/resources/notifications/rules.py +781 -0
- openmeter/resources/notifications/webhook.py +208 -0
- openmeter/resources/portal/__init__.py +47 -0
- openmeter/resources/portal/meters.py +230 -0
- openmeter/resources/portal/portal.py +112 -0
- openmeter/resources/portal/tokens.py +359 -0
- openmeter/resources/subjects/entitlements/__init__.py +33 -0
- openmeter/resources/subjects/entitlements/entitlements.py +1881 -0
- openmeter/resources/subjects/entitlements/grants.py +453 -0
- openmeter/resources/subjects.py +419 -0
- openmeter/types/__init__.py +21 -0
- openmeter/types/debug/__init__.py +5 -0
- openmeter/types/debug/metric_list_response.py +7 -0
- openmeter/types/entitlement.py +238 -0
- openmeter/types/entitlements/__init__.py +11 -0
- openmeter/types/entitlements/feature.py +61 -0
- openmeter/types/entitlements/feature_create_params.py +43 -0
- openmeter/types/entitlements/feature_list_params.py +23 -0
- openmeter/types/entitlements/grant_list_params.py +57 -0
- openmeter/types/entitlements/grant_list_response.py +11 -0
- openmeter/types/entitlements/grant_paginated_response.py +24 -0
- openmeter/types/entitlements/list_features_result.py +28 -0
- openmeter/types/event_ingest_params.py +46 -0
- openmeter/types/event_ingest_response.py +43 -0
- openmeter/types/event_list_params.py +22 -0
- openmeter/types/event_list_response.py +9 -0
- openmeter/types/ingested_event.py +59 -0
- openmeter/types/list_entitlements_result.py +28 -0
- openmeter/types/meter.py +53 -0
- openmeter/types/meter_create_params.py +50 -0
- openmeter/types/meter_list_response.py +9 -0
- openmeter/types/meter_query_params.py +50 -0
- openmeter/types/meter_query_result.py +35 -0
- openmeter/types/meters/__init__.py +5 -0
- openmeter/types/meters/subject_list_response.py +8 -0
- openmeter/types/notifications/__init__.py +18 -0
- openmeter/types/notifications/channel_create_params.py +34 -0
- openmeter/types/notifications/channel_list_params.py +41 -0
- openmeter/types/notifications/channel_list_response.py +24 -0
- openmeter/types/notifications/channel_update_params.py +34 -0
- openmeter/types/notifications/event_list_params.py +61 -0
- openmeter/types/notifications/event_list_response.py +24 -0
- openmeter/types/notifications/notification_channel.py +47 -0
- openmeter/types/notifications/notification_event.py +215 -0
- openmeter/types/notifications/notification_rule.py +70 -0
- openmeter/types/notifications/rule_create_params.py +39 -0
- openmeter/types/notifications/rule_list_params.py +54 -0
- openmeter/types/notifications/rule_list_response.py +24 -0
- openmeter/types/notifications/rule_update_params.py +39 -0
- openmeter/types/notifications/webhook_svix_params.py +26 -0
- openmeter/types/portal/__init__.py +10 -0
- openmeter/types/portal/meter_query_params.py +44 -0
- openmeter/types/portal/portal_token.py +28 -0
- openmeter/types/portal/token_create_params.py +17 -0
- openmeter/types/portal/token_invalidate_params.py +15 -0
- openmeter/types/portal/token_list_params.py +12 -0
- openmeter/types/portal/token_list_response.py +9 -0
- openmeter/types/shared/__init__.py +3 -0
- openmeter/types/subject.py +37 -0
- openmeter/types/subject_list_response.py +9 -0
- openmeter/types/subject_param.py +27 -0
- openmeter/types/subject_upsert_params.py +39 -0
- openmeter/types/subject_upsert_response.py +10 -0
- openmeter/types/subjects/__init__.py +13 -0
- openmeter/types/subjects/entitlement_history_params.py +35 -0
- openmeter/types/subjects/entitlement_history_response.py +98 -0
- openmeter/types/subjects/entitlement_list_response.py +10 -0
- openmeter/types/subjects/entitlements/__init__.py +8 -0
- openmeter/types/subjects/entitlements/entitlement_grant.py +103 -0
- openmeter/types/subjects/entitlements/grant_list_response.py +10 -0
- openmeter-2.0.0.dist-info/METADATA +396 -0
- openmeter-2.0.0.dist-info/RECORD +115 -0
- {openmeter-1.0.0b53.dist-info → openmeter-2.0.0.dist-info}/WHEEL +1 -1
- openmeter-2.0.0.dist-info/licenses/LICENSE +201 -0
- openmeter/_configuration.py +0 -36
- openmeter/_operations/__init__.py +0 -17
- openmeter/_operations/_operations.py +0 -2098
- openmeter/_operations/_patch.py +0 -20
- openmeter/_patch.py +0 -20
- openmeter/_serialization.py +0 -2008
- openmeter/_vendor.py +0 -24
- openmeter/aio/__init__.py +0 -21
- openmeter/aio/_client.py +0 -83
- openmeter/aio/_configuration.py +0 -36
- openmeter/aio/_operations/__init__.py +0 -17
- openmeter/aio/_operations/_operations.py +0 -1771
- openmeter/aio/_operations/_patch.py +0 -20
- openmeter/aio/_patch.py +0 -20
- openmeter/aio/_vendor.py +0 -24
- openmeter-1.0.0b53.dist-info/METADATA +0 -92
- openmeter-1.0.0b53.dist-info/RECORD +0 -21
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
8
|
+
from ..._compat import cached_property
|
|
9
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
10
|
+
from ..._response import (
|
|
11
|
+
to_raw_response_wrapper,
|
|
12
|
+
to_streamed_response_wrapper,
|
|
13
|
+
async_to_raw_response_wrapper,
|
|
14
|
+
async_to_streamed_response_wrapper,
|
|
15
|
+
)
|
|
16
|
+
from ..._base_client import make_request_options
|
|
17
|
+
|
|
18
|
+
__all__ = ["MetricsResource", "AsyncMetricsResource"]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class MetricsResource(SyncAPIResource):
|
|
22
|
+
@cached_property
|
|
23
|
+
def with_raw_response(self) -> MetricsResourceWithRawResponse:
|
|
24
|
+
"""
|
|
25
|
+
This property can be used as a prefix for any HTTP method call to return the
|
|
26
|
+
the raw response object instead of the parsed content.
|
|
27
|
+
|
|
28
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
|
|
29
|
+
"""
|
|
30
|
+
return MetricsResourceWithRawResponse(self)
|
|
31
|
+
|
|
32
|
+
@cached_property
|
|
33
|
+
def with_streaming_response(self) -> MetricsResourceWithStreamingResponse:
|
|
34
|
+
"""
|
|
35
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
36
|
+
|
|
37
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
|
|
38
|
+
"""
|
|
39
|
+
return MetricsResourceWithStreamingResponse(self)
|
|
40
|
+
|
|
41
|
+
def list(
|
|
42
|
+
self,
|
|
43
|
+
*,
|
|
44
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
45
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
46
|
+
extra_headers: Headers | None = None,
|
|
47
|
+
extra_query: Query | None = None,
|
|
48
|
+
extra_body: Body | None = None,
|
|
49
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
50
|
+
) -> str:
|
|
51
|
+
"""
|
|
52
|
+
Returns debug metrics (in OpenMetrics format) like the number of ingested events
|
|
53
|
+
since mindnight UTC.
|
|
54
|
+
|
|
55
|
+
The OpenMetrics Counter(s) reset every day at midnight UTC.
|
|
56
|
+
"""
|
|
57
|
+
extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
|
|
58
|
+
return self._get(
|
|
59
|
+
"/api/v1/debug/metrics",
|
|
60
|
+
options=make_request_options(
|
|
61
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
62
|
+
),
|
|
63
|
+
cast_to=str,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class AsyncMetricsResource(AsyncAPIResource):
|
|
68
|
+
@cached_property
|
|
69
|
+
def with_raw_response(self) -> AsyncMetricsResourceWithRawResponse:
|
|
70
|
+
"""
|
|
71
|
+
This property can be used as a prefix for any HTTP method call to return the
|
|
72
|
+
the raw response object instead of the parsed content.
|
|
73
|
+
|
|
74
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
|
|
75
|
+
"""
|
|
76
|
+
return AsyncMetricsResourceWithRawResponse(self)
|
|
77
|
+
|
|
78
|
+
@cached_property
|
|
79
|
+
def with_streaming_response(self) -> AsyncMetricsResourceWithStreamingResponse:
|
|
80
|
+
"""
|
|
81
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
82
|
+
|
|
83
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
|
|
84
|
+
"""
|
|
85
|
+
return AsyncMetricsResourceWithStreamingResponse(self)
|
|
86
|
+
|
|
87
|
+
async def list(
|
|
88
|
+
self,
|
|
89
|
+
*,
|
|
90
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
91
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
92
|
+
extra_headers: Headers | None = None,
|
|
93
|
+
extra_query: Query | None = None,
|
|
94
|
+
extra_body: Body | None = None,
|
|
95
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
96
|
+
) -> str:
|
|
97
|
+
"""
|
|
98
|
+
Returns debug metrics (in OpenMetrics format) like the number of ingested events
|
|
99
|
+
since mindnight UTC.
|
|
100
|
+
|
|
101
|
+
The OpenMetrics Counter(s) reset every day at midnight UTC.
|
|
102
|
+
"""
|
|
103
|
+
extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
|
|
104
|
+
return await self._get(
|
|
105
|
+
"/api/v1/debug/metrics",
|
|
106
|
+
options=make_request_options(
|
|
107
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
108
|
+
),
|
|
109
|
+
cast_to=str,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class MetricsResourceWithRawResponse:
|
|
114
|
+
def __init__(self, metrics: MetricsResource) -> None:
|
|
115
|
+
self._metrics = metrics
|
|
116
|
+
|
|
117
|
+
self.list = to_raw_response_wrapper(
|
|
118
|
+
metrics.list,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class AsyncMetricsResourceWithRawResponse:
|
|
123
|
+
def __init__(self, metrics: AsyncMetricsResource) -> None:
|
|
124
|
+
self._metrics = metrics
|
|
125
|
+
|
|
126
|
+
self.list = async_to_raw_response_wrapper(
|
|
127
|
+
metrics.list,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class MetricsResourceWithStreamingResponse:
|
|
132
|
+
def __init__(self, metrics: MetricsResource) -> None:
|
|
133
|
+
self._metrics = metrics
|
|
134
|
+
|
|
135
|
+
self.list = to_streamed_response_wrapper(
|
|
136
|
+
metrics.list,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class AsyncMetricsResourceWithStreamingResponse:
|
|
141
|
+
def __init__(self, metrics: AsyncMetricsResource) -> None:
|
|
142
|
+
self._metrics = metrics
|
|
143
|
+
|
|
144
|
+
self.list = async_to_streamed_response_wrapper(
|
|
145
|
+
metrics.list,
|
|
146
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from .grants import (
|
|
4
|
+
GrantsResource,
|
|
5
|
+
AsyncGrantsResource,
|
|
6
|
+
GrantsResourceWithRawResponse,
|
|
7
|
+
AsyncGrantsResourceWithRawResponse,
|
|
8
|
+
GrantsResourceWithStreamingResponse,
|
|
9
|
+
AsyncGrantsResourceWithStreamingResponse,
|
|
10
|
+
)
|
|
11
|
+
from .features import (
|
|
12
|
+
FeaturesResource,
|
|
13
|
+
AsyncFeaturesResource,
|
|
14
|
+
FeaturesResourceWithRawResponse,
|
|
15
|
+
AsyncFeaturesResourceWithRawResponse,
|
|
16
|
+
FeaturesResourceWithStreamingResponse,
|
|
17
|
+
AsyncFeaturesResourceWithStreamingResponse,
|
|
18
|
+
)
|
|
19
|
+
from .entitlements import (
|
|
20
|
+
EntitlementsResource,
|
|
21
|
+
AsyncEntitlementsResource,
|
|
22
|
+
EntitlementsResourceWithRawResponse,
|
|
23
|
+
AsyncEntitlementsResourceWithRawResponse,
|
|
24
|
+
EntitlementsResourceWithStreamingResponse,
|
|
25
|
+
AsyncEntitlementsResourceWithStreamingResponse,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"FeaturesResource",
|
|
30
|
+
"AsyncFeaturesResource",
|
|
31
|
+
"FeaturesResourceWithRawResponse",
|
|
32
|
+
"AsyncFeaturesResourceWithRawResponse",
|
|
33
|
+
"FeaturesResourceWithStreamingResponse",
|
|
34
|
+
"AsyncFeaturesResourceWithStreamingResponse",
|
|
35
|
+
"GrantsResource",
|
|
36
|
+
"AsyncGrantsResource",
|
|
37
|
+
"GrantsResourceWithRawResponse",
|
|
38
|
+
"AsyncGrantsResourceWithRawResponse",
|
|
39
|
+
"GrantsResourceWithStreamingResponse",
|
|
40
|
+
"AsyncGrantsResourceWithStreamingResponse",
|
|
41
|
+
"EntitlementsResource",
|
|
42
|
+
"AsyncEntitlementsResource",
|
|
43
|
+
"EntitlementsResourceWithRawResponse",
|
|
44
|
+
"AsyncEntitlementsResourceWithRawResponse",
|
|
45
|
+
"EntitlementsResourceWithStreamingResponse",
|
|
46
|
+
"AsyncEntitlementsResourceWithStreamingResponse",
|
|
47
|
+
]
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, List, cast
|
|
6
|
+
from typing_extensions import Literal
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
|
|
10
|
+
from .grants import (
|
|
11
|
+
GrantsResource,
|
|
12
|
+
AsyncGrantsResource,
|
|
13
|
+
GrantsResourceWithRawResponse,
|
|
14
|
+
AsyncGrantsResourceWithRawResponse,
|
|
15
|
+
GrantsResourceWithStreamingResponse,
|
|
16
|
+
AsyncGrantsResourceWithStreamingResponse,
|
|
17
|
+
)
|
|
18
|
+
from ...types import entitlement_list_params
|
|
19
|
+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
20
|
+
from ..._utils import (
|
|
21
|
+
maybe_transform,
|
|
22
|
+
async_maybe_transform,
|
|
23
|
+
)
|
|
24
|
+
from .features import (
|
|
25
|
+
FeaturesResource,
|
|
26
|
+
AsyncFeaturesResource,
|
|
27
|
+
FeaturesResourceWithRawResponse,
|
|
28
|
+
AsyncFeaturesResourceWithRawResponse,
|
|
29
|
+
FeaturesResourceWithStreamingResponse,
|
|
30
|
+
AsyncFeaturesResourceWithStreamingResponse,
|
|
31
|
+
)
|
|
32
|
+
from ..._compat import cached_property
|
|
33
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
34
|
+
from ..._response import (
|
|
35
|
+
to_raw_response_wrapper,
|
|
36
|
+
to_streamed_response_wrapper,
|
|
37
|
+
async_to_raw_response_wrapper,
|
|
38
|
+
async_to_streamed_response_wrapper,
|
|
39
|
+
)
|
|
40
|
+
from ..._base_client import make_request_options
|
|
41
|
+
from ...types.entitlement import Entitlement
|
|
42
|
+
from ...types.list_entitlements_result import ListEntitlementsResult
|
|
43
|
+
|
|
44
|
+
__all__ = ["EntitlementsResource", "AsyncEntitlementsResource"]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class EntitlementsResource(SyncAPIResource):
|
|
48
|
+
@cached_property
|
|
49
|
+
def features(self) -> FeaturesResource:
|
|
50
|
+
return FeaturesResource(self._client)
|
|
51
|
+
|
|
52
|
+
@cached_property
|
|
53
|
+
def grants(self) -> GrantsResource:
|
|
54
|
+
return GrantsResource(self._client)
|
|
55
|
+
|
|
56
|
+
@cached_property
|
|
57
|
+
def with_raw_response(self) -> EntitlementsResourceWithRawResponse:
|
|
58
|
+
"""
|
|
59
|
+
This property can be used as a prefix for any HTTP method call to return the
|
|
60
|
+
the raw response object instead of the parsed content.
|
|
61
|
+
|
|
62
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
|
|
63
|
+
"""
|
|
64
|
+
return EntitlementsResourceWithRawResponse(self)
|
|
65
|
+
|
|
66
|
+
@cached_property
|
|
67
|
+
def with_streaming_response(self) -> EntitlementsResourceWithStreamingResponse:
|
|
68
|
+
"""
|
|
69
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
70
|
+
|
|
71
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
|
|
72
|
+
"""
|
|
73
|
+
return EntitlementsResourceWithStreamingResponse(self)
|
|
74
|
+
|
|
75
|
+
def retrieve(
|
|
76
|
+
self,
|
|
77
|
+
entitlement_id: str,
|
|
78
|
+
*,
|
|
79
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
80
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
81
|
+
extra_headers: Headers | None = None,
|
|
82
|
+
extra_query: Query | None = None,
|
|
83
|
+
extra_body: Body | None = None,
|
|
84
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
85
|
+
) -> Entitlement:
|
|
86
|
+
"""
|
|
87
|
+
Get entitlement by id.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
extra_headers: Send extra headers
|
|
91
|
+
|
|
92
|
+
extra_query: Add additional query parameters to the request
|
|
93
|
+
|
|
94
|
+
extra_body: Add additional JSON properties to the request
|
|
95
|
+
|
|
96
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
97
|
+
"""
|
|
98
|
+
if not entitlement_id:
|
|
99
|
+
raise ValueError(f"Expected a non-empty value for `entitlement_id` but received {entitlement_id!r}")
|
|
100
|
+
return cast(
|
|
101
|
+
Entitlement,
|
|
102
|
+
self._get(
|
|
103
|
+
f"/api/v1/entitlements/{entitlement_id}",
|
|
104
|
+
options=make_request_options(
|
|
105
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
106
|
+
),
|
|
107
|
+
cast_to=cast(Any, Entitlement), # Union types cannot be passed in as arguments in the type system
|
|
108
|
+
),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def list(
|
|
112
|
+
self,
|
|
113
|
+
*,
|
|
114
|
+
entitlement_type: List[Literal["metered", "boolean", "static"]] | NotGiven = NOT_GIVEN,
|
|
115
|
+
feature: List[str] | NotGiven = NOT_GIVEN,
|
|
116
|
+
limit: int | NotGiven = NOT_GIVEN,
|
|
117
|
+
offset: int | NotGiven = NOT_GIVEN,
|
|
118
|
+
order: Literal["ASC", "DESC"] | NotGiven = NOT_GIVEN,
|
|
119
|
+
order_by: Literal["createdAt", "updatedAt"] | NotGiven = NOT_GIVEN,
|
|
120
|
+
page: int | NotGiven = NOT_GIVEN,
|
|
121
|
+
page_size: int | NotGiven = NOT_GIVEN,
|
|
122
|
+
subject: List[str] | NotGiven = NOT_GIVEN,
|
|
123
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
124
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
125
|
+
extra_headers: Headers | None = None,
|
|
126
|
+
extra_query: Query | None = None,
|
|
127
|
+
extra_body: Body | None = None,
|
|
128
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
129
|
+
) -> ListEntitlementsResult:
|
|
130
|
+
"""List all entitlements for all the subjects and features.
|
|
131
|
+
|
|
132
|
+
This endpoint is
|
|
133
|
+
intended for administrative purposes only. To fetch the entitlements of a
|
|
134
|
+
specific subject please use the /api/v1/subjects/{subjectKeyOrID}/entitlements
|
|
135
|
+
endpoint. If page is provided that takes precedence and the paginated response
|
|
136
|
+
is returned.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
entitlement_type: Filtering by multiple entitlement types.
|
|
140
|
+
|
|
141
|
+
Usage: `?entitlementType=metered&entitlementType=boolean`
|
|
142
|
+
|
|
143
|
+
feature: Filtering by multiple features.
|
|
144
|
+
|
|
145
|
+
Usage: `?feature=feature-1&feature=feature-2`
|
|
146
|
+
|
|
147
|
+
limit: Number of items to return.
|
|
148
|
+
|
|
149
|
+
Default is 100.
|
|
150
|
+
|
|
151
|
+
offset: Number of items to skip.
|
|
152
|
+
|
|
153
|
+
Default is 0.
|
|
154
|
+
|
|
155
|
+
order: The order direction.
|
|
156
|
+
|
|
157
|
+
order_by: The order by field.
|
|
158
|
+
|
|
159
|
+
page: Start date-time in RFC 3339 format.
|
|
160
|
+
|
|
161
|
+
Inclusive.
|
|
162
|
+
|
|
163
|
+
page_size: Number of items per page.
|
|
164
|
+
|
|
165
|
+
Default is 100.
|
|
166
|
+
|
|
167
|
+
subject: Filtering by multiple subjects.
|
|
168
|
+
|
|
169
|
+
Usage: `?subject=customer-1&subject=customer-2`
|
|
170
|
+
|
|
171
|
+
extra_headers: Send extra headers
|
|
172
|
+
|
|
173
|
+
extra_query: Add additional query parameters to the request
|
|
174
|
+
|
|
175
|
+
extra_body: Add additional JSON properties to the request
|
|
176
|
+
|
|
177
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
178
|
+
"""
|
|
179
|
+
return cast(
|
|
180
|
+
ListEntitlementsResult,
|
|
181
|
+
self._get(
|
|
182
|
+
"/api/v1/entitlements",
|
|
183
|
+
options=make_request_options(
|
|
184
|
+
extra_headers=extra_headers,
|
|
185
|
+
extra_query=extra_query,
|
|
186
|
+
extra_body=extra_body,
|
|
187
|
+
timeout=timeout,
|
|
188
|
+
query=maybe_transform(
|
|
189
|
+
{
|
|
190
|
+
"entitlement_type": entitlement_type,
|
|
191
|
+
"feature": feature,
|
|
192
|
+
"limit": limit,
|
|
193
|
+
"offset": offset,
|
|
194
|
+
"order": order,
|
|
195
|
+
"order_by": order_by,
|
|
196
|
+
"page": page,
|
|
197
|
+
"page_size": page_size,
|
|
198
|
+
"subject": subject,
|
|
199
|
+
},
|
|
200
|
+
entitlement_list_params.EntitlementListParams,
|
|
201
|
+
),
|
|
202
|
+
),
|
|
203
|
+
cast_to=cast(
|
|
204
|
+
Any, ListEntitlementsResult
|
|
205
|
+
), # Union types cannot be passed in as arguments in the type system
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
class AsyncEntitlementsResource(AsyncAPIResource):
|
|
211
|
+
@cached_property
|
|
212
|
+
def features(self) -> AsyncFeaturesResource:
|
|
213
|
+
return AsyncFeaturesResource(self._client)
|
|
214
|
+
|
|
215
|
+
@cached_property
|
|
216
|
+
def grants(self) -> AsyncGrantsResource:
|
|
217
|
+
return AsyncGrantsResource(self._client)
|
|
218
|
+
|
|
219
|
+
@cached_property
|
|
220
|
+
def with_raw_response(self) -> AsyncEntitlementsResourceWithRawResponse:
|
|
221
|
+
"""
|
|
222
|
+
This property can be used as a prefix for any HTTP method call to return the
|
|
223
|
+
the raw response object instead of the parsed content.
|
|
224
|
+
|
|
225
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
|
|
226
|
+
"""
|
|
227
|
+
return AsyncEntitlementsResourceWithRawResponse(self)
|
|
228
|
+
|
|
229
|
+
@cached_property
|
|
230
|
+
def with_streaming_response(self) -> AsyncEntitlementsResourceWithStreamingResponse:
|
|
231
|
+
"""
|
|
232
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
233
|
+
|
|
234
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
|
|
235
|
+
"""
|
|
236
|
+
return AsyncEntitlementsResourceWithStreamingResponse(self)
|
|
237
|
+
|
|
238
|
+
async def retrieve(
|
|
239
|
+
self,
|
|
240
|
+
entitlement_id: str,
|
|
241
|
+
*,
|
|
242
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
243
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
244
|
+
extra_headers: Headers | None = None,
|
|
245
|
+
extra_query: Query | None = None,
|
|
246
|
+
extra_body: Body | None = None,
|
|
247
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
248
|
+
) -> Entitlement:
|
|
249
|
+
"""
|
|
250
|
+
Get entitlement by id.
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
extra_headers: Send extra headers
|
|
254
|
+
|
|
255
|
+
extra_query: Add additional query parameters to the request
|
|
256
|
+
|
|
257
|
+
extra_body: Add additional JSON properties to the request
|
|
258
|
+
|
|
259
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
260
|
+
"""
|
|
261
|
+
if not entitlement_id:
|
|
262
|
+
raise ValueError(f"Expected a non-empty value for `entitlement_id` but received {entitlement_id!r}")
|
|
263
|
+
return cast(
|
|
264
|
+
Entitlement,
|
|
265
|
+
await self._get(
|
|
266
|
+
f"/api/v1/entitlements/{entitlement_id}",
|
|
267
|
+
options=make_request_options(
|
|
268
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
269
|
+
),
|
|
270
|
+
cast_to=cast(Any, Entitlement), # Union types cannot be passed in as arguments in the type system
|
|
271
|
+
),
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
async def list(
|
|
275
|
+
self,
|
|
276
|
+
*,
|
|
277
|
+
entitlement_type: List[Literal["metered", "boolean", "static"]] | NotGiven = NOT_GIVEN,
|
|
278
|
+
feature: List[str] | NotGiven = NOT_GIVEN,
|
|
279
|
+
limit: int | NotGiven = NOT_GIVEN,
|
|
280
|
+
offset: int | NotGiven = NOT_GIVEN,
|
|
281
|
+
order: Literal["ASC", "DESC"] | NotGiven = NOT_GIVEN,
|
|
282
|
+
order_by: Literal["createdAt", "updatedAt"] | NotGiven = NOT_GIVEN,
|
|
283
|
+
page: int | NotGiven = NOT_GIVEN,
|
|
284
|
+
page_size: int | NotGiven = NOT_GIVEN,
|
|
285
|
+
subject: List[str] | NotGiven = NOT_GIVEN,
|
|
286
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
287
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
288
|
+
extra_headers: Headers | None = None,
|
|
289
|
+
extra_query: Query | None = None,
|
|
290
|
+
extra_body: Body | None = None,
|
|
291
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
292
|
+
) -> ListEntitlementsResult:
|
|
293
|
+
"""List all entitlements for all the subjects and features.
|
|
294
|
+
|
|
295
|
+
This endpoint is
|
|
296
|
+
intended for administrative purposes only. To fetch the entitlements of a
|
|
297
|
+
specific subject please use the /api/v1/subjects/{subjectKeyOrID}/entitlements
|
|
298
|
+
endpoint. If page is provided that takes precedence and the paginated response
|
|
299
|
+
is returned.
|
|
300
|
+
|
|
301
|
+
Args:
|
|
302
|
+
entitlement_type: Filtering by multiple entitlement types.
|
|
303
|
+
|
|
304
|
+
Usage: `?entitlementType=metered&entitlementType=boolean`
|
|
305
|
+
|
|
306
|
+
feature: Filtering by multiple features.
|
|
307
|
+
|
|
308
|
+
Usage: `?feature=feature-1&feature=feature-2`
|
|
309
|
+
|
|
310
|
+
limit: Number of items to return.
|
|
311
|
+
|
|
312
|
+
Default is 100.
|
|
313
|
+
|
|
314
|
+
offset: Number of items to skip.
|
|
315
|
+
|
|
316
|
+
Default is 0.
|
|
317
|
+
|
|
318
|
+
order: The order direction.
|
|
319
|
+
|
|
320
|
+
order_by: The order by field.
|
|
321
|
+
|
|
322
|
+
page: Start date-time in RFC 3339 format.
|
|
323
|
+
|
|
324
|
+
Inclusive.
|
|
325
|
+
|
|
326
|
+
page_size: Number of items per page.
|
|
327
|
+
|
|
328
|
+
Default is 100.
|
|
329
|
+
|
|
330
|
+
subject: Filtering by multiple subjects.
|
|
331
|
+
|
|
332
|
+
Usage: `?subject=customer-1&subject=customer-2`
|
|
333
|
+
|
|
334
|
+
extra_headers: Send extra headers
|
|
335
|
+
|
|
336
|
+
extra_query: Add additional query parameters to the request
|
|
337
|
+
|
|
338
|
+
extra_body: Add additional JSON properties to the request
|
|
339
|
+
|
|
340
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
341
|
+
"""
|
|
342
|
+
return cast(
|
|
343
|
+
ListEntitlementsResult,
|
|
344
|
+
await self._get(
|
|
345
|
+
"/api/v1/entitlements",
|
|
346
|
+
options=make_request_options(
|
|
347
|
+
extra_headers=extra_headers,
|
|
348
|
+
extra_query=extra_query,
|
|
349
|
+
extra_body=extra_body,
|
|
350
|
+
timeout=timeout,
|
|
351
|
+
query=await async_maybe_transform(
|
|
352
|
+
{
|
|
353
|
+
"entitlement_type": entitlement_type,
|
|
354
|
+
"feature": feature,
|
|
355
|
+
"limit": limit,
|
|
356
|
+
"offset": offset,
|
|
357
|
+
"order": order,
|
|
358
|
+
"order_by": order_by,
|
|
359
|
+
"page": page,
|
|
360
|
+
"page_size": page_size,
|
|
361
|
+
"subject": subject,
|
|
362
|
+
},
|
|
363
|
+
entitlement_list_params.EntitlementListParams,
|
|
364
|
+
),
|
|
365
|
+
),
|
|
366
|
+
cast_to=cast(
|
|
367
|
+
Any, ListEntitlementsResult
|
|
368
|
+
), # Union types cannot be passed in as arguments in the type system
|
|
369
|
+
),
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
class EntitlementsResourceWithRawResponse:
|
|
374
|
+
def __init__(self, entitlements: EntitlementsResource) -> None:
|
|
375
|
+
self._entitlements = entitlements
|
|
376
|
+
|
|
377
|
+
self.retrieve = to_raw_response_wrapper(
|
|
378
|
+
entitlements.retrieve,
|
|
379
|
+
)
|
|
380
|
+
self.list = to_raw_response_wrapper(
|
|
381
|
+
entitlements.list,
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
@cached_property
|
|
385
|
+
def features(self) -> FeaturesResourceWithRawResponse:
|
|
386
|
+
return FeaturesResourceWithRawResponse(self._entitlements.features)
|
|
387
|
+
|
|
388
|
+
@cached_property
|
|
389
|
+
def grants(self) -> GrantsResourceWithRawResponse:
|
|
390
|
+
return GrantsResourceWithRawResponse(self._entitlements.grants)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
class AsyncEntitlementsResourceWithRawResponse:
|
|
394
|
+
def __init__(self, entitlements: AsyncEntitlementsResource) -> None:
|
|
395
|
+
self._entitlements = entitlements
|
|
396
|
+
|
|
397
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
398
|
+
entitlements.retrieve,
|
|
399
|
+
)
|
|
400
|
+
self.list = async_to_raw_response_wrapper(
|
|
401
|
+
entitlements.list,
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
@cached_property
|
|
405
|
+
def features(self) -> AsyncFeaturesResourceWithRawResponse:
|
|
406
|
+
return AsyncFeaturesResourceWithRawResponse(self._entitlements.features)
|
|
407
|
+
|
|
408
|
+
@cached_property
|
|
409
|
+
def grants(self) -> AsyncGrantsResourceWithRawResponse:
|
|
410
|
+
return AsyncGrantsResourceWithRawResponse(self._entitlements.grants)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
class EntitlementsResourceWithStreamingResponse:
|
|
414
|
+
def __init__(self, entitlements: EntitlementsResource) -> None:
|
|
415
|
+
self._entitlements = entitlements
|
|
416
|
+
|
|
417
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
418
|
+
entitlements.retrieve,
|
|
419
|
+
)
|
|
420
|
+
self.list = to_streamed_response_wrapper(
|
|
421
|
+
entitlements.list,
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
@cached_property
|
|
425
|
+
def features(self) -> FeaturesResourceWithStreamingResponse:
|
|
426
|
+
return FeaturesResourceWithStreamingResponse(self._entitlements.features)
|
|
427
|
+
|
|
428
|
+
@cached_property
|
|
429
|
+
def grants(self) -> GrantsResourceWithStreamingResponse:
|
|
430
|
+
return GrantsResourceWithStreamingResponse(self._entitlements.grants)
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
class AsyncEntitlementsResourceWithStreamingResponse:
|
|
434
|
+
def __init__(self, entitlements: AsyncEntitlementsResource) -> None:
|
|
435
|
+
self._entitlements = entitlements
|
|
436
|
+
|
|
437
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
438
|
+
entitlements.retrieve,
|
|
439
|
+
)
|
|
440
|
+
self.list = async_to_streamed_response_wrapper(
|
|
441
|
+
entitlements.list,
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
@cached_property
|
|
445
|
+
def features(self) -> AsyncFeaturesResourceWithStreamingResponse:
|
|
446
|
+
return AsyncFeaturesResourceWithStreamingResponse(self._entitlements.features)
|
|
447
|
+
|
|
448
|
+
@cached_property
|
|
449
|
+
def grants(self) -> AsyncGrantsResourceWithStreamingResponse:
|
|
450
|
+
return AsyncGrantsResourceWithStreamingResponse(self._entitlements.grants)
|