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.

Files changed (132) hide show
  1. openmeter/__init__.py +89 -15
  2. openmeter/_base_client.py +2041 -0
  3. openmeter/_client.py +518 -70
  4. openmeter/_compat.py +221 -0
  5. openmeter/_constants.py +14 -0
  6. openmeter/_exceptions.py +108 -0
  7. openmeter/_files.py +127 -0
  8. openmeter/_models.py +777 -0
  9. openmeter/_qs.py +150 -0
  10. openmeter/_resource.py +43 -0
  11. openmeter/_response.py +820 -0
  12. openmeter/_streaming.py +333 -0
  13. openmeter/_types.py +222 -0
  14. openmeter/_utils/__init__.py +56 -0
  15. openmeter/_utils/_logs.py +25 -0
  16. openmeter/_utils/_proxy.py +63 -0
  17. openmeter/_utils/_reflection.py +42 -0
  18. openmeter/_utils/_streams.py +12 -0
  19. openmeter/_utils/_sync.py +81 -0
  20. openmeter/_utils/_transform.py +387 -0
  21. openmeter/_utils/_typing.py +120 -0
  22. openmeter/_utils/_utils.py +419 -0
  23. openmeter/_version.py +4 -0
  24. openmeter/lib/.keep +4 -0
  25. openmeter/py.typed +0 -1
  26. openmeter/resources/__init__.py +103 -0
  27. openmeter/resources/debug/__init__.py +33 -0
  28. openmeter/resources/debug/debug.py +102 -0
  29. openmeter/resources/debug/metrics.py +146 -0
  30. openmeter/resources/entitlements/__init__.py +47 -0
  31. openmeter/resources/entitlements/entitlements.py +450 -0
  32. openmeter/resources/entitlements/features.py +578 -0
  33. openmeter/resources/entitlements/grants.py +389 -0
  34. openmeter/resources/events.py +442 -0
  35. openmeter/resources/meters/__init__.py +33 -0
  36. openmeter/resources/meters/meters.py +666 -0
  37. openmeter/resources/meters/subjects.py +163 -0
  38. openmeter/resources/notifications/__init__.py +75 -0
  39. openmeter/resources/notifications/channels.py +686 -0
  40. openmeter/resources/notifications/events.py +365 -0
  41. openmeter/resources/notifications/notifications.py +198 -0
  42. openmeter/resources/notifications/rules.py +781 -0
  43. openmeter/resources/notifications/webhook.py +208 -0
  44. openmeter/resources/portal/__init__.py +47 -0
  45. openmeter/resources/portal/meters.py +230 -0
  46. openmeter/resources/portal/portal.py +112 -0
  47. openmeter/resources/portal/tokens.py +359 -0
  48. openmeter/resources/subjects/entitlements/__init__.py +33 -0
  49. openmeter/resources/subjects/entitlements/entitlements.py +1881 -0
  50. openmeter/resources/subjects/entitlements/grants.py +453 -0
  51. openmeter/resources/subjects.py +419 -0
  52. openmeter/types/__init__.py +21 -0
  53. openmeter/types/debug/__init__.py +5 -0
  54. openmeter/types/debug/metric_list_response.py +7 -0
  55. openmeter/types/entitlement.py +238 -0
  56. openmeter/types/entitlements/__init__.py +11 -0
  57. openmeter/types/entitlements/feature.py +61 -0
  58. openmeter/types/entitlements/feature_create_params.py +43 -0
  59. openmeter/types/entitlements/feature_list_params.py +23 -0
  60. openmeter/types/entitlements/grant_list_params.py +57 -0
  61. openmeter/types/entitlements/grant_list_response.py +11 -0
  62. openmeter/types/entitlements/grant_paginated_response.py +24 -0
  63. openmeter/types/entitlements/list_features_result.py +28 -0
  64. openmeter/types/event_ingest_params.py +46 -0
  65. openmeter/types/event_ingest_response.py +43 -0
  66. openmeter/types/event_list_params.py +22 -0
  67. openmeter/types/event_list_response.py +9 -0
  68. openmeter/types/ingested_event.py +59 -0
  69. openmeter/types/list_entitlements_result.py +28 -0
  70. openmeter/types/meter.py +53 -0
  71. openmeter/types/meter_create_params.py +50 -0
  72. openmeter/types/meter_list_response.py +9 -0
  73. openmeter/types/meter_query_params.py +50 -0
  74. openmeter/types/meter_query_result.py +35 -0
  75. openmeter/types/meters/__init__.py +5 -0
  76. openmeter/types/meters/subject_list_response.py +8 -0
  77. openmeter/types/notifications/__init__.py +18 -0
  78. openmeter/types/notifications/channel_create_params.py +34 -0
  79. openmeter/types/notifications/channel_list_params.py +41 -0
  80. openmeter/types/notifications/channel_list_response.py +24 -0
  81. openmeter/types/notifications/channel_update_params.py +34 -0
  82. openmeter/types/notifications/event_list_params.py +61 -0
  83. openmeter/types/notifications/event_list_response.py +24 -0
  84. openmeter/types/notifications/notification_channel.py +47 -0
  85. openmeter/types/notifications/notification_event.py +215 -0
  86. openmeter/types/notifications/notification_rule.py +70 -0
  87. openmeter/types/notifications/rule_create_params.py +39 -0
  88. openmeter/types/notifications/rule_list_params.py +54 -0
  89. openmeter/types/notifications/rule_list_response.py +24 -0
  90. openmeter/types/notifications/rule_update_params.py +39 -0
  91. openmeter/types/notifications/webhook_svix_params.py +26 -0
  92. openmeter/types/portal/__init__.py +10 -0
  93. openmeter/types/portal/meter_query_params.py +44 -0
  94. openmeter/types/portal/portal_token.py +28 -0
  95. openmeter/types/portal/token_create_params.py +17 -0
  96. openmeter/types/portal/token_invalidate_params.py +15 -0
  97. openmeter/types/portal/token_list_params.py +12 -0
  98. openmeter/types/portal/token_list_response.py +9 -0
  99. openmeter/types/shared/__init__.py +3 -0
  100. openmeter/types/subject.py +37 -0
  101. openmeter/types/subject_list_response.py +9 -0
  102. openmeter/types/subject_param.py +27 -0
  103. openmeter/types/subject_upsert_params.py +39 -0
  104. openmeter/types/subject_upsert_response.py +10 -0
  105. openmeter/types/subjects/__init__.py +13 -0
  106. openmeter/types/subjects/entitlement_history_params.py +35 -0
  107. openmeter/types/subjects/entitlement_history_response.py +98 -0
  108. openmeter/types/subjects/entitlement_list_response.py +10 -0
  109. openmeter/types/subjects/entitlements/__init__.py +8 -0
  110. openmeter/types/subjects/entitlements/entitlement_grant.py +103 -0
  111. openmeter/types/subjects/entitlements/grant_list_response.py +10 -0
  112. openmeter-2.0.0.dist-info/METADATA +396 -0
  113. openmeter-2.0.0.dist-info/RECORD +115 -0
  114. {openmeter-1.0.0b53.dist-info → openmeter-2.0.0.dist-info}/WHEEL +1 -1
  115. openmeter-2.0.0.dist-info/licenses/LICENSE +201 -0
  116. openmeter/_configuration.py +0 -36
  117. openmeter/_operations/__init__.py +0 -17
  118. openmeter/_operations/_operations.py +0 -2098
  119. openmeter/_operations/_patch.py +0 -20
  120. openmeter/_patch.py +0 -20
  121. openmeter/_serialization.py +0 -2008
  122. openmeter/_vendor.py +0 -24
  123. openmeter/aio/__init__.py +0 -21
  124. openmeter/aio/_client.py +0 -83
  125. openmeter/aio/_configuration.py +0 -36
  126. openmeter/aio/_operations/__init__.py +0 -17
  127. openmeter/aio/_operations/_operations.py +0 -1771
  128. openmeter/aio/_operations/_patch.py +0 -20
  129. openmeter/aio/_patch.py +0 -20
  130. openmeter/aio/_vendor.py +0 -24
  131. openmeter-1.0.0b53.dist-info/METADATA +0 -92
  132. openmeter-1.0.0b53.dist-info/RECORD +0 -21
