paid-python 0.4.1a0__py3-none-any.whl → 0.5.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.
- paid/__init__.py +42 -4
- paid/agents/client.py +32 -0
- paid/agents/raw_client.py +32 -0
- paid/client.py +25 -2
- paid/core/client_wrapper.py +2 -3
- paid/customers/client.py +168 -36
- paid/customers/raw_client.py +217 -36
- paid/errors/__init__.py +2 -1
- paid/errors/internal_server_error.py +11 -0
- paid/orders/lines/client.py +0 -4
- paid/plans/__init__.py +4 -0
- paid/plans/client.py +261 -0
- paid/plans/raw_client.py +345 -0
- paid/products/__init__.py +7 -0
- paid/products/client.py +788 -0
- paid/products/raw_client.py +807 -0
- paid/products/types/__init__.py +7 -0
- paid/products/types/product_create_type.py +5 -0
- paid/traces/__init__.py +4 -0
- paid/traces/client.py +218 -0
- paid/traces/raw_client.py +226 -0
- paid/tracing/context_manager.py +9 -4
- paid/types/__init__.py +32 -2
- paid/types/cost_trace.py +6 -1
- paid/types/customer.py +4 -3
- paid/types/customer_update.py +4 -2
- paid/types/order_line_attribute_create_one.py +5 -0
- paid/types/order_line_create.py +26 -5
- paid/types/pagination_meta.py +26 -0
- paid/types/plan.py +81 -0
- paid/types/plan_plan_products_item.py +35 -0
- paid/types/plan_plan_products_item_plan_product_attribute_item.py +34 -0
- paid/types/product.py +56 -0
- paid/types/product_type.py +5 -0
- paid/types/product_update.py +36 -0
- paid/types/product_update_type.py +5 -0
- paid/types/signal.py +17 -5
- paid/types/signal_v_2.py +56 -0
- paid/types/trace.py +69 -0
- paid/types/traces_response.py +26 -0
- paid/types/{order_line_attribute_create.py → usage_pagination_meta.py} +16 -8
- paid/types/usage_summaries_response.py +26 -0
- paid/types/usage_summary.py +121 -0
- paid/types/usage_summary_order.py +26 -0
- paid/types/usage_summary_order_line.py +26 -0
- paid/usage/__init__.py +3 -0
- paid/usage/client.py +206 -0
- paid/usage/raw_client.py +283 -0
- paid/usage/types/__init__.py +7 -0
- paid/usage/types/usage_check_usage_response.py +53 -0
- {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/METADATA +20 -20
- {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/RECORD +54 -25
- {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/LICENSE +0 -0
- {paid_python-0.4.1a0.dist-info → paid_python-0.5.0.dist-info}/WHEEL +0 -0
paid/traces/__init__.py
ADDED
paid/traces/client.py
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
7
|
+
from ..core.request_options import RequestOptions
|
|
8
|
+
from ..types.traces_response import TracesResponse
|
|
9
|
+
from .raw_client import AsyncRawTracesClient, RawTracesClient
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TracesClient:
|
|
13
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
14
|
+
self._raw_client = RawTracesClient(client_wrapper=client_wrapper)
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def with_raw_response(self) -> RawTracesClient:
|
|
18
|
+
"""
|
|
19
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
RawTracesClient
|
|
24
|
+
"""
|
|
25
|
+
return self._raw_client
|
|
26
|
+
|
|
27
|
+
def get_traces(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
limit: typing.Optional[int] = None,
|
|
31
|
+
offset: typing.Optional[int] = None,
|
|
32
|
+
start_time: typing.Optional[dt.datetime] = None,
|
|
33
|
+
end_time: typing.Optional[dt.datetime] = None,
|
|
34
|
+
external_customer_id: typing.Optional[str] = None,
|
|
35
|
+
external_product_id: typing.Optional[str] = None,
|
|
36
|
+
external_agent_id: typing.Optional[str] = None,
|
|
37
|
+
metadata: typing.Optional[str] = None,
|
|
38
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
39
|
+
) -> TracesResponse:
|
|
40
|
+
"""
|
|
41
|
+
Parameters
|
|
42
|
+
----------
|
|
43
|
+
limit : typing.Optional[int]
|
|
44
|
+
Maximum number of traces to return (1-1000)
|
|
45
|
+
|
|
46
|
+
offset : typing.Optional[int]
|
|
47
|
+
Number of traces to skip for pagination
|
|
48
|
+
|
|
49
|
+
start_time : typing.Optional[dt.datetime]
|
|
50
|
+
Filter traces starting from this time (ISO 8601 format)
|
|
51
|
+
|
|
52
|
+
end_time : typing.Optional[dt.datetime]
|
|
53
|
+
Filter traces up to this time (ISO 8601 format)
|
|
54
|
+
|
|
55
|
+
external_customer_id : typing.Optional[str]
|
|
56
|
+
Filter traces by external customer ID
|
|
57
|
+
|
|
58
|
+
external_product_id : typing.Optional[str]
|
|
59
|
+
Filter traces by external product ID
|
|
60
|
+
|
|
61
|
+
external_agent_id : typing.Optional[str]
|
|
62
|
+
DEPRECATED: Use externalProductId instead. Filter traces by external agent ID
|
|
63
|
+
|
|
64
|
+
metadata : typing.Optional[str]
|
|
65
|
+
Filter traces by metadata fields. Must be a valid JSON object (e.g., {"key1":"value1","key2":"value2"}). All specified fields must match (AND logic).
|
|
66
|
+
|
|
67
|
+
request_options : typing.Optional[RequestOptions]
|
|
68
|
+
Request-specific configuration.
|
|
69
|
+
|
|
70
|
+
Returns
|
|
71
|
+
-------
|
|
72
|
+
TracesResponse
|
|
73
|
+
Success response
|
|
74
|
+
|
|
75
|
+
Examples
|
|
76
|
+
--------
|
|
77
|
+
import datetime
|
|
78
|
+
|
|
79
|
+
from paid import Paid
|
|
80
|
+
|
|
81
|
+
client = Paid(
|
|
82
|
+
token="YOUR_TOKEN",
|
|
83
|
+
)
|
|
84
|
+
client.traces.get_traces(
|
|
85
|
+
limit=1,
|
|
86
|
+
offset=1,
|
|
87
|
+
start_time=datetime.datetime.fromisoformat(
|
|
88
|
+
"2024-01-15 09:30:00+00:00",
|
|
89
|
+
),
|
|
90
|
+
end_time=datetime.datetime.fromisoformat(
|
|
91
|
+
"2024-01-15 09:30:00+00:00",
|
|
92
|
+
),
|
|
93
|
+
external_customer_id="externalCustomerId",
|
|
94
|
+
external_product_id="externalProductId",
|
|
95
|
+
external_agent_id="externalAgentId",
|
|
96
|
+
metadata="metadata",
|
|
97
|
+
)
|
|
98
|
+
"""
|
|
99
|
+
_response = self._raw_client.get_traces(
|
|
100
|
+
limit=limit,
|
|
101
|
+
offset=offset,
|
|
102
|
+
start_time=start_time,
|
|
103
|
+
end_time=end_time,
|
|
104
|
+
external_customer_id=external_customer_id,
|
|
105
|
+
external_product_id=external_product_id,
|
|
106
|
+
external_agent_id=external_agent_id,
|
|
107
|
+
metadata=metadata,
|
|
108
|
+
request_options=request_options,
|
|
109
|
+
)
|
|
110
|
+
return _response.data
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class AsyncTracesClient:
|
|
114
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
115
|
+
self._raw_client = AsyncRawTracesClient(client_wrapper=client_wrapper)
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def with_raw_response(self) -> AsyncRawTracesClient:
|
|
119
|
+
"""
|
|
120
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
AsyncRawTracesClient
|
|
125
|
+
"""
|
|
126
|
+
return self._raw_client
|
|
127
|
+
|
|
128
|
+
async def get_traces(
|
|
129
|
+
self,
|
|
130
|
+
*,
|
|
131
|
+
limit: typing.Optional[int] = None,
|
|
132
|
+
offset: typing.Optional[int] = None,
|
|
133
|
+
start_time: typing.Optional[dt.datetime] = None,
|
|
134
|
+
end_time: typing.Optional[dt.datetime] = None,
|
|
135
|
+
external_customer_id: typing.Optional[str] = None,
|
|
136
|
+
external_product_id: typing.Optional[str] = None,
|
|
137
|
+
external_agent_id: typing.Optional[str] = None,
|
|
138
|
+
metadata: typing.Optional[str] = None,
|
|
139
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
140
|
+
) -> TracesResponse:
|
|
141
|
+
"""
|
|
142
|
+
Parameters
|
|
143
|
+
----------
|
|
144
|
+
limit : typing.Optional[int]
|
|
145
|
+
Maximum number of traces to return (1-1000)
|
|
146
|
+
|
|
147
|
+
offset : typing.Optional[int]
|
|
148
|
+
Number of traces to skip for pagination
|
|
149
|
+
|
|
150
|
+
start_time : typing.Optional[dt.datetime]
|
|
151
|
+
Filter traces starting from this time (ISO 8601 format)
|
|
152
|
+
|
|
153
|
+
end_time : typing.Optional[dt.datetime]
|
|
154
|
+
Filter traces up to this time (ISO 8601 format)
|
|
155
|
+
|
|
156
|
+
external_customer_id : typing.Optional[str]
|
|
157
|
+
Filter traces by external customer ID
|
|
158
|
+
|
|
159
|
+
external_product_id : typing.Optional[str]
|
|
160
|
+
Filter traces by external product ID
|
|
161
|
+
|
|
162
|
+
external_agent_id : typing.Optional[str]
|
|
163
|
+
DEPRECATED: Use externalProductId instead. Filter traces by external agent ID
|
|
164
|
+
|
|
165
|
+
metadata : typing.Optional[str]
|
|
166
|
+
Filter traces by metadata fields. Must be a valid JSON object (e.g., {"key1":"value1","key2":"value2"}). All specified fields must match (AND logic).
|
|
167
|
+
|
|
168
|
+
request_options : typing.Optional[RequestOptions]
|
|
169
|
+
Request-specific configuration.
|
|
170
|
+
|
|
171
|
+
Returns
|
|
172
|
+
-------
|
|
173
|
+
TracesResponse
|
|
174
|
+
Success response
|
|
175
|
+
|
|
176
|
+
Examples
|
|
177
|
+
--------
|
|
178
|
+
import asyncio
|
|
179
|
+
import datetime
|
|
180
|
+
|
|
181
|
+
from paid import AsyncPaid
|
|
182
|
+
|
|
183
|
+
client = AsyncPaid(
|
|
184
|
+
token="YOUR_TOKEN",
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
async def main() -> None:
|
|
189
|
+
await client.traces.get_traces(
|
|
190
|
+
limit=1,
|
|
191
|
+
offset=1,
|
|
192
|
+
start_time=datetime.datetime.fromisoformat(
|
|
193
|
+
"2024-01-15 09:30:00+00:00",
|
|
194
|
+
),
|
|
195
|
+
end_time=datetime.datetime.fromisoformat(
|
|
196
|
+
"2024-01-15 09:30:00+00:00",
|
|
197
|
+
),
|
|
198
|
+
external_customer_id="externalCustomerId",
|
|
199
|
+
external_product_id="externalProductId",
|
|
200
|
+
external_agent_id="externalAgentId",
|
|
201
|
+
metadata="metadata",
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
asyncio.run(main())
|
|
206
|
+
"""
|
|
207
|
+
_response = await self._raw_client.get_traces(
|
|
208
|
+
limit=limit,
|
|
209
|
+
offset=offset,
|
|
210
|
+
start_time=start_time,
|
|
211
|
+
end_time=end_time,
|
|
212
|
+
external_customer_id=external_customer_id,
|
|
213
|
+
external_product_id=external_product_id,
|
|
214
|
+
external_agent_id=external_agent_id,
|
|
215
|
+
metadata=metadata,
|
|
216
|
+
request_options=request_options,
|
|
217
|
+
)
|
|
218
|
+
return _response.data
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from ..core.api_error import ApiError
|
|
8
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ..core.datetime_utils import serialize_datetime
|
|
10
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
12
|
+
from ..core.request_options import RequestOptions
|
|
13
|
+
from ..errors.bad_request_error import BadRequestError
|
|
14
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
15
|
+
from ..types.error import Error
|
|
16
|
+
from ..types.traces_response import TracesResponse
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RawTracesClient:
|
|
20
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
21
|
+
self._client_wrapper = client_wrapper
|
|
22
|
+
|
|
23
|
+
def get_traces(
|
|
24
|
+
self,
|
|
25
|
+
*,
|
|
26
|
+
limit: typing.Optional[int] = None,
|
|
27
|
+
offset: typing.Optional[int] = None,
|
|
28
|
+
start_time: typing.Optional[dt.datetime] = None,
|
|
29
|
+
end_time: typing.Optional[dt.datetime] = None,
|
|
30
|
+
external_customer_id: typing.Optional[str] = None,
|
|
31
|
+
external_product_id: typing.Optional[str] = None,
|
|
32
|
+
external_agent_id: typing.Optional[str] = None,
|
|
33
|
+
metadata: typing.Optional[str] = None,
|
|
34
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
35
|
+
) -> HttpResponse[TracesResponse]:
|
|
36
|
+
"""
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
limit : typing.Optional[int]
|
|
40
|
+
Maximum number of traces to return (1-1000)
|
|
41
|
+
|
|
42
|
+
offset : typing.Optional[int]
|
|
43
|
+
Number of traces to skip for pagination
|
|
44
|
+
|
|
45
|
+
start_time : typing.Optional[dt.datetime]
|
|
46
|
+
Filter traces starting from this time (ISO 8601 format)
|
|
47
|
+
|
|
48
|
+
end_time : typing.Optional[dt.datetime]
|
|
49
|
+
Filter traces up to this time (ISO 8601 format)
|
|
50
|
+
|
|
51
|
+
external_customer_id : typing.Optional[str]
|
|
52
|
+
Filter traces by external customer ID
|
|
53
|
+
|
|
54
|
+
external_product_id : typing.Optional[str]
|
|
55
|
+
Filter traces by external product ID
|
|
56
|
+
|
|
57
|
+
external_agent_id : typing.Optional[str]
|
|
58
|
+
DEPRECATED: Use externalProductId instead. Filter traces by external agent ID
|
|
59
|
+
|
|
60
|
+
metadata : typing.Optional[str]
|
|
61
|
+
Filter traces by metadata fields. Must be a valid JSON object (e.g., {"key1":"value1","key2":"value2"}). All specified fields must match (AND logic).
|
|
62
|
+
|
|
63
|
+
request_options : typing.Optional[RequestOptions]
|
|
64
|
+
Request-specific configuration.
|
|
65
|
+
|
|
66
|
+
Returns
|
|
67
|
+
-------
|
|
68
|
+
HttpResponse[TracesResponse]
|
|
69
|
+
Success response
|
|
70
|
+
"""
|
|
71
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
72
|
+
"traces",
|
|
73
|
+
method="GET",
|
|
74
|
+
params={
|
|
75
|
+
"limit": limit,
|
|
76
|
+
"offset": offset,
|
|
77
|
+
"startTime": serialize_datetime(start_time) if start_time is not None else None,
|
|
78
|
+
"endTime": serialize_datetime(end_time) if end_time is not None else None,
|
|
79
|
+
"externalCustomerId": external_customer_id,
|
|
80
|
+
"externalProductId": external_product_id,
|
|
81
|
+
"externalAgentId": external_agent_id,
|
|
82
|
+
"metadata": metadata,
|
|
83
|
+
},
|
|
84
|
+
request_options=request_options,
|
|
85
|
+
)
|
|
86
|
+
try:
|
|
87
|
+
if 200 <= _response.status_code < 300:
|
|
88
|
+
_data = typing.cast(
|
|
89
|
+
TracesResponse,
|
|
90
|
+
parse_obj_as(
|
|
91
|
+
type_=TracesResponse, # type: ignore
|
|
92
|
+
object_=_response.json(),
|
|
93
|
+
),
|
|
94
|
+
)
|
|
95
|
+
return HttpResponse(response=_response, data=_data)
|
|
96
|
+
if _response.status_code == 400:
|
|
97
|
+
raise BadRequestError(
|
|
98
|
+
headers=dict(_response.headers),
|
|
99
|
+
body=typing.cast(
|
|
100
|
+
Error,
|
|
101
|
+
parse_obj_as(
|
|
102
|
+
type_=Error, # type: ignore
|
|
103
|
+
object_=_response.json(),
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
if _response.status_code == 403:
|
|
108
|
+
raise ForbiddenError(
|
|
109
|
+
headers=dict(_response.headers),
|
|
110
|
+
body=typing.cast(
|
|
111
|
+
Error,
|
|
112
|
+
parse_obj_as(
|
|
113
|
+
type_=Error, # type: ignore
|
|
114
|
+
object_=_response.json(),
|
|
115
|
+
),
|
|
116
|
+
),
|
|
117
|
+
)
|
|
118
|
+
_response_json = _response.json()
|
|
119
|
+
except JSONDecodeError:
|
|
120
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
121
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class AsyncRawTracesClient:
|
|
125
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
126
|
+
self._client_wrapper = client_wrapper
|
|
127
|
+
|
|
128
|
+
async def get_traces(
|
|
129
|
+
self,
|
|
130
|
+
*,
|
|
131
|
+
limit: typing.Optional[int] = None,
|
|
132
|
+
offset: typing.Optional[int] = None,
|
|
133
|
+
start_time: typing.Optional[dt.datetime] = None,
|
|
134
|
+
end_time: typing.Optional[dt.datetime] = None,
|
|
135
|
+
external_customer_id: typing.Optional[str] = None,
|
|
136
|
+
external_product_id: typing.Optional[str] = None,
|
|
137
|
+
external_agent_id: typing.Optional[str] = None,
|
|
138
|
+
metadata: typing.Optional[str] = None,
|
|
139
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
140
|
+
) -> AsyncHttpResponse[TracesResponse]:
|
|
141
|
+
"""
|
|
142
|
+
Parameters
|
|
143
|
+
----------
|
|
144
|
+
limit : typing.Optional[int]
|
|
145
|
+
Maximum number of traces to return (1-1000)
|
|
146
|
+
|
|
147
|
+
offset : typing.Optional[int]
|
|
148
|
+
Number of traces to skip for pagination
|
|
149
|
+
|
|
150
|
+
start_time : typing.Optional[dt.datetime]
|
|
151
|
+
Filter traces starting from this time (ISO 8601 format)
|
|
152
|
+
|
|
153
|
+
end_time : typing.Optional[dt.datetime]
|
|
154
|
+
Filter traces up to this time (ISO 8601 format)
|
|
155
|
+
|
|
156
|
+
external_customer_id : typing.Optional[str]
|
|
157
|
+
Filter traces by external customer ID
|
|
158
|
+
|
|
159
|
+
external_product_id : typing.Optional[str]
|
|
160
|
+
Filter traces by external product ID
|
|
161
|
+
|
|
162
|
+
external_agent_id : typing.Optional[str]
|
|
163
|
+
DEPRECATED: Use externalProductId instead. Filter traces by external agent ID
|
|
164
|
+
|
|
165
|
+
metadata : typing.Optional[str]
|
|
166
|
+
Filter traces by metadata fields. Must be a valid JSON object (e.g., {"key1":"value1","key2":"value2"}). All specified fields must match (AND logic).
|
|
167
|
+
|
|
168
|
+
request_options : typing.Optional[RequestOptions]
|
|
169
|
+
Request-specific configuration.
|
|
170
|
+
|
|
171
|
+
Returns
|
|
172
|
+
-------
|
|
173
|
+
AsyncHttpResponse[TracesResponse]
|
|
174
|
+
Success response
|
|
175
|
+
"""
|
|
176
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
177
|
+
"traces",
|
|
178
|
+
method="GET",
|
|
179
|
+
params={
|
|
180
|
+
"limit": limit,
|
|
181
|
+
"offset": offset,
|
|
182
|
+
"startTime": serialize_datetime(start_time) if start_time is not None else None,
|
|
183
|
+
"endTime": serialize_datetime(end_time) if end_time is not None else None,
|
|
184
|
+
"externalCustomerId": external_customer_id,
|
|
185
|
+
"externalProductId": external_product_id,
|
|
186
|
+
"externalAgentId": external_agent_id,
|
|
187
|
+
"metadata": metadata,
|
|
188
|
+
},
|
|
189
|
+
request_options=request_options,
|
|
190
|
+
)
|
|
191
|
+
try:
|
|
192
|
+
if 200 <= _response.status_code < 300:
|
|
193
|
+
_data = typing.cast(
|
|
194
|
+
TracesResponse,
|
|
195
|
+
parse_obj_as(
|
|
196
|
+
type_=TracesResponse, # type: ignore
|
|
197
|
+
object_=_response.json(),
|
|
198
|
+
),
|
|
199
|
+
)
|
|
200
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
201
|
+
if _response.status_code == 400:
|
|
202
|
+
raise BadRequestError(
|
|
203
|
+
headers=dict(_response.headers),
|
|
204
|
+
body=typing.cast(
|
|
205
|
+
Error,
|
|
206
|
+
parse_obj_as(
|
|
207
|
+
type_=Error, # type: ignore
|
|
208
|
+
object_=_response.json(),
|
|
209
|
+
),
|
|
210
|
+
),
|
|
211
|
+
)
|
|
212
|
+
if _response.status_code == 403:
|
|
213
|
+
raise ForbiddenError(
|
|
214
|
+
headers=dict(_response.headers),
|
|
215
|
+
body=typing.cast(
|
|
216
|
+
Error,
|
|
217
|
+
parse_obj_as(
|
|
218
|
+
type_=Error, # type: ignore
|
|
219
|
+
object_=_response.json(),
|
|
220
|
+
),
|
|
221
|
+
),
|
|
222
|
+
)
|
|
223
|
+
_response_json = _response.json()
|
|
224
|
+
except JSONDecodeError:
|
|
225
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
226
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
paid/tracing/context_manager.py
CHANGED
|
@@ -23,8 +23,11 @@ class paid_tracing:
|
|
|
23
23
|
----------
|
|
24
24
|
external_customer_id : str
|
|
25
25
|
The external customer ID to associate with the trace.
|
|
26
|
+
external_product_id : Optional[str], optional
|
|
27
|
+
The external product ID to associate with the trace, by default None.
|
|
26
28
|
external_agent_id : Optional[str], optional
|
|
27
|
-
The external agent ID to associate
|
|
29
|
+
**Deprecated.** Use external_product_id instead. The external agent ID to associate
|
|
30
|
+
with the trace, by default None.
|
|
28
31
|
tracing_token : Optional[int], optional
|
|
29
32
|
Optional tracing token for distributed tracing, by default None.
|
|
30
33
|
store_prompt : bool, optional
|
|
@@ -37,7 +40,7 @@ class paid_tracing:
|
|
|
37
40
|
Examples
|
|
38
41
|
--------
|
|
39
42
|
As a decorator (sync):
|
|
40
|
-
>>> @paid_tracing(external_customer_id="customer123",
|
|
43
|
+
>>> @paid_tracing(external_customer_id="customer123", external_product_id="product456")
|
|
41
44
|
... def my_function(arg1, arg2):
|
|
42
45
|
... return arg1 + arg2
|
|
43
46
|
|
|
@@ -47,7 +50,7 @@ class paid_tracing:
|
|
|
47
50
|
... return arg1 + arg2
|
|
48
51
|
|
|
49
52
|
As a context manager (sync):
|
|
50
|
-
>>> with paid_tracing(external_customer_id="customer123",
|
|
53
|
+
>>> with paid_tracing(external_customer_id="customer123", external_product_id="product456"):
|
|
51
54
|
... result = expensive_computation()
|
|
52
55
|
|
|
53
56
|
As a context manager (async):
|
|
@@ -64,6 +67,7 @@ class paid_tracing:
|
|
|
64
67
|
self,
|
|
65
68
|
external_customer_id: Optional[str] = None,
|
|
66
69
|
*,
|
|
70
|
+
external_product_id: Optional[str] = None,
|
|
67
71
|
external_agent_id: Optional[str] = None,
|
|
68
72
|
tracing_token: Optional[int] = None,
|
|
69
73
|
store_prompt: bool = False,
|
|
@@ -71,7 +75,8 @@ class paid_tracing:
|
|
|
71
75
|
metadata: Optional[Dict[str, Any]] = None,
|
|
72
76
|
):
|
|
73
77
|
self.external_customer_id = external_customer_id
|
|
74
|
-
|
|
78
|
+
# external_product_id overrides external_agent_id for backwards compatibility
|
|
79
|
+
self.external_agent_id = external_product_id if external_product_id else external_agent_id
|
|
75
80
|
self.tracing_token = tracing_token
|
|
76
81
|
self.store_prompt = store_prompt
|
|
77
82
|
self.collector_endpoint = collector_endpoint
|
paid/types/__init__.py
CHANGED
|
@@ -24,17 +24,32 @@ from .error import Error
|
|
|
24
24
|
from .order import Order
|
|
25
25
|
from .order_line import OrderLine
|
|
26
26
|
from .order_line_attribute import OrderLineAttribute
|
|
27
|
-
from .
|
|
27
|
+
from .order_line_attribute_create_one import OrderLineAttributeCreateOne
|
|
28
28
|
from .order_line_attribute_pricing import OrderLineAttributePricing
|
|
29
29
|
from .order_line_create import OrderLineCreate
|
|
30
30
|
from .pagination_meta import PaginationMeta
|
|
31
|
+
from .plan import Plan
|
|
32
|
+
from .plan_plan_products_item import PlanPlanProductsItem
|
|
33
|
+
from .plan_plan_products_item_plan_product_attribute_item import PlanPlanProductsItemPlanProductAttributeItem
|
|
31
34
|
from .price_point import PricePoint
|
|
32
35
|
from .pricing import Pricing
|
|
33
36
|
from .pricing_model_type import PricingModelType
|
|
37
|
+
from .product import Product
|
|
38
|
+
from .product_type import ProductType
|
|
39
|
+
from .product_update import ProductUpdate
|
|
40
|
+
from .product_update_type import ProductUpdateType
|
|
34
41
|
from .salutation import Salutation
|
|
35
42
|
from .signal import Signal
|
|
43
|
+
from .signal_v_2 import SignalV2
|
|
36
44
|
from .tax_exempt_status import TaxExemptStatus
|
|
37
45
|
from .tier import Tier
|
|
46
|
+
from .trace import Trace
|
|
47
|
+
from .traces_response import TracesResponse
|
|
48
|
+
from .usage_pagination_meta import UsagePaginationMeta
|
|
49
|
+
from .usage_summaries_response import UsageSummariesResponse
|
|
50
|
+
from .usage_summary import UsageSummary
|
|
51
|
+
from .usage_summary_order import UsageSummaryOrder
|
|
52
|
+
from .usage_summary_order_line import UsageSummaryOrderLine
|
|
38
53
|
|
|
39
54
|
__all__ = [
|
|
40
55
|
"Address",
|
|
@@ -59,15 +74,30 @@ __all__ = [
|
|
|
59
74
|
"Order",
|
|
60
75
|
"OrderLine",
|
|
61
76
|
"OrderLineAttribute",
|
|
62
|
-
"
|
|
77
|
+
"OrderLineAttributeCreateOne",
|
|
63
78
|
"OrderLineAttributePricing",
|
|
64
79
|
"OrderLineCreate",
|
|
65
80
|
"PaginationMeta",
|
|
81
|
+
"Plan",
|
|
82
|
+
"PlanPlanProductsItem",
|
|
83
|
+
"PlanPlanProductsItemPlanProductAttributeItem",
|
|
66
84
|
"PricePoint",
|
|
67
85
|
"Pricing",
|
|
68
86
|
"PricingModelType",
|
|
87
|
+
"Product",
|
|
88
|
+
"ProductType",
|
|
89
|
+
"ProductUpdate",
|
|
90
|
+
"ProductUpdateType",
|
|
69
91
|
"Salutation",
|
|
70
92
|
"Signal",
|
|
93
|
+
"SignalV2",
|
|
71
94
|
"TaxExemptStatus",
|
|
72
95
|
"Tier",
|
|
96
|
+
"Trace",
|
|
97
|
+
"TracesResponse",
|
|
98
|
+
"UsagePaginationMeta",
|
|
99
|
+
"UsageSummariesResponse",
|
|
100
|
+
"UsageSummary",
|
|
101
|
+
"UsageSummaryOrder",
|
|
102
|
+
"UsageSummaryOrderLine",
|
|
73
103
|
]
|
paid/types/cost_trace.py
CHANGED
|
@@ -24,6 +24,11 @@ class CostTrace(UniversalBaseModel):
|
|
|
24
24
|
The vendor/provider (e.g., "openai", "anthropic", "mistral")
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
|
+
model: typing.Optional[str] = pydantic.Field(default=None)
|
|
28
|
+
"""
|
|
29
|
+
The model used for the operation (e.g., "gpt-4o-mini", "claude-3-sonnet")
|
|
30
|
+
"""
|
|
31
|
+
|
|
27
32
|
cost: CostAmount
|
|
28
33
|
start_time_unix_nano: typing_extensions.Annotated[str, FieldMetadata(alias="startTimeUnixNano")] = pydantic.Field()
|
|
29
34
|
"""
|
|
@@ -37,7 +42,7 @@ class CostTrace(UniversalBaseModel):
|
|
|
37
42
|
|
|
38
43
|
attributes: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field()
|
|
39
44
|
"""
|
|
40
|
-
Additional metadata about the trace (e.g.,
|
|
45
|
+
Additional metadata about the trace (e.g., tokens, etc.)
|
|
41
46
|
"""
|
|
42
47
|
|
|
43
48
|
if IS_PYDANTIC_V2:
|
paid/types/customer.py
CHANGED
|
@@ -16,7 +16,6 @@ class Customer(UniversalBaseModel):
|
|
|
16
16
|
id: str
|
|
17
17
|
organization_id: typing_extensions.Annotated[str, FieldMetadata(alias="organizationId")]
|
|
18
18
|
name: str
|
|
19
|
-
email: typing.Optional[str] = None
|
|
20
19
|
external_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="externalId")] = None
|
|
21
20
|
phone: typing.Optional[str] = None
|
|
22
21
|
employee_count: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="employeeCount")] = None
|
|
@@ -32,8 +31,10 @@ class Customer(UniversalBaseModel):
|
|
|
32
31
|
] = None
|
|
33
32
|
website: typing.Optional[str] = None
|
|
34
33
|
billing_address: typing_extensions.Annotated[typing.Optional[Address], FieldMetadata(alias="billingAddress")] = None
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
|
|
35
|
+
"""
|
|
36
|
+
Flexible JSON field for storing custom metadata about the customer
|
|
37
|
+
"""
|
|
37
38
|
|
|
38
39
|
if IS_PYDANTIC_V2:
|
|
39
40
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
paid/types/customer_update.py
CHANGED
|
@@ -13,7 +13,6 @@ from .tax_exempt_status import TaxExemptStatus
|
|
|
13
13
|
|
|
14
14
|
class CustomerUpdate(UniversalBaseModel):
|
|
15
15
|
name: typing.Optional[str] = None
|
|
16
|
-
email: typing.Optional[str] = None
|
|
17
16
|
external_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="externalId")] = None
|
|
18
17
|
phone: typing.Optional[str] = None
|
|
19
18
|
employee_count: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="employeeCount")] = None
|
|
@@ -26,7 +25,10 @@ class CustomerUpdate(UniversalBaseModel):
|
|
|
26
25
|
] = None
|
|
27
26
|
website: typing.Optional[str] = None
|
|
28
27
|
billing_address: typing_extensions.Annotated[typing.Optional[Address], FieldMetadata(alias="billingAddress")] = None
|
|
29
|
-
|
|
28
|
+
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
|
|
29
|
+
"""
|
|
30
|
+
Flexible JSON field for storing custom metadata about the customer
|
|
31
|
+
"""
|
|
30
32
|
|
|
31
33
|
if IS_PYDANTIC_V2:
|
|
32
34
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|