paid-python 1.0.0a0__py3-none-any.whl → 1.0.0a1__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.
- paid/__init__.py +61 -122
- paid/client.py +16 -22
- paid/contacts/client.py +415 -133
- paid/contacts/raw_client.py +1046 -118
- paid/core/client_wrapper.py +8 -10
- paid/customers/__init__.py +0 -3
- paid/customers/client.py +392 -1112
- paid/customers/raw_client.py +656 -1054
- paid/environment.py +1 -1
- paid/errors/bad_request_error.py +2 -2
- paid/errors/forbidden_error.py +2 -2
- paid/errors/internal_server_error.py +2 -2
- paid/errors/not_found_error.py +2 -2
- paid/invoices/client.py +369 -0
- paid/{plans → invoices}/raw_client.py +310 -201
- paid/orders/__init__.py +0 -3
- paid/orders/client.py +279 -471
- paid/orders/raw_client.py +551 -538
- paid/products/__init__.py +0 -3
- paid/products/client.py +129 -265
- paid/products/raw_client.py +563 -233
- paid/signals/client.py +130 -0
- paid/signals/raw_client.py +190 -0
- paid/tracing/autoinstrumentation.py +12 -6
- paid/tracing/context_manager.py +2 -6
- paid/tracing/distributed_tracing.py +3 -3
- paid/tracing/signal.py +3 -3
- paid/tracing/wrappers/openai_agents/openaiAgentsHook.py +1 -1
- paid/types/__init__.py +58 -110
- paid/types/attribution.py +8 -0
- paid/types/{agent_attribute.py → bulk_signals_response.py} +4 -5
- paid/types/contact.py +12 -20
- paid/types/{address.py → contact_billing_address.py} +6 -7
- paid/types/{traces_response.py → contact_list_response.py} +5 -9
- paid/types/customer.py +15 -22
- paid/types/customer_attribution.py +8 -0
- paid/types/customer_billing_address.py +26 -0
- paid/types/{usage_summary_order.py → customer_by_external_id.py} +3 -5
- paid/types/{usage_summary_order_line.py → customer_by_id.py} +3 -5
- paid/types/customer_creation_state.py +5 -0
- paid/types/customer_list_response.py +22 -0
- paid/types/empty_response.py +17 -0
- paid/types/{error.py → error_response.py} +4 -7
- paid/types/invoice.py +33 -51
- paid/types/invoice_line.py +42 -0
- paid/types/invoice_line_payment_status.py +7 -0
- paid/types/invoice_lines_response.py +22 -0
- paid/types/invoice_list_response.py +22 -0
- paid/types/invoice_payment_status.py +5 -0
- paid/types/invoice_source.py +5 -0
- paid/types/invoice_status.py +3 -1
- paid/types/invoice_tax_status.py +7 -0
- paid/types/order.py +30 -29
- paid/types/order_creation_state.py +5 -0
- paid/types/order_line.py +6 -24
- paid/types/order_lines_response.py +22 -0
- paid/types/order_list_response.py +22 -0
- paid/types/pagination.py +24 -0
- paid/types/product.py +4 -29
- paid/types/{tier.py → product_by_external_id.py} +5 -4
- paid/types/{cost_amount.py → product_by_id.py} +5 -12
- paid/types/product_list_response.py +22 -0
- paid/types/signal.py +8 -34
- paid/types/{agent_update.py → update_contact_request.py} +10 -9
- paid/types/update_customer_request.py +38 -0
- paid/types/{product_update.py → update_product_request.py} +2 -12
- {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a1.dist-info}/METADATA +22 -8
- paid_python-1.0.0a1.dist-info/RECORD +110 -0
- paid/agents/client.py +0 -880
- paid/agents/raw_client.py +0 -785
- paid/customers/types/__init__.py +0 -8
- paid/customers/types/customers_check_entitlement_request_view.py +0 -5
- paid/customers/types/customers_check_entitlement_response.py +0 -22
- paid/orders/lines/client.py +0 -144
- paid/orders/lines/raw_client.py +0 -129
- paid/plans/__init__.py +0 -4
- paid/plans/client.py +0 -403
- paid/products/types/__init__.py +0 -7
- paid/products/types/product_create_type.py +0 -5
- paid/traces/__init__.py +0 -4
- paid/traces/client.py +0 -218
- paid/traces/raw_client.py +0 -226
- paid/types/agent.py +0 -31
- paid/types/agent_price_point.py +0 -27
- paid/types/agent_price_point_tiers.py +0 -23
- paid/types/api_error.py +0 -29
- paid/types/billing_frequency.py +0 -5
- paid/types/cancel_renewal_response.py +0 -49
- paid/types/charge_type.py +0 -5
- paid/types/contact_create_for_customer.py +0 -37
- paid/types/cost_trace.py +0 -55
- paid/types/cost_traces_response.py +0 -26
- paid/types/creation_source.py +0 -5
- paid/types/creation_state.py +0 -5
- paid/types/customer_update.py +0 -40
- paid/types/entitlement_usage.py +0 -48
- paid/types/order_line_attribute.py +0 -27
- paid/types/order_line_attribute_create_one.py +0 -5
- paid/types/order_line_attribute_pricing.py +0 -33
- paid/types/order_line_create.py +0 -72
- paid/types/pagination_meta.py +0 -84
- paid/types/payment_method.py +0 -58
- paid/types/payment_method_card.py +0 -49
- paid/types/payment_method_type.py +0 -5
- paid/types/payment_method_us_bank_account.py +0 -36
- paid/types/payment_method_us_bank_account_account_type.py +0 -5
- paid/types/plan.py +0 -81
- paid/types/plan_group.py +0 -60
- paid/types/plan_plan_products_item.py +0 -41
- paid/types/plan_plan_products_item_plan_product_attribute_item.py +0 -34
- paid/types/plan_with_features.py +0 -69
- paid/types/plan_with_features_features_item.py +0 -34
- paid/types/price_point.py +0 -25
- paid/types/pricing.py +0 -31
- paid/types/pricing_model_type.py +0 -7
- paid/types/product_type.py +0 -5
- paid/types/product_update_type.py +0 -5
- paid/types/proration_attribute_update.py +0 -44
- paid/types/proration_detail.py +0 -49
- paid/types/proration_upgrade_response.py +0 -73
- paid/types/salutation.py +0 -5
- paid/types/signal_v_2.py +0 -56
- paid/types/tax_exempt_status.py +0 -5
- paid/types/trace.py +0 -69
- paid/types/usage_pagination_meta.py +0 -43
- paid/types/usage_summaries_response.py +0 -26
- paid/types/usage_summary.py +0 -121
- paid/usage/__init__.py +0 -7
- paid/usage/client.py +0 -321
- paid/usage/raw_client.py +0 -387
- paid/usage/types/__init__.py +0 -7
- paid/usage/types/usage_check_usage_response.py +0 -53
- paid_python-1.0.0a0.dist-info/RECORD +0 -152
- /paid/{agents → invoices}/__init__.py +0 -0
- /paid/{orders/lines → signals}/__init__.py +0 -0
- {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a1.dist-info}/LICENSE +0 -0
- {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a1.dist-info}/WHEEL +0 -0
paid/usage/client.py
DELETED
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
|
|
5
|
-
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
-
from ..core.request_options import RequestOptions
|
|
7
|
-
from ..types.signal import Signal
|
|
8
|
-
from ..types.signal_v_2 import SignalV2
|
|
9
|
-
from .raw_client import AsyncRawUsageClient, RawUsageClient
|
|
10
|
-
from .types.usage_check_usage_response import UsageCheckUsageResponse
|
|
11
|
-
|
|
12
|
-
# this is used as the default value for optional parameters
|
|
13
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class UsageClient:
|
|
17
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
18
|
-
self._raw_client = RawUsageClient(client_wrapper=client_wrapper)
|
|
19
|
-
|
|
20
|
-
@property
|
|
21
|
-
def with_raw_response(self) -> RawUsageClient:
|
|
22
|
-
"""
|
|
23
|
-
Retrieves a raw implementation of this client that returns raw responses.
|
|
24
|
-
|
|
25
|
-
Returns
|
|
26
|
-
-------
|
|
27
|
-
RawUsageClient
|
|
28
|
-
"""
|
|
29
|
-
return self._raw_client
|
|
30
|
-
|
|
31
|
-
def record_bulk(
|
|
32
|
-
self,
|
|
33
|
-
*,
|
|
34
|
-
signals: typing.Optional[typing.Sequence[Signal]] = OMIT,
|
|
35
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
36
|
-
) -> None:
|
|
37
|
-
"""
|
|
38
|
-
DEPRECATED: Use POST /usage/v2/signals/bulk instead for cleaner field names.
|
|
39
|
-
|
|
40
|
-
Parameters
|
|
41
|
-
----------
|
|
42
|
-
signals : typing.Optional[typing.Sequence[Signal]]
|
|
43
|
-
|
|
44
|
-
request_options : typing.Optional[RequestOptions]
|
|
45
|
-
Request-specific configuration.
|
|
46
|
-
|
|
47
|
-
Returns
|
|
48
|
-
-------
|
|
49
|
-
None
|
|
50
|
-
|
|
51
|
-
Examples
|
|
52
|
-
--------
|
|
53
|
-
from paid import Paid, Signal
|
|
54
|
-
|
|
55
|
-
client = Paid(
|
|
56
|
-
token="YOUR_TOKEN",
|
|
57
|
-
)
|
|
58
|
-
client.usage.record_bulk(
|
|
59
|
-
signals=[Signal(), Signal(), Signal()],
|
|
60
|
-
)
|
|
61
|
-
"""
|
|
62
|
-
_response = self._raw_client.record_bulk(signals=signals, request_options=request_options)
|
|
63
|
-
return _response.data
|
|
64
|
-
|
|
65
|
-
def usage_record_bulk_v_2(
|
|
66
|
-
self,
|
|
67
|
-
*,
|
|
68
|
-
signals: typing.Optional[typing.Sequence[SignalV2]] = OMIT,
|
|
69
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
70
|
-
) -> None:
|
|
71
|
-
"""
|
|
72
|
-
Parameters
|
|
73
|
-
----------
|
|
74
|
-
signals : typing.Optional[typing.Sequence[SignalV2]]
|
|
75
|
-
|
|
76
|
-
request_options : typing.Optional[RequestOptions]
|
|
77
|
-
Request-specific configuration.
|
|
78
|
-
|
|
79
|
-
Returns
|
|
80
|
-
-------
|
|
81
|
-
None
|
|
82
|
-
|
|
83
|
-
Examples
|
|
84
|
-
--------
|
|
85
|
-
from paid import Paid, SignalV2
|
|
86
|
-
|
|
87
|
-
client = Paid(
|
|
88
|
-
token="YOUR_TOKEN",
|
|
89
|
-
)
|
|
90
|
-
client.usage.usage_record_bulk_v_2(
|
|
91
|
-
signals=[
|
|
92
|
-
SignalV2(
|
|
93
|
-
event_name="emails_sent",
|
|
94
|
-
product_id="prod_abc123def",
|
|
95
|
-
customer_id="cus_xyz789ghi",
|
|
96
|
-
),
|
|
97
|
-
SignalV2(
|
|
98
|
-
event_name="emails_sent",
|
|
99
|
-
external_product_id="acme-product",
|
|
100
|
-
external_customer_id="acme-inc",
|
|
101
|
-
),
|
|
102
|
-
SignalV2(
|
|
103
|
-
event_name="meeting_booked",
|
|
104
|
-
product_id="prod_abc123def",
|
|
105
|
-
external_customer_id="acme-inc",
|
|
106
|
-
data={"meeting_duration": 30, "meeting_type": "demo"},
|
|
107
|
-
),
|
|
108
|
-
],
|
|
109
|
-
)
|
|
110
|
-
"""
|
|
111
|
-
_response = self._raw_client.usage_record_bulk_v_2(signals=signals, request_options=request_options)
|
|
112
|
-
return _response.data
|
|
113
|
-
|
|
114
|
-
def check_usage(
|
|
115
|
-
self,
|
|
116
|
-
*,
|
|
117
|
-
external_customer_id: str,
|
|
118
|
-
external_product_id: str,
|
|
119
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
120
|
-
) -> UsageCheckUsageResponse:
|
|
121
|
-
"""
|
|
122
|
-
Parameters
|
|
123
|
-
----------
|
|
124
|
-
external_customer_id : str
|
|
125
|
-
External customer ID
|
|
126
|
-
|
|
127
|
-
external_product_id : str
|
|
128
|
-
External product ID (the external ID of the product/agent)
|
|
129
|
-
|
|
130
|
-
request_options : typing.Optional[RequestOptions]
|
|
131
|
-
Request-specific configuration.
|
|
132
|
-
|
|
133
|
-
Returns
|
|
134
|
-
-------
|
|
135
|
-
UsageCheckUsageResponse
|
|
136
|
-
Usage check response
|
|
137
|
-
|
|
138
|
-
Examples
|
|
139
|
-
--------
|
|
140
|
-
from paid import Paid
|
|
141
|
-
|
|
142
|
-
client = Paid(
|
|
143
|
-
token="YOUR_TOKEN",
|
|
144
|
-
)
|
|
145
|
-
client.usage.check_usage(
|
|
146
|
-
external_customer_id="acme-inc",
|
|
147
|
-
external_product_id="acme-agent",
|
|
148
|
-
)
|
|
149
|
-
"""
|
|
150
|
-
_response = self._raw_client.check_usage(
|
|
151
|
-
external_customer_id=external_customer_id,
|
|
152
|
-
external_product_id=external_product_id,
|
|
153
|
-
request_options=request_options,
|
|
154
|
-
)
|
|
155
|
-
return _response.data
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
class AsyncUsageClient:
|
|
159
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
160
|
-
self._raw_client = AsyncRawUsageClient(client_wrapper=client_wrapper)
|
|
161
|
-
|
|
162
|
-
@property
|
|
163
|
-
def with_raw_response(self) -> AsyncRawUsageClient:
|
|
164
|
-
"""
|
|
165
|
-
Retrieves a raw implementation of this client that returns raw responses.
|
|
166
|
-
|
|
167
|
-
Returns
|
|
168
|
-
-------
|
|
169
|
-
AsyncRawUsageClient
|
|
170
|
-
"""
|
|
171
|
-
return self._raw_client
|
|
172
|
-
|
|
173
|
-
async def record_bulk(
|
|
174
|
-
self,
|
|
175
|
-
*,
|
|
176
|
-
signals: typing.Optional[typing.Sequence[Signal]] = OMIT,
|
|
177
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
178
|
-
) -> None:
|
|
179
|
-
"""
|
|
180
|
-
DEPRECATED: Use POST /usage/v2/signals/bulk instead for cleaner field names.
|
|
181
|
-
|
|
182
|
-
Parameters
|
|
183
|
-
----------
|
|
184
|
-
signals : typing.Optional[typing.Sequence[Signal]]
|
|
185
|
-
|
|
186
|
-
request_options : typing.Optional[RequestOptions]
|
|
187
|
-
Request-specific configuration.
|
|
188
|
-
|
|
189
|
-
Returns
|
|
190
|
-
-------
|
|
191
|
-
None
|
|
192
|
-
|
|
193
|
-
Examples
|
|
194
|
-
--------
|
|
195
|
-
import asyncio
|
|
196
|
-
|
|
197
|
-
from paid import AsyncPaid, Signal
|
|
198
|
-
|
|
199
|
-
client = AsyncPaid(
|
|
200
|
-
token="YOUR_TOKEN",
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
async def main() -> None:
|
|
205
|
-
await client.usage.record_bulk(
|
|
206
|
-
signals=[Signal(), Signal(), Signal()],
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
asyncio.run(main())
|
|
211
|
-
"""
|
|
212
|
-
_response = await self._raw_client.record_bulk(signals=signals, request_options=request_options)
|
|
213
|
-
return _response.data
|
|
214
|
-
|
|
215
|
-
async def usage_record_bulk_v_2(
|
|
216
|
-
self,
|
|
217
|
-
*,
|
|
218
|
-
signals: typing.Optional[typing.Sequence[SignalV2]] = OMIT,
|
|
219
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
220
|
-
) -> None:
|
|
221
|
-
"""
|
|
222
|
-
Parameters
|
|
223
|
-
----------
|
|
224
|
-
signals : typing.Optional[typing.Sequence[SignalV2]]
|
|
225
|
-
|
|
226
|
-
request_options : typing.Optional[RequestOptions]
|
|
227
|
-
Request-specific configuration.
|
|
228
|
-
|
|
229
|
-
Returns
|
|
230
|
-
-------
|
|
231
|
-
None
|
|
232
|
-
|
|
233
|
-
Examples
|
|
234
|
-
--------
|
|
235
|
-
import asyncio
|
|
236
|
-
|
|
237
|
-
from paid import AsyncPaid, SignalV2
|
|
238
|
-
|
|
239
|
-
client = AsyncPaid(
|
|
240
|
-
token="YOUR_TOKEN",
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
async def main() -> None:
|
|
245
|
-
await client.usage.usage_record_bulk_v_2(
|
|
246
|
-
signals=[
|
|
247
|
-
SignalV2(
|
|
248
|
-
event_name="emails_sent",
|
|
249
|
-
product_id="prod_abc123def",
|
|
250
|
-
customer_id="cus_xyz789ghi",
|
|
251
|
-
),
|
|
252
|
-
SignalV2(
|
|
253
|
-
event_name="emails_sent",
|
|
254
|
-
external_product_id="acme-product",
|
|
255
|
-
external_customer_id="acme-inc",
|
|
256
|
-
),
|
|
257
|
-
SignalV2(
|
|
258
|
-
event_name="meeting_booked",
|
|
259
|
-
product_id="prod_abc123def",
|
|
260
|
-
external_customer_id="acme-inc",
|
|
261
|
-
data={"meeting_duration": 30, "meeting_type": "demo"},
|
|
262
|
-
),
|
|
263
|
-
],
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
asyncio.run(main())
|
|
268
|
-
"""
|
|
269
|
-
_response = await self._raw_client.usage_record_bulk_v_2(signals=signals, request_options=request_options)
|
|
270
|
-
return _response.data
|
|
271
|
-
|
|
272
|
-
async def check_usage(
|
|
273
|
-
self,
|
|
274
|
-
*,
|
|
275
|
-
external_customer_id: str,
|
|
276
|
-
external_product_id: str,
|
|
277
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
278
|
-
) -> UsageCheckUsageResponse:
|
|
279
|
-
"""
|
|
280
|
-
Parameters
|
|
281
|
-
----------
|
|
282
|
-
external_customer_id : str
|
|
283
|
-
External customer ID
|
|
284
|
-
|
|
285
|
-
external_product_id : str
|
|
286
|
-
External product ID (the external ID of the product/agent)
|
|
287
|
-
|
|
288
|
-
request_options : typing.Optional[RequestOptions]
|
|
289
|
-
Request-specific configuration.
|
|
290
|
-
|
|
291
|
-
Returns
|
|
292
|
-
-------
|
|
293
|
-
UsageCheckUsageResponse
|
|
294
|
-
Usage check response
|
|
295
|
-
|
|
296
|
-
Examples
|
|
297
|
-
--------
|
|
298
|
-
import asyncio
|
|
299
|
-
|
|
300
|
-
from paid import AsyncPaid
|
|
301
|
-
|
|
302
|
-
client = AsyncPaid(
|
|
303
|
-
token="YOUR_TOKEN",
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
async def main() -> None:
|
|
308
|
-
await client.usage.check_usage(
|
|
309
|
-
external_customer_id="acme-inc",
|
|
310
|
-
external_product_id="acme-agent",
|
|
311
|
-
)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
asyncio.run(main())
|
|
315
|
-
"""
|
|
316
|
-
_response = await self._raw_client.check_usage(
|
|
317
|
-
external_customer_id=external_customer_id,
|
|
318
|
-
external_product_id=external_product_id,
|
|
319
|
-
request_options=request_options,
|
|
320
|
-
)
|
|
321
|
-
return _response.data
|
paid/usage/raw_client.py
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
3
|
-
import typing
|
|
4
|
-
from json.decoder import JSONDecodeError
|
|
5
|
-
|
|
6
|
-
from ..core.api_error import ApiError
|
|
7
|
-
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
-
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
-
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
-
from ..core.request_options import RequestOptions
|
|
11
|
-
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
12
|
-
from ..errors.bad_request_error import BadRequestError
|
|
13
|
-
from ..errors.internal_server_error import InternalServerError
|
|
14
|
-
from ..errors.not_found_error import NotFoundError
|
|
15
|
-
from ..types.error import Error
|
|
16
|
-
from ..types.signal import Signal
|
|
17
|
-
from ..types.signal_v_2 import SignalV2
|
|
18
|
-
from .types.usage_check_usage_response import UsageCheckUsageResponse
|
|
19
|
-
|
|
20
|
-
# this is used as the default value for optional parameters
|
|
21
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class RawUsageClient:
|
|
25
|
-
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
26
|
-
self._client_wrapper = client_wrapper
|
|
27
|
-
|
|
28
|
-
def record_bulk(
|
|
29
|
-
self,
|
|
30
|
-
*,
|
|
31
|
-
signals: typing.Optional[typing.Sequence[Signal]] = OMIT,
|
|
32
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
33
|
-
) -> HttpResponse[None]:
|
|
34
|
-
"""
|
|
35
|
-
DEPRECATED: Use POST /usage/v2/signals/bulk instead for cleaner field names.
|
|
36
|
-
|
|
37
|
-
Parameters
|
|
38
|
-
----------
|
|
39
|
-
signals : typing.Optional[typing.Sequence[Signal]]
|
|
40
|
-
|
|
41
|
-
request_options : typing.Optional[RequestOptions]
|
|
42
|
-
Request-specific configuration.
|
|
43
|
-
|
|
44
|
-
Returns
|
|
45
|
-
-------
|
|
46
|
-
HttpResponse[None]
|
|
47
|
-
"""
|
|
48
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
49
|
-
"usage/signals/bulk",
|
|
50
|
-
method="POST",
|
|
51
|
-
json={
|
|
52
|
-
"signals": convert_and_respect_annotation_metadata(
|
|
53
|
-
object_=signals, annotation=typing.Sequence[Signal], direction="write"
|
|
54
|
-
),
|
|
55
|
-
},
|
|
56
|
-
headers={
|
|
57
|
-
"content-type": "application/json",
|
|
58
|
-
},
|
|
59
|
-
request_options=request_options,
|
|
60
|
-
omit=OMIT,
|
|
61
|
-
)
|
|
62
|
-
try:
|
|
63
|
-
if 200 <= _response.status_code < 300:
|
|
64
|
-
return HttpResponse(response=_response, data=None)
|
|
65
|
-
_response_json = _response.json()
|
|
66
|
-
except JSONDecodeError:
|
|
67
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
68
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
69
|
-
|
|
70
|
-
def usage_record_bulk_v_2(
|
|
71
|
-
self,
|
|
72
|
-
*,
|
|
73
|
-
signals: typing.Optional[typing.Sequence[SignalV2]] = OMIT,
|
|
74
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
75
|
-
) -> HttpResponse[None]:
|
|
76
|
-
"""
|
|
77
|
-
Parameters
|
|
78
|
-
----------
|
|
79
|
-
signals : typing.Optional[typing.Sequence[SignalV2]]
|
|
80
|
-
|
|
81
|
-
request_options : typing.Optional[RequestOptions]
|
|
82
|
-
Request-specific configuration.
|
|
83
|
-
|
|
84
|
-
Returns
|
|
85
|
-
-------
|
|
86
|
-
HttpResponse[None]
|
|
87
|
-
"""
|
|
88
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
89
|
-
"usage/v2/signals/bulk",
|
|
90
|
-
method="POST",
|
|
91
|
-
json={
|
|
92
|
-
"signals": convert_and_respect_annotation_metadata(
|
|
93
|
-
object_=signals, annotation=typing.Sequence[SignalV2], direction="write"
|
|
94
|
-
),
|
|
95
|
-
},
|
|
96
|
-
headers={
|
|
97
|
-
"content-type": "application/json",
|
|
98
|
-
},
|
|
99
|
-
request_options=request_options,
|
|
100
|
-
omit=OMIT,
|
|
101
|
-
)
|
|
102
|
-
try:
|
|
103
|
-
if 200 <= _response.status_code < 300:
|
|
104
|
-
return HttpResponse(response=_response, data=None)
|
|
105
|
-
if _response.status_code == 400:
|
|
106
|
-
raise BadRequestError(
|
|
107
|
-
headers=dict(_response.headers),
|
|
108
|
-
body=typing.cast(
|
|
109
|
-
Error,
|
|
110
|
-
parse_obj_as(
|
|
111
|
-
type_=Error, # type: ignore
|
|
112
|
-
object_=_response.json(),
|
|
113
|
-
),
|
|
114
|
-
),
|
|
115
|
-
)
|
|
116
|
-
_response_json = _response.json()
|
|
117
|
-
except JSONDecodeError:
|
|
118
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
119
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
120
|
-
|
|
121
|
-
def check_usage(
|
|
122
|
-
self,
|
|
123
|
-
*,
|
|
124
|
-
external_customer_id: str,
|
|
125
|
-
external_product_id: str,
|
|
126
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
127
|
-
) -> HttpResponse[UsageCheckUsageResponse]:
|
|
128
|
-
"""
|
|
129
|
-
Parameters
|
|
130
|
-
----------
|
|
131
|
-
external_customer_id : str
|
|
132
|
-
External customer ID
|
|
133
|
-
|
|
134
|
-
external_product_id : str
|
|
135
|
-
External product ID (the external ID of the product/agent)
|
|
136
|
-
|
|
137
|
-
request_options : typing.Optional[RequestOptions]
|
|
138
|
-
Request-specific configuration.
|
|
139
|
-
|
|
140
|
-
Returns
|
|
141
|
-
-------
|
|
142
|
-
HttpResponse[UsageCheckUsageResponse]
|
|
143
|
-
Usage check response
|
|
144
|
-
"""
|
|
145
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
146
|
-
"usage/check-usage",
|
|
147
|
-
method="POST",
|
|
148
|
-
json={
|
|
149
|
-
"externalCustomerId": external_customer_id,
|
|
150
|
-
"externalProductId": external_product_id,
|
|
151
|
-
},
|
|
152
|
-
headers={
|
|
153
|
-
"content-type": "application/json",
|
|
154
|
-
},
|
|
155
|
-
request_options=request_options,
|
|
156
|
-
omit=OMIT,
|
|
157
|
-
)
|
|
158
|
-
try:
|
|
159
|
-
if 200 <= _response.status_code < 300:
|
|
160
|
-
_data = typing.cast(
|
|
161
|
-
UsageCheckUsageResponse,
|
|
162
|
-
parse_obj_as(
|
|
163
|
-
type_=UsageCheckUsageResponse, # type: ignore
|
|
164
|
-
object_=_response.json(),
|
|
165
|
-
),
|
|
166
|
-
)
|
|
167
|
-
return HttpResponse(response=_response, data=_data)
|
|
168
|
-
if _response.status_code == 400:
|
|
169
|
-
raise BadRequestError(
|
|
170
|
-
headers=dict(_response.headers),
|
|
171
|
-
body=typing.cast(
|
|
172
|
-
Error,
|
|
173
|
-
parse_obj_as(
|
|
174
|
-
type_=Error, # type: ignore
|
|
175
|
-
object_=_response.json(),
|
|
176
|
-
),
|
|
177
|
-
),
|
|
178
|
-
)
|
|
179
|
-
if _response.status_code == 404:
|
|
180
|
-
raise NotFoundError(
|
|
181
|
-
headers=dict(_response.headers),
|
|
182
|
-
body=typing.cast(
|
|
183
|
-
Error,
|
|
184
|
-
parse_obj_as(
|
|
185
|
-
type_=Error, # type: ignore
|
|
186
|
-
object_=_response.json(),
|
|
187
|
-
),
|
|
188
|
-
),
|
|
189
|
-
)
|
|
190
|
-
if _response.status_code == 500:
|
|
191
|
-
raise InternalServerError(
|
|
192
|
-
headers=dict(_response.headers),
|
|
193
|
-
body=typing.cast(
|
|
194
|
-
Error,
|
|
195
|
-
parse_obj_as(
|
|
196
|
-
type_=Error, # type: ignore
|
|
197
|
-
object_=_response.json(),
|
|
198
|
-
),
|
|
199
|
-
),
|
|
200
|
-
)
|
|
201
|
-
_response_json = _response.json()
|
|
202
|
-
except JSONDecodeError:
|
|
203
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
204
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
class AsyncRawUsageClient:
|
|
208
|
-
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
209
|
-
self._client_wrapper = client_wrapper
|
|
210
|
-
|
|
211
|
-
async def record_bulk(
|
|
212
|
-
self,
|
|
213
|
-
*,
|
|
214
|
-
signals: typing.Optional[typing.Sequence[Signal]] = OMIT,
|
|
215
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
216
|
-
) -> AsyncHttpResponse[None]:
|
|
217
|
-
"""
|
|
218
|
-
DEPRECATED: Use POST /usage/v2/signals/bulk instead for cleaner field names.
|
|
219
|
-
|
|
220
|
-
Parameters
|
|
221
|
-
----------
|
|
222
|
-
signals : typing.Optional[typing.Sequence[Signal]]
|
|
223
|
-
|
|
224
|
-
request_options : typing.Optional[RequestOptions]
|
|
225
|
-
Request-specific configuration.
|
|
226
|
-
|
|
227
|
-
Returns
|
|
228
|
-
-------
|
|
229
|
-
AsyncHttpResponse[None]
|
|
230
|
-
"""
|
|
231
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
232
|
-
"usage/signals/bulk",
|
|
233
|
-
method="POST",
|
|
234
|
-
json={
|
|
235
|
-
"signals": convert_and_respect_annotation_metadata(
|
|
236
|
-
object_=signals, annotation=typing.Sequence[Signal], direction="write"
|
|
237
|
-
),
|
|
238
|
-
},
|
|
239
|
-
headers={
|
|
240
|
-
"content-type": "application/json",
|
|
241
|
-
},
|
|
242
|
-
request_options=request_options,
|
|
243
|
-
omit=OMIT,
|
|
244
|
-
)
|
|
245
|
-
try:
|
|
246
|
-
if 200 <= _response.status_code < 300:
|
|
247
|
-
return AsyncHttpResponse(response=_response, data=None)
|
|
248
|
-
_response_json = _response.json()
|
|
249
|
-
except JSONDecodeError:
|
|
250
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
251
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
252
|
-
|
|
253
|
-
async def usage_record_bulk_v_2(
|
|
254
|
-
self,
|
|
255
|
-
*,
|
|
256
|
-
signals: typing.Optional[typing.Sequence[SignalV2]] = OMIT,
|
|
257
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
258
|
-
) -> AsyncHttpResponse[None]:
|
|
259
|
-
"""
|
|
260
|
-
Parameters
|
|
261
|
-
----------
|
|
262
|
-
signals : typing.Optional[typing.Sequence[SignalV2]]
|
|
263
|
-
|
|
264
|
-
request_options : typing.Optional[RequestOptions]
|
|
265
|
-
Request-specific configuration.
|
|
266
|
-
|
|
267
|
-
Returns
|
|
268
|
-
-------
|
|
269
|
-
AsyncHttpResponse[None]
|
|
270
|
-
"""
|
|
271
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
272
|
-
"usage/v2/signals/bulk",
|
|
273
|
-
method="POST",
|
|
274
|
-
json={
|
|
275
|
-
"signals": convert_and_respect_annotation_metadata(
|
|
276
|
-
object_=signals, annotation=typing.Sequence[SignalV2], direction="write"
|
|
277
|
-
),
|
|
278
|
-
},
|
|
279
|
-
headers={
|
|
280
|
-
"content-type": "application/json",
|
|
281
|
-
},
|
|
282
|
-
request_options=request_options,
|
|
283
|
-
omit=OMIT,
|
|
284
|
-
)
|
|
285
|
-
try:
|
|
286
|
-
if 200 <= _response.status_code < 300:
|
|
287
|
-
return AsyncHttpResponse(response=_response, data=None)
|
|
288
|
-
if _response.status_code == 400:
|
|
289
|
-
raise BadRequestError(
|
|
290
|
-
headers=dict(_response.headers),
|
|
291
|
-
body=typing.cast(
|
|
292
|
-
Error,
|
|
293
|
-
parse_obj_as(
|
|
294
|
-
type_=Error, # type: ignore
|
|
295
|
-
object_=_response.json(),
|
|
296
|
-
),
|
|
297
|
-
),
|
|
298
|
-
)
|
|
299
|
-
_response_json = _response.json()
|
|
300
|
-
except JSONDecodeError:
|
|
301
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
302
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
303
|
-
|
|
304
|
-
async def check_usage(
|
|
305
|
-
self,
|
|
306
|
-
*,
|
|
307
|
-
external_customer_id: str,
|
|
308
|
-
external_product_id: str,
|
|
309
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
310
|
-
) -> AsyncHttpResponse[UsageCheckUsageResponse]:
|
|
311
|
-
"""
|
|
312
|
-
Parameters
|
|
313
|
-
----------
|
|
314
|
-
external_customer_id : str
|
|
315
|
-
External customer ID
|
|
316
|
-
|
|
317
|
-
external_product_id : str
|
|
318
|
-
External product ID (the external ID of the product/agent)
|
|
319
|
-
|
|
320
|
-
request_options : typing.Optional[RequestOptions]
|
|
321
|
-
Request-specific configuration.
|
|
322
|
-
|
|
323
|
-
Returns
|
|
324
|
-
-------
|
|
325
|
-
AsyncHttpResponse[UsageCheckUsageResponse]
|
|
326
|
-
Usage check response
|
|
327
|
-
"""
|
|
328
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
329
|
-
"usage/check-usage",
|
|
330
|
-
method="POST",
|
|
331
|
-
json={
|
|
332
|
-
"externalCustomerId": external_customer_id,
|
|
333
|
-
"externalProductId": external_product_id,
|
|
334
|
-
},
|
|
335
|
-
headers={
|
|
336
|
-
"content-type": "application/json",
|
|
337
|
-
},
|
|
338
|
-
request_options=request_options,
|
|
339
|
-
omit=OMIT,
|
|
340
|
-
)
|
|
341
|
-
try:
|
|
342
|
-
if 200 <= _response.status_code < 300:
|
|
343
|
-
_data = typing.cast(
|
|
344
|
-
UsageCheckUsageResponse,
|
|
345
|
-
parse_obj_as(
|
|
346
|
-
type_=UsageCheckUsageResponse, # type: ignore
|
|
347
|
-
object_=_response.json(),
|
|
348
|
-
),
|
|
349
|
-
)
|
|
350
|
-
return AsyncHttpResponse(response=_response, data=_data)
|
|
351
|
-
if _response.status_code == 400:
|
|
352
|
-
raise BadRequestError(
|
|
353
|
-
headers=dict(_response.headers),
|
|
354
|
-
body=typing.cast(
|
|
355
|
-
Error,
|
|
356
|
-
parse_obj_as(
|
|
357
|
-
type_=Error, # type: ignore
|
|
358
|
-
object_=_response.json(),
|
|
359
|
-
),
|
|
360
|
-
),
|
|
361
|
-
)
|
|
362
|
-
if _response.status_code == 404:
|
|
363
|
-
raise NotFoundError(
|
|
364
|
-
headers=dict(_response.headers),
|
|
365
|
-
body=typing.cast(
|
|
366
|
-
Error,
|
|
367
|
-
parse_obj_as(
|
|
368
|
-
type_=Error, # type: ignore
|
|
369
|
-
object_=_response.json(),
|
|
370
|
-
),
|
|
371
|
-
),
|
|
372
|
-
)
|
|
373
|
-
if _response.status_code == 500:
|
|
374
|
-
raise InternalServerError(
|
|
375
|
-
headers=dict(_response.headers),
|
|
376
|
-
body=typing.cast(
|
|
377
|
-
Error,
|
|
378
|
-
parse_obj_as(
|
|
379
|
-
type_=Error, # type: ignore
|
|
380
|
-
object_=_response.json(),
|
|
381
|
-
),
|
|
382
|
-
),
|
|
383
|
-
)
|
|
384
|
-
_response_json = _response.json()
|
|
385
|
-
except JSONDecodeError:
|
|
386
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
387
|
-
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|