@@ -0,0 +1,781 @@
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 List, Iterable
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
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 ..._base_client import make_request_options
24
+ from ...types.notifications import rule_list_params, rule_create_params, rule_update_params
25
+ from ...types.notifications.notification_rule import NotificationRule
26
+ from ...types.notifications.notification_event import NotificationEvent
27
+ from ...types.notifications.rule_list_response import RuleListResponse
28
+
29
+ __all__ = ["RulesResource", "AsyncRulesResource"]
30
+
31
+
32
+ class RulesResource(SyncAPIResource):
33
+ @cached_property
34
+ def with_raw_response(self) -> RulesResourceWithRawResponse:
35
+ """
36
+ This property can be used as a prefix for any HTTP method call to return the
37
+ the raw response object instead of the parsed content.
38
+
39
+ For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
40
+ """
41
+ return RulesResourceWithRawResponse(self)
42
+
43
+ @cached_property
44
+ def with_streaming_response(self) -> RulesResourceWithStreamingResponse:
45
+ """
46
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
47
+
48
+ For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
49
+ """
50
+ return RulesResourceWithStreamingResponse(self)
51
+
52
+ def create(
53
+ self,
54
+ *,
55
+ channels: List[str],
56
+ name: str,
57
+ thresholds: Iterable[rule_create_params.Threshold],
58
+ type: Literal["entitlements.balance.threshold"],
59
+ disabled: bool | NotGiven = NOT_GIVEN,
60
+ features: List[str] | NotGiven = NOT_GIVEN,
61
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
62
+ # The extra values given here take precedence over values defined on the client or passed to this method.
63
+ extra_headers: Headers | None = None,
64
+ extra_query: Query | None = None,
65
+ extra_body: Body | None = None,
66
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
67
+ ) -> NotificationRule:
68
+ """
69
+ Create a new notification rule.
70
+
71
+ Args:
72
+ channels: List of notification channels the rule is applied to.
73
+
74
+ name: The user friendly name of the notification rule.
75
+
76
+ thresholds: List of thresholds the rule suppose to be triggered.
77
+
78
+ type: Notification rule type.
79
+
80
+ disabled: Whether the rule is disabled or not.
81
+
82
+ features: Optional field for defining the scope of notification by feature. It may contain
83
+ features by id or key.
84
+
85
+ extra_headers: Send extra headers
86
+
87
+ extra_query: Add additional query parameters to the request
88
+
89
+ extra_body: Add additional JSON properties to the request
90
+
91
+ timeout: Override the client-level default timeout for this request, in seconds
92
+ """
93
+ return self._post(
94
+ "/api/v1/notification/rules",
95
+ body=maybe_transform(
96
+ {
97
+ "channels": channels,
98
+ "name": name,
99
+ "thresholds": thresholds,
100
+ "type": type,
101
+ "disabled": disabled,
102
+ "features": features,
103
+ },
104
+ rule_create_params.RuleCreateParams,
105
+ ),
106
+ options=make_request_options(
107
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
108
+ ),
109
+ cast_to=NotificationRule,
110
+ )
111
+
112
+ def retrieve(
113
+ self,
114
+ rule_id: str,
115
+ *,
116
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
117
+ # The extra values given here take precedence over values defined on the client or passed to this method.
118
+ extra_headers: Headers | None = None,
119
+ extra_query: Query | None = None,
120
+ extra_body: Body | None = None,
121
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
122
+ ) -> NotificationRule:
123
+ """
124
+ Get a notification rule by id.
125
+
126
+ Args:
127
+ extra_headers: Send extra headers
128
+
129
+ extra_query: Add additional query parameters to the request
130
+
131
+ extra_body: Add additional JSON properties to the request
132
+
133
+ timeout: Override the client-level default timeout for this request, in seconds
134
+ """
135
+ if not rule_id:
136
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
137
+ return self._get(
138
+ f"/api/v1/notification/rules/{rule_id}",
139
+ options=make_request_options(
140
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
141
+ ),
142
+ cast_to=NotificationRule,
143
+ )
144
+
145
+ def update(
146
+ self,
147
+ rule_id: str,
148
+ *,
149
+ channels: List[str],
150
+ name: str,
151
+ thresholds: Iterable[rule_update_params.Threshold],
152
+ type: Literal["entitlements.balance.threshold"],
153
+ disabled: bool | NotGiven = NOT_GIVEN,
154
+ features: List[str] | NotGiven = NOT_GIVEN,
155
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
156
+ # The extra values given here take precedence over values defined on the client or passed to this method.
157
+ extra_headers: Headers | None = None,
158
+ extra_query: Query | None = None,
159
+ extra_body: Body | None = None,
160
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
161
+ ) -> NotificationRule:
162
+ """
163
+ Update notification rule.
164
+
165
+ Args:
166
+ channels: List of notification channels the rule is applied to.
167
+
168
+ name: The user friendly name of the notification rule.
169
+
170
+ thresholds: List of thresholds the rule suppose to be triggered.
171
+
172
+ type: Notification rule type.
173
+
174
+ disabled: Whether the rule is disabled or not.
175
+
176
+ features: Optional field for defining the scope of notification by feature. It may contain
177
+ features by id or key.
178
+
179
+ extra_headers: Send extra headers
180
+
181
+ extra_query: Add additional query parameters to the request
182
+
183
+ extra_body: Add additional JSON properties to the request
184
+
185
+ timeout: Override the client-level default timeout for this request, in seconds
186
+ """
187
+ if not rule_id:
188
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
189
+ return self._put(
190
+ f"/api/v1/notification/rules/{rule_id}",
191
+ body=maybe_transform(
192
+ {
193
+ "channels": channels,
194
+ "name": name,
195
+ "thresholds": thresholds,
196
+ "type": type,
197
+ "disabled": disabled,
198
+ "features": features,
199
+ },
200
+ rule_update_params.RuleUpdateParams,
201
+ ),
202
+ options=make_request_options(
203
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
204
+ ),
205
+ cast_to=NotificationRule,
206
+ )
207
+
208
+ def list(
209
+ self,
210
+ *,
211
+ channel: List[str] | NotGiven = NOT_GIVEN,
212
+ feature: List[str] | NotGiven = NOT_GIVEN,
213
+ include_deleted: bool | NotGiven = NOT_GIVEN,
214
+ include_disabled: bool | NotGiven = NOT_GIVEN,
215
+ order: Literal["ASC", "DESC"] | NotGiven = NOT_GIVEN,
216
+ order_by: Literal["id", "type", "createdAt", "updatedAt"] | NotGiven = NOT_GIVEN,
217
+ page: int | NotGiven = NOT_GIVEN,
218
+ page_size: int | NotGiven = NOT_GIVEN,
219
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
220
+ # The extra values given here take precedence over values defined on the client or passed to this method.
221
+ extra_headers: Headers | None = None,
222
+ extra_query: Query | None = None,
223
+ extra_body: Body | None = None,
224
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
225
+ ) -> RuleListResponse:
226
+ """
227
+ List all notification rules.
228
+
229
+ Args:
230
+ channel: Filtering by multiple notifiaction channel ids.
231
+
232
+ Usage: `?channel=01ARZ3NDEKTSV4RRFFQ69G5FAV&channel=01J8J2Y5X4NNGQS32CF81W95E3`
233
+
234
+ feature: Filtering by multiple feature ids/keys.
235
+
236
+ Usage: `?feature=feature-1&feature=feature-2`
237
+
238
+ include_deleted: Include deleted notification rules in response.
239
+
240
+ Usage: `?includeDeleted=true`
241
+
242
+ include_disabled: Include disabled notification rules in response.
243
+
244
+ Usage: `?includeDisabled=false`
245
+
246
+ order: The order direction.
247
+
248
+ order_by: The order by field.
249
+
250
+ page: Start date-time in RFC 3339 format.
251
+
252
+ Inclusive.
253
+
254
+ page_size: Number of items per page.
255
+
256
+ Default is 100.
257
+
258
+ extra_headers: Send extra headers
259
+
260
+ extra_query: Add additional query parameters to the request
261
+
262
+ extra_body: Add additional JSON properties to the request
263
+
264
+ timeout: Override the client-level default timeout for this request, in seconds
265
+ """
266
+ return self._get(
267
+ "/api/v1/notification/rules",
268
+ options=make_request_options(
269
+ extra_headers=extra_headers,
270
+ extra_query=extra_query,
271
+ extra_body=extra_body,
272
+ timeout=timeout,
273
+ query=maybe_transform(
274
+ {
275
+ "channel": channel,
276
+ "feature": feature,
277
+ "include_deleted": include_deleted,
278
+ "include_disabled": include_disabled,
279
+ "order": order,
280
+ "order_by": order_by,
281
+ "page": page,
282
+ "page_size": page_size,
283
+ },
284
+ rule_list_params.RuleListParams,
285
+ ),
286
+ ),
287
+ cast_to=RuleListResponse,
288
+ )
289
+
290
+ def delete(
291
+ self,
292
+ rule_id: str,
293
+ *,
294
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
295
+ # The extra values given here take precedence over values defined on the client or passed to this method.
296
+ extra_headers: Headers | None = None,
297
+ extra_query: Query | None = None,
298
+ extra_body: Body | None = None,
299
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
300
+ ) -> None:
301
+ """
302
+ Soft delete notification rule by id.
303
+
304
+ Once a notification rule is deleted it cannot be undeleted.
305
+
306
+ Args:
307
+ extra_headers: Send extra headers
308
+
309
+ extra_query: Add additional query parameters to the request
310
+
311
+ extra_body: Add additional JSON properties to the request
312
+
313
+ timeout: Override the client-level default timeout for this request, in seconds
314
+ """
315
+ if not rule_id:
316
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
317
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
318
+ return self._delete(
319
+ f"/api/v1/notification/rules/{rule_id}",
320
+ options=make_request_options(
321
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
322
+ ),
323
+ cast_to=NoneType,
324
+ )
325
+
326
+ def test(
327
+ self,
328
+ rule_id: str,
329
+ *,
330
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
331
+ # The extra values given here take precedence over values defined on the client or passed to this method.
332
+ extra_headers: Headers | None = None,
333
+ extra_query: Query | None = None,
334
+ extra_body: Body | None = None,
335
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
336
+ ) -> NotificationEvent:
337
+ """
338
+ Test a notification rule by sending a test event with random data.
339
+
340
+ Args:
341
+ extra_headers: Send extra headers
342
+
343
+ extra_query: Add additional query parameters to the request
344
+
345
+ extra_body: Add additional JSON properties to the request
346
+
347
+ timeout: Override the client-level default timeout for this request, in seconds
348
+ """
349
+ if not rule_id:
350
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
351
+ return self._post(
352
+ f"/api/v1/notification/rules/{rule_id}/test",
353
+ options=make_request_options(
354
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
355
+ ),
356
+ cast_to=NotificationEvent,
357
+ )
358
+
359
+
360
+ class AsyncRulesResource(AsyncAPIResource):
361
+ @cached_property
362
+ def with_raw_response(self) -> AsyncRulesResourceWithRawResponse:
363
+ """
364
+ This property can be used as a prefix for any HTTP method call to return the
365
+ the raw response object instead of the parsed content.
366
+
367
+ For more information, see https://www.github.com/openmeterio/openmeter-python#accessing-raw-response-data-eg-headers
368
+ """
369
+ return AsyncRulesResourceWithRawResponse(self)
370
+
371
+ @cached_property
372
+ def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse:
373
+ """
374
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
375
+
376
+ For more information, see https://www.github.com/openmeterio/openmeter-python#with_streaming_response
377
+ """
378
+ return AsyncRulesResourceWithStreamingResponse(self)
379
+
380
+ async def create(
381
+ self,
382
+ *,
383
+ channels: List[str],
384
+ name: str,
385
+ thresholds: Iterable[rule_create_params.Threshold],
386
+ type: Literal["entitlements.balance.threshold"],
387
+ disabled: bool | NotGiven = NOT_GIVEN,
388
+ features: List[str] | NotGiven = NOT_GIVEN,
389
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
390
+ # The extra values given here take precedence over values defined on the client or passed to this method.
391
+ extra_headers: Headers | None = None,
392
+ extra_query: Query | None = None,
393
+ extra_body: Body | None = None,
394
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
395
+ ) -> NotificationRule:
396
+ """
397
+ Create a new notification rule.
398
+
399
+ Args:
400
+ channels: List of notification channels the rule is applied to.
401
+
402
+ name: The user friendly name of the notification rule.
403
+
404
+ thresholds: List of thresholds the rule suppose to be triggered.
405
+
406
+ type: Notification rule type.
407
+
408
+ disabled: Whether the rule is disabled or not.
409
+
410
+ features: Optional field for defining the scope of notification by feature. It may contain
411
+ features by id or key.
412
+
413
+ extra_headers: Send extra headers
414
+
415
+ extra_query: Add additional query parameters to the request
416
+
417
+ extra_body: Add additional JSON properties to the request
418
+
419
+ timeout: Override the client-level default timeout for this request, in seconds
420
+ """
421
+ return await self._post(
422
+ "/api/v1/notification/rules",
423
+ body=await async_maybe_transform(
424
+ {
425
+ "channels": channels,
426
+ "name": name,
427
+ "thresholds": thresholds,
428
+ "type": type,
429
+ "disabled": disabled,
430
+ "features": features,
431
+ },
432
+ rule_create_params.RuleCreateParams,
433
+ ),
434
+ options=make_request_options(
435
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
436
+ ),
437
+ cast_to=NotificationRule,
438
+ )
439
+
440
+ async def retrieve(
441
+ self,
442
+ rule_id: str,
443
+ *,
444
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
445
+ # The extra values given here take precedence over values defined on the client or passed to this method.
446
+ extra_headers: Headers | None = None,
447
+ extra_query: Query | None = None,
448
+ extra_body: Body | None = None,
449
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
450
+ ) -> NotificationRule:
451
+ """
452
+ Get a notification rule by id.
453
+
454
+ Args:
455
+ extra_headers: Send extra headers
456
+
457
+ extra_query: Add additional query parameters to the request
458
+
459
+ extra_body: Add additional JSON properties to the request
460
+
461
+ timeout: Override the client-level default timeout for this request, in seconds
462
+ """
463
+ if not rule_id:
464
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
465
+ return await self._get(
466
+ f"/api/v1/notification/rules/{rule_id}",
467
+ options=make_request_options(
468
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
469
+ ),
470
+ cast_to=NotificationRule,
471
+ )
472
+
473
+ async def update(
474
+ self,
475
+ rule_id: str,
476
+ *,
477
+ channels: List[str],
478
+ name: str,
479
+ thresholds: Iterable[rule_update_params.Threshold],
480
+ type: Literal["entitlements.balance.threshold"],
481
+ disabled: bool | NotGiven = NOT_GIVEN,
482
+ features: List[str] | NotGiven = NOT_GIVEN,
483
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
484
+ # The extra values given here take precedence over values defined on the client or passed to this method.
485
+ extra_headers: Headers | None = None,
486
+ extra_query: Query | None = None,
487
+ extra_body: Body | None = None,
488
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
489
+ ) -> NotificationRule:
490
+ """
491
+ Update notification rule.
492
+
493
+ Args:
494
+ channels: List of notification channels the rule is applied to.
495
+
496
+ name: The user friendly name of the notification rule.
497
+
498
+ thresholds: List of thresholds the rule suppose to be triggered.
499
+
500
+ type: Notification rule type.
501
+
502
+ disabled: Whether the rule is disabled or not.
503
+
504
+ features: Optional field for defining the scope of notification by feature. It may contain
505
+ features by id or key.
506
+
507
+ extra_headers: Send extra headers
508
+
509
+ extra_query: Add additional query parameters to the request
510
+
511
+ extra_body: Add additional JSON properties to the request
512
+
513
+ timeout: Override the client-level default timeout for this request, in seconds
514
+ """
515
+ if not rule_id:
516
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
517
+ return await self._put(
518
+ f"/api/v1/notification/rules/{rule_id}",
519
+ body=await async_maybe_transform(
520
+ {
521
+ "channels": channels,
522
+ "name": name,
523
+ "thresholds": thresholds,
524
+ "type": type,
525
+ "disabled": disabled,
526
+ "features": features,
527
+ },
528
+ rule_update_params.RuleUpdateParams,
529
+ ),
530
+ options=make_request_options(
531
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
532
+ ),
533
+ cast_to=NotificationRule,
534
+ )
535
+
536
+ async def list(
537
+ self,
538
+ *,
539
+ channel: List[str] | NotGiven = NOT_GIVEN,
540
+ feature: List[str] | NotGiven = NOT_GIVEN,
541
+ include_deleted: bool | NotGiven = NOT_GIVEN,
542
+ include_disabled: bool | NotGiven = NOT_GIVEN,
543
+ order: Literal["ASC", "DESC"] | NotGiven = NOT_GIVEN,
544
+ order_by: Literal["id", "type", "createdAt", "updatedAt"] | NotGiven = NOT_GIVEN,
545
+ page: int | NotGiven = NOT_GIVEN,
546
+ page_size: int | NotGiven = NOT_GIVEN,
547
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
548
+ # The extra values given here take precedence over values defined on the client or passed to this method.
549
+ extra_headers: Headers | None = None,
550
+ extra_query: Query | None = None,
551
+ extra_body: Body | None = None,
552
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
553
+ ) -> RuleListResponse:
554
+ """
555
+ List all notification rules.
556
+
557
+ Args:
558
+ channel: Filtering by multiple notifiaction channel ids.
559
+
560
+ Usage: `?channel=01ARZ3NDEKTSV4RRFFQ69G5FAV&channel=01J8J2Y5X4NNGQS32CF81W95E3`
561
+
562
+ feature: Filtering by multiple feature ids/keys.
563
+
564
+ Usage: `?feature=feature-1&feature=feature-2`
565
+
566
+ include_deleted: Include deleted notification rules in response.
567
+
568
+ Usage: `?includeDeleted=true`
569
+
570
+ include_disabled: Include disabled notification rules in response.
571
+
572
+ Usage: `?includeDisabled=false`
573
+
574
+ order: The order direction.
575
+
576
+ order_by: The order by field.
577
+
578
+ page: Start date-time in RFC 3339 format.
579
+
580
+ Inclusive.
581
+
582
+ page_size: Number of items per page.
583
+
584
+ Default is 100.
585
+
586
+ extra_headers: Send extra headers
587
+
588
+ extra_query: Add additional query parameters to the request
589
+
590
+ extra_body: Add additional JSON properties to the request
591
+
592
+ timeout: Override the client-level default timeout for this request, in seconds
593
+ """
594
+ return await self._get(
595
+ "/api/v1/notification/rules",
596
+ options=make_request_options(
597
+ extra_headers=extra_headers,
598
+ extra_query=extra_query,
599
+ extra_body=extra_body,
600
+ timeout=timeout,
601
+ query=await async_maybe_transform(
602
+ {
603
+ "channel": channel,
604
+ "feature": feature,
605
+ "include_deleted": include_deleted,
606
+ "include_disabled": include_disabled,
607
+ "order": order,
608
+ "order_by": order_by,
609
+ "page": page,
610
+ "page_size": page_size,
611
+ },
612
+ rule_list_params.RuleListParams,
613
+ ),
614
+ ),
615
+ cast_to=RuleListResponse,
616
+ )
617
+
618
+ async def delete(
619
+ self,
620
+ rule_id: str,
621
+ *,
622
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
623
+ # The extra values given here take precedence over values defined on the client or passed to this method.
624
+ extra_headers: Headers | None = None,
625
+ extra_query: Query | None = None,
626
+ extra_body: Body | None = None,
627
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
628
+ ) -> None:
629
+ """
630
+ Soft delete notification rule by id.
631
+
632
+ Once a notification rule is deleted it cannot be undeleted.
633
+
634
+ Args:
635
+ extra_headers: Send extra headers
636
+
637
+ extra_query: Add additional query parameters to the request
638
+
639
+ extra_body: Add additional JSON properties to the request
640
+
641
+ timeout: Override the client-level default timeout for this request, in seconds
642
+ """
643
+ if not rule_id:
644
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
645
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
646
+ return await self._delete(
647
+ f"/api/v1/notification/rules/{rule_id}",
648
+ options=make_request_options(
649
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
650
+ ),
651
+ cast_to=NoneType,
652
+ )
653
+
654
+ async def test(
655
+ self,
656
+ rule_id: str,
657
+ *,
658
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
659
+ # The extra values given here take precedence over values defined on the client or passed to this method.
660
+ extra_headers: Headers | None = None,
661
+ extra_query: Query | None = None,
662
+ extra_body: Body | None = None,
663
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
664
+ ) -> NotificationEvent:
665
+ """
666
+ Test a notification rule by sending a test event with random data.
667
+
668
+ Args:
669
+ extra_headers: Send extra headers
670
+
671
+ extra_query: Add additional query parameters to the request
672
+
673
+ extra_body: Add additional JSON properties to the request
674
+
675
+ timeout: Override the client-level default timeout for this request, in seconds
676
+ """
677
+ if not rule_id:
678
+ raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}")
679
+ return await self._post(
680
+ f"/api/v1/notification/rules/{rule_id}/test",
681
+ options=make_request_options(
682
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
683
+ ),
684
+ cast_to=NotificationEvent,
685
+ )
686
+
687
+
688
+ class RulesResourceWithRawResponse:
689
+ def __init__(self, rules: RulesResource) -> None:
690
+ self._rules = rules
691
+
692
+ self.create = to_raw_response_wrapper(
693
+ rules.create,
694
+ )
695
+ self.retrieve = to_raw_response_wrapper(
696
+ rules.retrieve,
697
+ )
698
+ self.update = to_raw_response_wrapper(
699
+ rules.update,
700
+ )
701
+ self.list = to_raw_response_wrapper(
702
+ rules.list,
703
+ )
704
+ self.delete = to_raw_response_wrapper(
705
+ rules.delete,
706
+ )
707
+ self.test = to_raw_response_wrapper(
708
+ rules.test,
709
+ )
710
+
711
+
712
+ class AsyncRulesResourceWithRawResponse:
713
+ def __init__(self, rules: AsyncRulesResource) -> None:
714
+ self._rules = rules
715
+
716
+ self.create = async_to_raw_response_wrapper(
717
+ rules.create,
718
+ )
719
+ self.retrieve = async_to_raw_response_wrapper(
720
+ rules.retrieve,
721
+ )
722
+ self.update = async_to_raw_response_wrapper(
723
+ rules.update,
724
+ )
725
+ self.list = async_to_raw_response_wrapper(
726
+ rules.list,
727
+ )
728
+ self.delete = async_to_raw_response_wrapper(
729
+ rules.delete,
730
+ )
731
+ self.test = async_to_raw_response_wrapper(
732
+ rules.test,
733
+ )
734
+
735
+
736
+ class RulesResourceWithStreamingResponse:
737
+ def __init__(self, rules: RulesResource) -> None:
738
+ self._rules = rules
739
+
740
+ self.create = to_streamed_response_wrapper(
741
+ rules.create,
742
+ )
743
+ self.retrieve = to_streamed_response_wrapper(
744
+ rules.retrieve,
745
+ )
746
+ self.update = to_streamed_response_wrapper(
747
+ rules.update,
748
+ )
749
+ self.list = to_streamed_response_wrapper(
750
+ rules.list,
751
+ )
752
+ self.delete = to_streamed_response_wrapper(
753
+ rules.delete,
754
+ )
755
+ self.test = to_streamed_response_wrapper(
756
+ rules.test,
757
+ )
758
+
759
+
760
+ class AsyncRulesResourceWithStreamingResponse:
761
+ def __init__(self, rules: AsyncRulesResource) -> None:
762
+ self._rules = rules
763
+
764
+ self.create = async_to_streamed_response_wrapper(
765
+ rules.create,
766
+ )
767
+ self.retrieve = async_to_streamed_response_wrapper(
768
+ rules.retrieve,
769
+ )
770
+ self.update = async_to_streamed_response_wrapper(
771
+ rules.update,
772
+ )
773
+ self.list = async_to_streamed_response_wrapper(
774
+ rules.list,
775
+ )
776
+ self.delete = async_to_streamed_response_wrapper(
777
+ rules.delete,
778
+ )
779
+ self.test = async_to_streamed_response_wrapper(
780
+ rules.test,
781
+ )