openmeter 1.0.0b54__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.0b54.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 -2105
- 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 -1778
- openmeter/aio/_operations/_patch.py +0 -20
- openmeter/aio/_patch.py +0 -20
- openmeter/aio/_vendor.py +0 -24
- openmeter-1.0.0b54.dist-info/METADATA +0 -92
- openmeter-1.0.0b54.dist-info/RECORD +0 -21
|
@@ -0,0 +1,419 @@
|
|
|
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 Iterable
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ...types import subject_upsert_params
|
|
10
|
+
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
|
|
11
|
+
from ..._utils import (
|
|
12
|
+
maybe_transform,
|
|
13
|
+
async_maybe_transform,
|
|
14
|
+
)
|
|
15
|
+
from ..._compat import cached_property
|
|
16
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
17
|
+
from ..._response import (
|
|
18
|
+
to_raw_response_wrapper,
|
|
19
|
+
to_streamed_response_wrapper,
|
|
20
|
+
async_to_raw_response_wrapper,
|
|
21
|
+
async_to_streamed_response_wrapper,
|
|
22
|
+
)
|
|
23
|
+
from .entitlements import (
|
|
24
|
+
EntitlementsResource,
|
|
25
|
+
AsyncEntitlementsResource,
|
|
26
|
+
EntitlementsResourceWithRawResponse,
|
|
27
|
+
AsyncEntitlementsResourceWithRawResponse,
|
|
28
|
+
EntitlementsResourceWithStreamingResponse,
|
|
29
|
+
AsyncEntitlementsResourceWithStreamingResponse,
|
|
30
|
+
)
|
|
31
|
+
from ..._base_client import make_request_options
|
|
32
|
+
from ...types.subject import Subject
|
|
33
|
+
from .entitlements.entitlements import EntitlementsResource, AsyncEntitlementsResource
|
|
34
|
+
from ...types.subject_list_response import SubjectListResponse
|
|
35
|
+
from ...types.subject_upsert_response import SubjectUpsertResponse
|
|
36
|
+
|
|
37
|
+
__all__ = ["SubjectsResource", "AsyncSubjectsResource"]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SubjectsResource(SyncAPIResource):
|
|
41
|
+
@cached_property
|
|
42
|
+
def entitlements(self) -> EntitlementsResource:
|
|
43
|
+
return EntitlementsResource(self._client)
|
|
44
|
+
|
|
45
|
+
@cached_property
|
|
46
|
+
def with_raw_response(self) -> SubjectsResourceWithRawResponse:
|
|
47
|
+
"""
|
|
48
|
+
This property can be used as a prefix for any HTTP method call to return the
|
|
49
|
+
the raw response object instead of the parsed content.
|
|
50
|
+
|
|
51
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
|
|
52
|
+
"""
|
|
53
|
+
return SubjectsResourceWithRawResponse(self)
|
|
54
|
+
|
|
55
|
+
@cached_property
|
|
56
|
+
def with_streaming_response(self) -> SubjectsResourceWithStreamingResponse:
|
|
57
|
+
"""
|
|
58
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
59
|
+
|
|
60
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
|
|
61
|
+
"""
|
|
62
|
+
return SubjectsResourceWithStreamingResponse(self)
|
|
63
|
+
|
|
64
|
+
def retrieve(
|
|
65
|
+
self,
|
|
66
|
+
subject_id_or_key: str,
|
|
67
|
+
*,
|
|
68
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
69
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
70
|
+
extra_headers: Headers | None = None,
|
|
71
|
+
extra_query: Query | None = None,
|
|
72
|
+
extra_body: Body | None = None,
|
|
73
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
74
|
+
) -> Subject:
|
|
75
|
+
"""
|
|
76
|
+
Get subject by ID or key.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
extra_headers: Send extra headers
|
|
80
|
+
|
|
81
|
+
extra_query: Add additional query parameters to the request
|
|
82
|
+
|
|
83
|
+
extra_body: Add additional JSON properties to the request
|
|
84
|
+
|
|
85
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
86
|
+
"""
|
|
87
|
+
if not subject_id_or_key:
|
|
88
|
+
raise ValueError(f"Expected a non-empty value for `subject_id_or_key` but received {subject_id_or_key!r}")
|
|
89
|
+
return self._get(
|
|
90
|
+
f"/api/v1/subjects/{subject_id_or_key}",
|
|
91
|
+
options=make_request_options(
|
|
92
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
93
|
+
),
|
|
94
|
+
cast_to=Subject,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def list(
|
|
98
|
+
self,
|
|
99
|
+
*,
|
|
100
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
101
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
102
|
+
extra_headers: Headers | None = None,
|
|
103
|
+
extra_query: Query | None = None,
|
|
104
|
+
extra_body: Body | None = None,
|
|
105
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
106
|
+
) -> SubjectListResponse:
|
|
107
|
+
"""List subjects."""
|
|
108
|
+
return self._get(
|
|
109
|
+
"/api/v1/subjects",
|
|
110
|
+
options=make_request_options(
|
|
111
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
112
|
+
),
|
|
113
|
+
cast_to=SubjectListResponse,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def delete(
|
|
117
|
+
self,
|
|
118
|
+
subject_id_or_key: str,
|
|
119
|
+
*,
|
|
120
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
121
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
122
|
+
extra_headers: Headers | None = None,
|
|
123
|
+
extra_query: Query | None = None,
|
|
124
|
+
extra_body: Body | None = None,
|
|
125
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
126
|
+
) -> None:
|
|
127
|
+
"""
|
|
128
|
+
Delete subject by ID or key.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
extra_headers: Send extra headers
|
|
132
|
+
|
|
133
|
+
extra_query: Add additional query parameters to the request
|
|
134
|
+
|
|
135
|
+
extra_body: Add additional JSON properties to the request
|
|
136
|
+
|
|
137
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
138
|
+
"""
|
|
139
|
+
if not subject_id_or_key:
|
|
140
|
+
raise ValueError(f"Expected a non-empty value for `subject_id_or_key` but received {subject_id_or_key!r}")
|
|
141
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
142
|
+
return self._delete(
|
|
143
|
+
f"/api/v1/subjects/{subject_id_or_key}",
|
|
144
|
+
options=make_request_options(
|
|
145
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
146
|
+
),
|
|
147
|
+
cast_to=NoneType,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def upsert(
|
|
151
|
+
self,
|
|
152
|
+
*,
|
|
153
|
+
body: Iterable[subject_upsert_params.Body],
|
|
154
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
155
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
156
|
+
extra_headers: Headers | None = None,
|
|
157
|
+
extra_query: Query | None = None,
|
|
158
|
+
extra_body: Body | None = None,
|
|
159
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
160
|
+
) -> SubjectUpsertResponse:
|
|
161
|
+
"""Upserts a subject.
|
|
162
|
+
|
|
163
|
+
Creates or updates subject.
|
|
164
|
+
|
|
165
|
+
If the subject doesn't exist, it will be created. If the subject exists, it will
|
|
166
|
+
be partially updated with the provided fields.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
extra_headers: Send extra headers
|
|
170
|
+
|
|
171
|
+
extra_query: Add additional query parameters to the request
|
|
172
|
+
|
|
173
|
+
extra_body: Add additional JSON properties to the request
|
|
174
|
+
|
|
175
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
176
|
+
"""
|
|
177
|
+
return self._post(
|
|
178
|
+
"/api/v1/subjects",
|
|
179
|
+
body=maybe_transform(body, Iterable[subject_upsert_params.Body]),
|
|
180
|
+
options=make_request_options(
|
|
181
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
182
|
+
),
|
|
183
|
+
cast_to=SubjectUpsertResponse,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class AsyncSubjectsResource(AsyncAPIResource):
|
|
188
|
+
@cached_property
|
|
189
|
+
def entitlements(self) -> AsyncEntitlementsResource:
|
|
190
|
+
return AsyncEntitlementsResource(self._client)
|
|
191
|
+
|
|
192
|
+
@cached_property
|
|
193
|
+
def with_raw_response(self) -> AsyncSubjectsResourceWithRawResponse:
|
|
194
|
+
"""
|
|
195
|
+
This property can be used as a prefix for any HTTP method call to return the
|
|
196
|
+
the raw response object instead of the parsed content.
|
|
197
|
+
|
|
198
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
|
|
199
|
+
"""
|
|
200
|
+
return AsyncSubjectsResourceWithRawResponse(self)
|
|
201
|
+
|
|
202
|
+
@cached_property
|
|
203
|
+
def with_streaming_response(self) -> AsyncSubjectsResourceWithStreamingResponse:
|
|
204
|
+
"""
|
|
205
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
206
|
+
|
|
207
|
+
For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
|
|
208
|
+
"""
|
|
209
|
+
return AsyncSubjectsResourceWithStreamingResponse(self)
|
|
210
|
+
|
|
211
|
+
async def retrieve(
|
|
212
|
+
self,
|
|
213
|
+
subject_id_or_key: str,
|
|
214
|
+
*,
|
|
215
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
216
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
217
|
+
extra_headers: Headers | None = None,
|
|
218
|
+
extra_query: Query | None = None,
|
|
219
|
+
extra_body: Body | None = None,
|
|
220
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
221
|
+
) -> Subject:
|
|
222
|
+
"""
|
|
223
|
+
Get subject by ID or key.
|
|
224
|
+
|
|
225
|
+
Args:
|
|
226
|
+
extra_headers: Send extra headers
|
|
227
|
+
|
|
228
|
+
extra_query: Add additional query parameters to the request
|
|
229
|
+
|
|
230
|
+
extra_body: Add additional JSON properties to the request
|
|
231
|
+
|
|
232
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
233
|
+
"""
|
|
234
|
+
if not subject_id_or_key:
|
|
235
|
+
raise ValueError(f"Expected a non-empty value for `subject_id_or_key` but received {subject_id_or_key!r}")
|
|
236
|
+
return await self._get(
|
|
237
|
+
f"/api/v1/subjects/{subject_id_or_key}",
|
|
238
|
+
options=make_request_options(
|
|
239
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
240
|
+
),
|
|
241
|
+
cast_to=Subject,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
async def list(
|
|
245
|
+
self,
|
|
246
|
+
*,
|
|
247
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
248
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
249
|
+
extra_headers: Headers | None = None,
|
|
250
|
+
extra_query: Query | None = None,
|
|
251
|
+
extra_body: Body | None = None,
|
|
252
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
253
|
+
) -> SubjectListResponse:
|
|
254
|
+
"""List subjects."""
|
|
255
|
+
return await self._get(
|
|
256
|
+
"/api/v1/subjects",
|
|
257
|
+
options=make_request_options(
|
|
258
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
259
|
+
),
|
|
260
|
+
cast_to=SubjectListResponse,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
async def delete(
|
|
264
|
+
self,
|
|
265
|
+
subject_id_or_key: str,
|
|
266
|
+
*,
|
|
267
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
268
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
269
|
+
extra_headers: Headers | None = None,
|
|
270
|
+
extra_query: Query | None = None,
|
|
271
|
+
extra_body: Body | None = None,
|
|
272
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
273
|
+
) -> None:
|
|
274
|
+
"""
|
|
275
|
+
Delete subject by ID or key.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
extra_headers: Send extra headers
|
|
279
|
+
|
|
280
|
+
extra_query: Add additional query parameters to the request
|
|
281
|
+
|
|
282
|
+
extra_body: Add additional JSON properties to the request
|
|
283
|
+
|
|
284
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
285
|
+
"""
|
|
286
|
+
if not subject_id_or_key:
|
|
287
|
+
raise ValueError(f"Expected a non-empty value for `subject_id_or_key` but received {subject_id_or_key!r}")
|
|
288
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
289
|
+
return await self._delete(
|
|
290
|
+
f"/api/v1/subjects/{subject_id_or_key}",
|
|
291
|
+
options=make_request_options(
|
|
292
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
293
|
+
),
|
|
294
|
+
cast_to=NoneType,
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
async def upsert(
|
|
298
|
+
self,
|
|
299
|
+
*,
|
|
300
|
+
body: Iterable[subject_upsert_params.Body],
|
|
301
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
302
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
303
|
+
extra_headers: Headers | None = None,
|
|
304
|
+
extra_query: Query | None = None,
|
|
305
|
+
extra_body: Body | None = None,
|
|
306
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
307
|
+
) -> SubjectUpsertResponse:
|
|
308
|
+
"""Upserts a subject.
|
|
309
|
+
|
|
310
|
+
Creates or updates subject.
|
|
311
|
+
|
|
312
|
+
If the subject doesn't exist, it will be created. If the subject exists, it will
|
|
313
|
+
be partially updated with the provided fields.
|
|
314
|
+
|
|
315
|
+
Args:
|
|
316
|
+
extra_headers: Send extra headers
|
|
317
|
+
|
|
318
|
+
extra_query: Add additional query parameters to the request
|
|
319
|
+
|
|
320
|
+
extra_body: Add additional JSON properties to the request
|
|
321
|
+
|
|
322
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
323
|
+
"""
|
|
324
|
+
return await self._post(
|
|
325
|
+
"/api/v1/subjects",
|
|
326
|
+
body=await async_maybe_transform(body, Iterable[subject_upsert_params.Body]),
|
|
327
|
+
options=make_request_options(
|
|
328
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
329
|
+
),
|
|
330
|
+
cast_to=SubjectUpsertResponse,
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
class SubjectsResourceWithRawResponse:
|
|
335
|
+
def __init__(self, subjects: SubjectsResource) -> None:
|
|
336
|
+
self._subjects = subjects
|
|
337
|
+
|
|
338
|
+
self.retrieve = to_raw_response_wrapper(
|
|
339
|
+
subjects.retrieve,
|
|
340
|
+
)
|
|
341
|
+
self.list = to_raw_response_wrapper(
|
|
342
|
+
subjects.list,
|
|
343
|
+
)
|
|
344
|
+
self.delete = to_raw_response_wrapper(
|
|
345
|
+
subjects.delete,
|
|
346
|
+
)
|
|
347
|
+
self.upsert = to_raw_response_wrapper(
|
|
348
|
+
subjects.upsert,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
@cached_property
|
|
352
|
+
def entitlements(self) -> EntitlementsResourceWithRawResponse:
|
|
353
|
+
return EntitlementsResourceWithRawResponse(self._subjects.entitlements)
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
class AsyncSubjectsResourceWithRawResponse:
|
|
357
|
+
def __init__(self, subjects: AsyncSubjectsResource) -> None:
|
|
358
|
+
self._subjects = subjects
|
|
359
|
+
|
|
360
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
361
|
+
subjects.retrieve,
|
|
362
|
+
)
|
|
363
|
+
self.list = async_to_raw_response_wrapper(
|
|
364
|
+
subjects.list,
|
|
365
|
+
)
|
|
366
|
+
self.delete = async_to_raw_response_wrapper(
|
|
367
|
+
subjects.delete,
|
|
368
|
+
)
|
|
369
|
+
self.upsert = async_to_raw_response_wrapper(
|
|
370
|
+
subjects.upsert,
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
@cached_property
|
|
374
|
+
def entitlements(self) -> AsyncEntitlementsResourceWithRawResponse:
|
|
375
|
+
return AsyncEntitlementsResourceWithRawResponse(self._subjects.entitlements)
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
class SubjectsResourceWithStreamingResponse:
|
|
379
|
+
def __init__(self, subjects: SubjectsResource) -> None:
|
|
380
|
+
self._subjects = subjects
|
|
381
|
+
|
|
382
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
383
|
+
subjects.retrieve,
|
|
384
|
+
)
|
|
385
|
+
self.list = to_streamed_response_wrapper(
|
|
386
|
+
subjects.list,
|
|
387
|
+
)
|
|
388
|
+
self.delete = to_streamed_response_wrapper(
|
|
389
|
+
subjects.delete,
|
|
390
|
+
)
|
|
391
|
+
self.upsert = to_streamed_response_wrapper(
|
|
392
|
+
subjects.upsert,
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
@cached_property
|
|
396
|
+
def entitlements(self) -> EntitlementsResourceWithStreamingResponse:
|
|
397
|
+
return EntitlementsResourceWithStreamingResponse(self._subjects.entitlements)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class AsyncSubjectsResourceWithStreamingResponse:
|
|
401
|
+
def __init__(self, subjects: AsyncSubjectsResource) -> None:
|
|
402
|
+
self._subjects = subjects
|
|
403
|
+
|
|
404
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
405
|
+
subjects.retrieve,
|
|
406
|
+
)
|
|
407
|
+
self.list = async_to_streamed_response_wrapper(
|
|
408
|
+
subjects.list,
|
|
409
|
+
)
|
|
410
|
+
self.delete = async_to_streamed_response_wrapper(
|
|
411
|
+
subjects.delete,
|
|
412
|
+
)
|
|
413
|
+
self.upsert = async_to_streamed_response_wrapper(
|
|
414
|
+
subjects.upsert,
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
@cached_property
|
|
418
|
+
def entitlements(self) -> AsyncEntitlementsResourceWithStreamingResponse:
|
|
419
|
+
return AsyncEntitlementsResourceWithStreamingResponse(self._subjects.entitlements)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .meter import Meter as Meter
|
|
6
|
+
from .subject import Subject as Subject
|
|
7
|
+
from .entitlement import Entitlement as Entitlement
|
|
8
|
+
from .ingested_event import IngestedEvent as IngestedEvent
|
|
9
|
+
from .event_list_params import EventListParams as EventListParams
|
|
10
|
+
from .meter_query_params import MeterQueryParams as MeterQueryParams
|
|
11
|
+
from .meter_query_result import MeterQueryResult as MeterQueryResult
|
|
12
|
+
from .event_ingest_params import EventIngestParams as EventIngestParams
|
|
13
|
+
from .event_list_response import EventListResponse as EventListResponse
|
|
14
|
+
from .meter_create_params import MeterCreateParams as MeterCreateParams
|
|
15
|
+
from .meter_list_response import MeterListResponse as MeterListResponse
|
|
16
|
+
from .event_ingest_response import EventIngestResponse as EventIngestResponse
|
|
17
|
+
from .subject_list_response import SubjectListResponse as SubjectListResponse
|
|
18
|
+
from .subject_upsert_params import SubjectUpsertParams as SubjectUpsertParams
|
|
19
|
+
from .entitlement_list_params import EntitlementListParams as EntitlementListParams
|
|
20
|
+
from .subject_upsert_response import SubjectUpsertResponse as SubjectUpsertResponse
|
|
21
|
+
from .list_entitlements_result import ListEntitlementsResult as ListEntitlementsResult
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Union, Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing_extensions import Literal, Annotated, TypeAlias
|
|
6
|
+
|
|
7
|
+
from pydantic import Field as FieldInfo
|
|
8
|
+
|
|
9
|
+
from .._utils import PropertyInfo
|
|
10
|
+
from .._models import BaseModel
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"Entitlement",
|
|
14
|
+
"EntitlementMetered",
|
|
15
|
+
"EntitlementMeteredCurrentUsagePeriod",
|
|
16
|
+
"EntitlementMeteredUsagePeriod",
|
|
17
|
+
"EntitlementStatic",
|
|
18
|
+
"EntitlementStaticCurrentUsagePeriod",
|
|
19
|
+
"EntitlementStaticUsagePeriod",
|
|
20
|
+
"EntitlementBaseTemplate",
|
|
21
|
+
"EntitlementBaseTemplateCurrentUsagePeriod",
|
|
22
|
+
"EntitlementBaseTemplateUsagePeriod",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class EntitlementMeteredCurrentUsagePeriod(BaseModel):
|
|
27
|
+
from_: datetime = FieldInfo(alias="from")
|
|
28
|
+
"""Period start time."""
|
|
29
|
+
|
|
30
|
+
to: datetime
|
|
31
|
+
"""Period end time."""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class EntitlementMeteredUsagePeriod(BaseModel):
|
|
35
|
+
anchor: datetime
|
|
36
|
+
"""A date-time anchor to base the recurring period on."""
|
|
37
|
+
|
|
38
|
+
interval: Literal["DAY", "WEEK", "MONTH", "YEAR"]
|
|
39
|
+
"""The unit of time for the interval. One of: `day`, `week`, `month`, or `year`."""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class EntitlementMetered(BaseModel):
|
|
43
|
+
id: str
|
|
44
|
+
"""Readonly unique ULID identifier."""
|
|
45
|
+
|
|
46
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
|
47
|
+
"""Timestamp of when the resource was created."""
|
|
48
|
+
|
|
49
|
+
current_usage_period: EntitlementMeteredCurrentUsagePeriod = FieldInfo(alias="currentUsagePeriod")
|
|
50
|
+
"""A period with a start and end time."""
|
|
51
|
+
|
|
52
|
+
feature_id: str = FieldInfo(alias="featureId")
|
|
53
|
+
"""The feature the subject is entitled to use."""
|
|
54
|
+
|
|
55
|
+
feature_key: str = FieldInfo(alias="featureKey")
|
|
56
|
+
"""The feature the subject is entitled to use."""
|
|
57
|
+
|
|
58
|
+
last_reset: datetime = FieldInfo(alias="lastReset")
|
|
59
|
+
"""The time the last reset happened."""
|
|
60
|
+
|
|
61
|
+
measure_usage_from: datetime = FieldInfo(alias="measureUsageFrom")
|
|
62
|
+
"""The time from which usage is measured.
|
|
63
|
+
|
|
64
|
+
If not specified on creation, defaults to entitlement creation time.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
subject_key: str = FieldInfo(alias="subjectKey")
|
|
68
|
+
"""The identifier key unique to the subject"""
|
|
69
|
+
|
|
70
|
+
type: Literal["metered"]
|
|
71
|
+
|
|
72
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
73
|
+
"""Timestamp of when the resource was last updated."""
|
|
74
|
+
|
|
75
|
+
usage_period: EntitlementMeteredUsagePeriod = FieldInfo(alias="usagePeriod")
|
|
76
|
+
"""Recurring period with an interval and an anchor."""
|
|
77
|
+
|
|
78
|
+
deleted_at: Optional[datetime] = FieldInfo(alias="deletedAt", default=None)
|
|
79
|
+
"""Timestamp of when the resource was permanently deleted."""
|
|
80
|
+
|
|
81
|
+
is_soft_limit: Optional[bool] = FieldInfo(alias="isSoftLimit", default=None)
|
|
82
|
+
"""
|
|
83
|
+
If softLimit=true the subject can use the feature even if the entitlement is
|
|
84
|
+
exhausted, hasAccess will always be true.
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
issue_after_reset: Optional[float] = FieldInfo(alias="issueAfterReset", default=None)
|
|
88
|
+
"""
|
|
89
|
+
You can grant usage automatically alongside the entitlement, the example
|
|
90
|
+
scenario would be creating a starting balance. If an amount is specified here, a
|
|
91
|
+
grant will be created alongside the entitlement with the specified amount. That
|
|
92
|
+
grant will have it's rollover settings configured in a way that after each reset
|
|
93
|
+
operation, the balance will return the original amount specified here. Manually
|
|
94
|
+
creating such a grant would mean having the "amount", "minRolloverAmount", and
|
|
95
|
+
"maxRolloverAmount" fields all be the same.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
issue_after_reset_priority: Optional[int] = FieldInfo(alias="issueAfterResetPriority", default=None)
|
|
99
|
+
"""Defines the grant priority for the default grant."""
|
|
100
|
+
|
|
101
|
+
is_unlimited: Optional[bool] = FieldInfo(alias="isUnlimited", default=None)
|
|
102
|
+
"""Deprecated, ignored by the backend.
|
|
103
|
+
|
|
104
|
+
Please use isSoftLimit instead; this field will be removed in the future.
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
metadata: Optional[Dict[str, str]] = None
|
|
108
|
+
"""
|
|
109
|
+
Set of key-value pairs. Metadata can be used to store additional information
|
|
110
|
+
about a resource.
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
preserve_overage_at_reset: Optional[bool] = FieldInfo(alias="preserveOverageAtReset", default=None)
|
|
114
|
+
"""If true, the overage is preserved at reset. If false, the usage is reset to 0."""
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class EntitlementStaticCurrentUsagePeriod(BaseModel):
|
|
118
|
+
from_: datetime = FieldInfo(alias="from")
|
|
119
|
+
"""Period start time."""
|
|
120
|
+
|
|
121
|
+
to: datetime
|
|
122
|
+
"""Period end time."""
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class EntitlementStaticUsagePeriod(BaseModel):
|
|
126
|
+
anchor: datetime
|
|
127
|
+
"""A date-time anchor to base the recurring period on."""
|
|
128
|
+
|
|
129
|
+
interval: Literal["DAY", "WEEK", "MONTH", "YEAR"]
|
|
130
|
+
"""The unit of time for the interval. One of: `day`, `week`, `month`, or `year`."""
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class EntitlementStatic(BaseModel):
|
|
134
|
+
id: str
|
|
135
|
+
"""Readonly unique ULID identifier."""
|
|
136
|
+
|
|
137
|
+
config: str
|
|
138
|
+
"""The JSON parsable config of the entitlement.
|
|
139
|
+
|
|
140
|
+
This value is also returned when checking entitlement access and it is useful
|
|
141
|
+
for configuring fine-grained access settings to the feature, implemented in your
|
|
142
|
+
own system. Has to be an object.
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
|
146
|
+
"""Timestamp of when the resource was created."""
|
|
147
|
+
|
|
148
|
+
feature_id: str = FieldInfo(alias="featureId")
|
|
149
|
+
"""The feature the subject is entitled to use."""
|
|
150
|
+
|
|
151
|
+
feature_key: str = FieldInfo(alias="featureKey")
|
|
152
|
+
"""The feature the subject is entitled to use."""
|
|
153
|
+
|
|
154
|
+
subject_key: str = FieldInfo(alias="subjectKey")
|
|
155
|
+
"""The identifier key unique to the subject"""
|
|
156
|
+
|
|
157
|
+
type: Literal["static"]
|
|
158
|
+
|
|
159
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
160
|
+
"""Timestamp of when the resource was last updated."""
|
|
161
|
+
|
|
162
|
+
current_usage_period: Optional[EntitlementStaticCurrentUsagePeriod] = FieldInfo(
|
|
163
|
+
alias="currentUsagePeriod", default=None
|
|
164
|
+
)
|
|
165
|
+
"""A period with a start and end time."""
|
|
166
|
+
|
|
167
|
+
deleted_at: Optional[datetime] = FieldInfo(alias="deletedAt", default=None)
|
|
168
|
+
"""Timestamp of when the resource was permanently deleted."""
|
|
169
|
+
|
|
170
|
+
metadata: Optional[Dict[str, str]] = None
|
|
171
|
+
"""
|
|
172
|
+
Set of key-value pairs. Metadata can be used to store additional information
|
|
173
|
+
about a resource.
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
usage_period: Optional[EntitlementStaticUsagePeriod] = FieldInfo(alias="usagePeriod", default=None)
|
|
177
|
+
"""Recurring period with an interval and an anchor."""
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class EntitlementBaseTemplateCurrentUsagePeriod(BaseModel):
|
|
181
|
+
from_: datetime = FieldInfo(alias="from")
|
|
182
|
+
"""Period start time."""
|
|
183
|
+
|
|
184
|
+
to: datetime
|
|
185
|
+
"""Period end time."""
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class EntitlementBaseTemplateUsagePeriod(BaseModel):
|
|
189
|
+
anchor: datetime
|
|
190
|
+
"""A date-time anchor to base the recurring period on."""
|
|
191
|
+
|
|
192
|
+
interval: Literal["DAY", "WEEK", "MONTH", "YEAR"]
|
|
193
|
+
"""The unit of time for the interval. One of: `day`, `week`, `month`, or `year`."""
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class EntitlementBaseTemplate(BaseModel):
|
|
197
|
+
id: str
|
|
198
|
+
"""Readonly unique ULID identifier."""
|
|
199
|
+
|
|
200
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
|
201
|
+
"""Timestamp of when the resource was created."""
|
|
202
|
+
|
|
203
|
+
feature_id: str = FieldInfo(alias="featureId")
|
|
204
|
+
"""The feature the subject is entitled to use."""
|
|
205
|
+
|
|
206
|
+
feature_key: str = FieldInfo(alias="featureKey")
|
|
207
|
+
"""The feature the subject is entitled to use."""
|
|
208
|
+
|
|
209
|
+
subject_key: str = FieldInfo(alias="subjectKey")
|
|
210
|
+
"""The identifier key unique to the subject"""
|
|
211
|
+
|
|
212
|
+
type: Literal["metered", "boolean", "static"]
|
|
213
|
+
"""Type of the entitlement."""
|
|
214
|
+
|
|
215
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
216
|
+
"""Timestamp of when the resource was last updated."""
|
|
217
|
+
|
|
218
|
+
current_usage_period: Optional[EntitlementBaseTemplateCurrentUsagePeriod] = FieldInfo(
|
|
219
|
+
alias="currentUsagePeriod", default=None
|
|
220
|
+
)
|
|
221
|
+
"""A period with a start and end time."""
|
|
222
|
+
|
|
223
|
+
deleted_at: Optional[datetime] = FieldInfo(alias="deletedAt", default=None)
|
|
224
|
+
"""Timestamp of when the resource was permanently deleted."""
|
|
225
|
+
|
|
226
|
+
metadata: Optional[Dict[str, str]] = None
|
|
227
|
+
"""
|
|
228
|
+
Set of key-value pairs. Metadata can be used to store additional information
|
|
229
|
+
about a resource.
|
|
230
|
+
"""
|
|
231
|
+
|
|
232
|
+
usage_period: Optional[EntitlementBaseTemplateUsagePeriod] = FieldInfo(alias="usagePeriod", default=None)
|
|
233
|
+
"""Recurring period with an interval and an anchor."""
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
Entitlement: TypeAlias = Annotated[
|
|
237
|
+
Union[EntitlementMetered, EntitlementStatic, EntitlementBaseTemplate], PropertyInfo(discriminator="type")
|
|
238
|
+
]
|