payi 0.1.0a12__py3-none-any.whl → 0.1.0a14__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 payi might be problematic. Click here for more details.
- payi/_base_client.py +22 -12
- payi/_client.py +8 -0
- payi/_compat.py +3 -3
- payi/_models.py +17 -0
- payi/_version.py +1 -1
- payi/resources/__init__.py +14 -0
- payi/resources/budgets/budgets.py +13 -7
- payi/resources/budgets/tags.py +1 -3
- payi/resources/categories/__init__.py +33 -0
- payi/resources/categories/categories.py +388 -0
- payi/resources/categories/resources.py +450 -0
- payi/resources/ingest.py +53 -18
- payi/types/__init__.py +6 -0
- payi/types/budget_create_params.py +4 -0
- payi/types/budget_history_response.py +15 -64
- payi/types/budget_response.py +19 -3
- payi/types/budget_update_params.py +4 -3
- payi/types/categories/__init__.py +6 -0
- payi/types/categories/resource_create_params.py +25 -0
- payi/types/categories/resource_list_response.py +9 -0
- payi/types/category_delete_resource_response.py +9 -0
- payi/types/category_delete_response.py +9 -0
- payi/types/category_list_resources_response.py +9 -0
- payi/types/category_list_response.py +9 -0
- payi/types/category_resource_response.py +24 -0
- payi/types/category_response.py +15 -0
- payi/types/ingest_units_params.py +6 -2
- payi/types/paged_budget_list.py +19 -3
- payi/types/requests_data.py +3 -7
- {payi-0.1.0a12.dist-info → payi-0.1.0a14.dist-info}/METADATA +8 -2
- {payi-0.1.0a12.dist-info → payi-0.1.0a14.dist-info}/RECORD +33 -21
- {payi-0.1.0a12.dist-info → payi-0.1.0a14.dist-info}/WHEEL +0 -0
- {payi-0.1.0a12.dist-info → payi-0.1.0a14.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Union
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
|
|
10
|
+
from ..._types import NOT_GIVEN, Body, Query, Headers, 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.categories import resource_create_params
|
|
25
|
+
from ...types.category_resource_response import CategoryResourceResponse
|
|
26
|
+
from ...types.categories.resource_list_response import ResourceListResponse
|
|
27
|
+
|
|
28
|
+
__all__ = ["ResourcesResource", "AsyncResourcesResource"]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ResourcesResource(SyncAPIResource):
|
|
32
|
+
@cached_property
|
|
33
|
+
def with_raw_response(self) -> ResourcesResourceWithRawResponse:
|
|
34
|
+
return ResourcesResourceWithRawResponse(self)
|
|
35
|
+
|
|
36
|
+
@cached_property
|
|
37
|
+
def with_streaming_response(self) -> ResourcesResourceWithStreamingResponse:
|
|
38
|
+
return ResourcesResourceWithStreamingResponse(self)
|
|
39
|
+
|
|
40
|
+
def create(
|
|
41
|
+
self,
|
|
42
|
+
resource: str,
|
|
43
|
+
*,
|
|
44
|
+
category: str,
|
|
45
|
+
start_timestamp: Union[str, datetime],
|
|
46
|
+
input_price: float | NotGiven = NOT_GIVEN,
|
|
47
|
+
max_input_units: int | NotGiven = NOT_GIVEN,
|
|
48
|
+
max_output_units: int | NotGiven = NOT_GIVEN,
|
|
49
|
+
output_price: float | NotGiven = NOT_GIVEN,
|
|
50
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
51
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
52
|
+
extra_headers: Headers | None = None,
|
|
53
|
+
extra_query: Query | None = None,
|
|
54
|
+
extra_body: Body | None = None,
|
|
55
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
56
|
+
) -> CategoryResourceResponse:
|
|
57
|
+
"""
|
|
58
|
+
Create a Resource
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
extra_headers: Send extra headers
|
|
62
|
+
|
|
63
|
+
extra_query: Add additional query parameters to the request
|
|
64
|
+
|
|
65
|
+
extra_body: Add additional JSON properties to the request
|
|
66
|
+
|
|
67
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
68
|
+
"""
|
|
69
|
+
if not category:
|
|
70
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
71
|
+
if not resource:
|
|
72
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
73
|
+
return self._post(
|
|
74
|
+
f"/api/v1/categories/{category}/resources/{resource}",
|
|
75
|
+
body=maybe_transform(
|
|
76
|
+
{
|
|
77
|
+
"start_timestamp": start_timestamp,
|
|
78
|
+
"input_price": input_price,
|
|
79
|
+
"max_input_units": max_input_units,
|
|
80
|
+
"max_output_units": max_output_units,
|
|
81
|
+
"output_price": output_price,
|
|
82
|
+
},
|
|
83
|
+
resource_create_params.ResourceCreateParams,
|
|
84
|
+
),
|
|
85
|
+
options=make_request_options(
|
|
86
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
87
|
+
),
|
|
88
|
+
cast_to=CategoryResourceResponse,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def retrieve(
|
|
92
|
+
self,
|
|
93
|
+
start_timestamp: Union[str, datetime],
|
|
94
|
+
*,
|
|
95
|
+
category: str,
|
|
96
|
+
resource: str,
|
|
97
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
98
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
99
|
+
extra_headers: Headers | None = None,
|
|
100
|
+
extra_query: Query | None = None,
|
|
101
|
+
extra_body: Body | None = None,
|
|
102
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
103
|
+
) -> CategoryResourceResponse:
|
|
104
|
+
"""
|
|
105
|
+
Get a Resource's version details
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
extra_headers: Send extra headers
|
|
109
|
+
|
|
110
|
+
extra_query: Add additional query parameters to the request
|
|
111
|
+
|
|
112
|
+
extra_body: Add additional JSON properties to the request
|
|
113
|
+
|
|
114
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
115
|
+
"""
|
|
116
|
+
if not category:
|
|
117
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
118
|
+
if not resource:
|
|
119
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
120
|
+
if not start_timestamp:
|
|
121
|
+
raise ValueError(f"Expected a non-empty value for `start_timestamp` but received {start_timestamp!r}")
|
|
122
|
+
return self._get(
|
|
123
|
+
f"/api/v1/categories/{category}/resources/{resource}/{start_timestamp}",
|
|
124
|
+
options=make_request_options(
|
|
125
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
126
|
+
),
|
|
127
|
+
cast_to=CategoryResourceResponse,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
def list(
|
|
131
|
+
self,
|
|
132
|
+
resource: str,
|
|
133
|
+
*,
|
|
134
|
+
category: str,
|
|
135
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
136
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
137
|
+
extra_headers: Headers | None = None,
|
|
138
|
+
extra_query: Query | None = None,
|
|
139
|
+
extra_body: Body | None = None,
|
|
140
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
141
|
+
) -> ResourceListResponse:
|
|
142
|
+
"""
|
|
143
|
+
Get a list of versions of a Resource
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
extra_headers: Send extra headers
|
|
147
|
+
|
|
148
|
+
extra_query: Add additional query parameters to the request
|
|
149
|
+
|
|
150
|
+
extra_body: Add additional JSON properties to the request
|
|
151
|
+
|
|
152
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
153
|
+
"""
|
|
154
|
+
if not category:
|
|
155
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
156
|
+
if not resource:
|
|
157
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
158
|
+
return self._get(
|
|
159
|
+
f"/api/v1/categories/{category}/resources/{resource}",
|
|
160
|
+
options=make_request_options(
|
|
161
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
162
|
+
),
|
|
163
|
+
cast_to=ResourceListResponse,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
def delete(
|
|
167
|
+
self,
|
|
168
|
+
start_timestamp: Union[str, datetime],
|
|
169
|
+
*,
|
|
170
|
+
category: str,
|
|
171
|
+
resource: str,
|
|
172
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
173
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
174
|
+
extra_headers: Headers | None = None,
|
|
175
|
+
extra_query: Query | None = None,
|
|
176
|
+
extra_body: Body | None = None,
|
|
177
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
178
|
+
) -> CategoryResourceResponse:
|
|
179
|
+
"""
|
|
180
|
+
Delete a version of the Resource
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
extra_headers: Send extra headers
|
|
184
|
+
|
|
185
|
+
extra_query: Add additional query parameters to the request
|
|
186
|
+
|
|
187
|
+
extra_body: Add additional JSON properties to the request
|
|
188
|
+
|
|
189
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
190
|
+
"""
|
|
191
|
+
if not category:
|
|
192
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
193
|
+
if not resource:
|
|
194
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
195
|
+
if not start_timestamp:
|
|
196
|
+
raise ValueError(f"Expected a non-empty value for `start_timestamp` but received {start_timestamp!r}")
|
|
197
|
+
return self._delete(
|
|
198
|
+
f"/api/v1/categories/{category}/resources/{resource}/{start_timestamp}",
|
|
199
|
+
options=make_request_options(
|
|
200
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
201
|
+
),
|
|
202
|
+
cast_to=CategoryResourceResponse,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class AsyncResourcesResource(AsyncAPIResource):
|
|
207
|
+
@cached_property
|
|
208
|
+
def with_raw_response(self) -> AsyncResourcesResourceWithRawResponse:
|
|
209
|
+
return AsyncResourcesResourceWithRawResponse(self)
|
|
210
|
+
|
|
211
|
+
@cached_property
|
|
212
|
+
def with_streaming_response(self) -> AsyncResourcesResourceWithStreamingResponse:
|
|
213
|
+
return AsyncResourcesResourceWithStreamingResponse(self)
|
|
214
|
+
|
|
215
|
+
async def create(
|
|
216
|
+
self,
|
|
217
|
+
resource: str,
|
|
218
|
+
*,
|
|
219
|
+
category: str,
|
|
220
|
+
start_timestamp: Union[str, datetime],
|
|
221
|
+
input_price: float | NotGiven = NOT_GIVEN,
|
|
222
|
+
max_input_units: int | NotGiven = NOT_GIVEN,
|
|
223
|
+
max_output_units: int | NotGiven = NOT_GIVEN,
|
|
224
|
+
output_price: float | NotGiven = NOT_GIVEN,
|
|
225
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
226
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
227
|
+
extra_headers: Headers | None = None,
|
|
228
|
+
extra_query: Query | None = None,
|
|
229
|
+
extra_body: Body | None = None,
|
|
230
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
231
|
+
) -> CategoryResourceResponse:
|
|
232
|
+
"""
|
|
233
|
+
Create a Resource
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
extra_headers: Send extra headers
|
|
237
|
+
|
|
238
|
+
extra_query: Add additional query parameters to the request
|
|
239
|
+
|
|
240
|
+
extra_body: Add additional JSON properties to the request
|
|
241
|
+
|
|
242
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
243
|
+
"""
|
|
244
|
+
if not category:
|
|
245
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
246
|
+
if not resource:
|
|
247
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
248
|
+
return await self._post(
|
|
249
|
+
f"/api/v1/categories/{category}/resources/{resource}",
|
|
250
|
+
body=await async_maybe_transform(
|
|
251
|
+
{
|
|
252
|
+
"start_timestamp": start_timestamp,
|
|
253
|
+
"input_price": input_price,
|
|
254
|
+
"max_input_units": max_input_units,
|
|
255
|
+
"max_output_units": max_output_units,
|
|
256
|
+
"output_price": output_price,
|
|
257
|
+
},
|
|
258
|
+
resource_create_params.ResourceCreateParams,
|
|
259
|
+
),
|
|
260
|
+
options=make_request_options(
|
|
261
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
262
|
+
),
|
|
263
|
+
cast_to=CategoryResourceResponse,
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
async def retrieve(
|
|
267
|
+
self,
|
|
268
|
+
start_timestamp: Union[str, datetime],
|
|
269
|
+
*,
|
|
270
|
+
category: str,
|
|
271
|
+
resource: str,
|
|
272
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
273
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
274
|
+
extra_headers: Headers | None = None,
|
|
275
|
+
extra_query: Query | None = None,
|
|
276
|
+
extra_body: Body | None = None,
|
|
277
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
278
|
+
) -> CategoryResourceResponse:
|
|
279
|
+
"""
|
|
280
|
+
Get a Resource's version details
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
extra_headers: Send extra headers
|
|
284
|
+
|
|
285
|
+
extra_query: Add additional query parameters to the request
|
|
286
|
+
|
|
287
|
+
extra_body: Add additional JSON properties to the request
|
|
288
|
+
|
|
289
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
290
|
+
"""
|
|
291
|
+
if not category:
|
|
292
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
293
|
+
if not resource:
|
|
294
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
295
|
+
if not start_timestamp:
|
|
296
|
+
raise ValueError(f"Expected a non-empty value for `start_timestamp` but received {start_timestamp!r}")
|
|
297
|
+
return await self._get(
|
|
298
|
+
f"/api/v1/categories/{category}/resources/{resource}/{start_timestamp}",
|
|
299
|
+
options=make_request_options(
|
|
300
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
301
|
+
),
|
|
302
|
+
cast_to=CategoryResourceResponse,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
async def list(
|
|
306
|
+
self,
|
|
307
|
+
resource: str,
|
|
308
|
+
*,
|
|
309
|
+
category: str,
|
|
310
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
311
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
312
|
+
extra_headers: Headers | None = None,
|
|
313
|
+
extra_query: Query | None = None,
|
|
314
|
+
extra_body: Body | None = None,
|
|
315
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
316
|
+
) -> ResourceListResponse:
|
|
317
|
+
"""
|
|
318
|
+
Get a list of versions of a Resource
|
|
319
|
+
|
|
320
|
+
Args:
|
|
321
|
+
extra_headers: Send extra headers
|
|
322
|
+
|
|
323
|
+
extra_query: Add additional query parameters to the request
|
|
324
|
+
|
|
325
|
+
extra_body: Add additional JSON properties to the request
|
|
326
|
+
|
|
327
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
328
|
+
"""
|
|
329
|
+
if not category:
|
|
330
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
331
|
+
if not resource:
|
|
332
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
333
|
+
return await self._get(
|
|
334
|
+
f"/api/v1/categories/{category}/resources/{resource}",
|
|
335
|
+
options=make_request_options(
|
|
336
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
337
|
+
),
|
|
338
|
+
cast_to=ResourceListResponse,
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
async def delete(
|
|
342
|
+
self,
|
|
343
|
+
start_timestamp: Union[str, datetime],
|
|
344
|
+
*,
|
|
345
|
+
category: str,
|
|
346
|
+
resource: str,
|
|
347
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
348
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
349
|
+
extra_headers: Headers | None = None,
|
|
350
|
+
extra_query: Query | None = None,
|
|
351
|
+
extra_body: Body | None = None,
|
|
352
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
353
|
+
) -> CategoryResourceResponse:
|
|
354
|
+
"""
|
|
355
|
+
Delete a version of the Resource
|
|
356
|
+
|
|
357
|
+
Args:
|
|
358
|
+
extra_headers: Send extra headers
|
|
359
|
+
|
|
360
|
+
extra_query: Add additional query parameters to the request
|
|
361
|
+
|
|
362
|
+
extra_body: Add additional JSON properties to the request
|
|
363
|
+
|
|
364
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
365
|
+
"""
|
|
366
|
+
if not category:
|
|
367
|
+
raise ValueError(f"Expected a non-empty value for `category` but received {category!r}")
|
|
368
|
+
if not resource:
|
|
369
|
+
raise ValueError(f"Expected a non-empty value for `resource` but received {resource!r}")
|
|
370
|
+
if not start_timestamp:
|
|
371
|
+
raise ValueError(f"Expected a non-empty value for `start_timestamp` but received {start_timestamp!r}")
|
|
372
|
+
return await self._delete(
|
|
373
|
+
f"/api/v1/categories/{category}/resources/{resource}/{start_timestamp}",
|
|
374
|
+
options=make_request_options(
|
|
375
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
376
|
+
),
|
|
377
|
+
cast_to=CategoryResourceResponse,
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
class ResourcesResourceWithRawResponse:
|
|
382
|
+
def __init__(self, resources: ResourcesResource) -> None:
|
|
383
|
+
self._resources = resources
|
|
384
|
+
|
|
385
|
+
self.create = to_raw_response_wrapper(
|
|
386
|
+
resources.create,
|
|
387
|
+
)
|
|
388
|
+
self.retrieve = to_raw_response_wrapper(
|
|
389
|
+
resources.retrieve,
|
|
390
|
+
)
|
|
391
|
+
self.list = to_raw_response_wrapper(
|
|
392
|
+
resources.list,
|
|
393
|
+
)
|
|
394
|
+
self.delete = to_raw_response_wrapper(
|
|
395
|
+
resources.delete,
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
class AsyncResourcesResourceWithRawResponse:
|
|
400
|
+
def __init__(self, resources: AsyncResourcesResource) -> None:
|
|
401
|
+
self._resources = resources
|
|
402
|
+
|
|
403
|
+
self.create = async_to_raw_response_wrapper(
|
|
404
|
+
resources.create,
|
|
405
|
+
)
|
|
406
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
407
|
+
resources.retrieve,
|
|
408
|
+
)
|
|
409
|
+
self.list = async_to_raw_response_wrapper(
|
|
410
|
+
resources.list,
|
|
411
|
+
)
|
|
412
|
+
self.delete = async_to_raw_response_wrapper(
|
|
413
|
+
resources.delete,
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
class ResourcesResourceWithStreamingResponse:
|
|
418
|
+
def __init__(self, resources: ResourcesResource) -> None:
|
|
419
|
+
self._resources = resources
|
|
420
|
+
|
|
421
|
+
self.create = to_streamed_response_wrapper(
|
|
422
|
+
resources.create,
|
|
423
|
+
)
|
|
424
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
425
|
+
resources.retrieve,
|
|
426
|
+
)
|
|
427
|
+
self.list = to_streamed_response_wrapper(
|
|
428
|
+
resources.list,
|
|
429
|
+
)
|
|
430
|
+
self.delete = to_streamed_response_wrapper(
|
|
431
|
+
resources.delete,
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
class AsyncResourcesResourceWithStreamingResponse:
|
|
436
|
+
def __init__(self, resources: AsyncResourcesResource) -> None:
|
|
437
|
+
self._resources = resources
|
|
438
|
+
|
|
439
|
+
self.create = async_to_streamed_response_wrapper(
|
|
440
|
+
resources.create,
|
|
441
|
+
)
|
|
442
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
443
|
+
resources.retrieve,
|
|
444
|
+
)
|
|
445
|
+
self.list = async_to_streamed_response_wrapper(
|
|
446
|
+
resources.list,
|
|
447
|
+
)
|
|
448
|
+
self.delete = async_to_streamed_response_wrapper(
|
|
449
|
+
resources.delete,
|
|
450
|
+
)
|
payi/resources/ingest.py
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from typing import Union
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
5
8
|
import httpx
|
|
6
9
|
|
|
7
10
|
from ..types import ingest_units_params
|
|
@@ -19,9 +22,7 @@ from .._response import (
|
|
|
19
22
|
async_to_raw_response_wrapper,
|
|
20
23
|
async_to_streamed_response_wrapper,
|
|
21
24
|
)
|
|
22
|
-
from .._base_client import
|
|
23
|
-
make_request_options,
|
|
24
|
-
)
|
|
25
|
+
from .._base_client import make_request_options
|
|
25
26
|
from ..types.proxy_result import ProxyResult
|
|
26
27
|
|
|
27
28
|
__all__ = ["IngestResource", "AsyncIngestResource"]
|
|
@@ -43,8 +44,9 @@ class IngestResource(SyncAPIResource):
|
|
|
43
44
|
input: int,
|
|
44
45
|
output: int,
|
|
45
46
|
resource: str,
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
event_timestamp: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
|
|
48
|
+
budget_ids: Union[list[str], None] | NotGiven = NOT_GIVEN,
|
|
49
|
+
request_tags: Union[list[str], None] | NotGiven = NOT_GIVEN,
|
|
48
50
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
49
51
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
50
52
|
extra_headers: Headers | None = None,
|
|
@@ -57,20 +59,31 @@ class IngestResource(SyncAPIResource):
|
|
|
57
59
|
|
|
58
60
|
Args:
|
|
59
61
|
category (str): The name of the category
|
|
60
|
-
|
|
62
|
+
|
|
63
|
+
resource (str): The name of the resource
|
|
64
|
+
|
|
61
65
|
input (int): The number of input units
|
|
66
|
+
|
|
62
67
|
output (int): The number of output units
|
|
68
|
+
|
|
69
|
+
event_timestamp: (datetime, None): The timestamp of the event. Defaults to None.
|
|
70
|
+
|
|
63
71
|
budget_ids (list[str], optional): The budget IDs to associate with the request. Defaults to None.
|
|
72
|
+
|
|
64
73
|
request_tags (list[str], optional): The request tags to associate with the request. Defaults to None.
|
|
74
|
+
|
|
65
75
|
extra_headers (Dict[str, str], optional): Additional headers for the request. Defaults to None.
|
|
76
|
+
|
|
66
77
|
extra_query (Dict[str, str], optional): Additional query parameters. Defaults to None.
|
|
78
|
+
|
|
67
79
|
extra_body (Dict[str, Any], optional): Additional body parameters. Defaults to None.
|
|
80
|
+
|
|
68
81
|
timeout (Union[float, None], optional): The timeout for the request in seconds. Defaults to None.
|
|
69
82
|
"""
|
|
70
83
|
valid_ids_str: str | NotGiven = NOT_GIVEN
|
|
71
84
|
valid_tags_str: str | NotGiven = NOT_GIVEN
|
|
72
85
|
|
|
73
|
-
if isinstance(budget_ids, NotGiven):
|
|
86
|
+
if budget_ids is None or isinstance(budget_ids, NotGiven):
|
|
74
87
|
valid_ids_str = NOT_GIVEN
|
|
75
88
|
elif not isinstance(budget_ids, list): # type: ignore
|
|
76
89
|
raise TypeError("budget_ids must be a list")
|
|
@@ -79,7 +92,7 @@ class IngestResource(SyncAPIResource):
|
|
|
79
92
|
valid_ids = [id.strip() for id in budget_ids if id.strip()]
|
|
80
93
|
valid_ids_str = ",".join(valid_ids) if valid_ids else NOT_GIVEN
|
|
81
94
|
|
|
82
|
-
if isinstance(request_tags, NotGiven):
|
|
95
|
+
if request_tags is None or isinstance(request_tags, NotGiven):
|
|
83
96
|
valid_tags_str = NOT_GIVEN
|
|
84
97
|
elif not isinstance(request_tags, list): # type: ignore
|
|
85
98
|
raise TypeError("request_tags must be a list")
|
|
@@ -105,6 +118,7 @@ class IngestResource(SyncAPIResource):
|
|
|
105
118
|
"input": input,
|
|
106
119
|
"output": output,
|
|
107
120
|
"resource": resource,
|
|
121
|
+
"event_timestamp": event_timestamp,
|
|
108
122
|
},
|
|
109
123
|
ingest_units_params.IngestUnitsParams,
|
|
110
124
|
),
|
|
@@ -131,8 +145,9 @@ class AsyncIngestResource(AsyncAPIResource):
|
|
|
131
145
|
input: int,
|
|
132
146
|
output: int,
|
|
133
147
|
resource: str,
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
event_timestamp: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
|
|
149
|
+
budget_ids: Union[list[str], None] | NotGiven = NOT_GIVEN,
|
|
150
|
+
request_tags: Union[list[str], None] | NotGiven = NOT_GIVEN,
|
|
136
151
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
137
152
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
138
153
|
extra_headers: Headers | None = None,
|
|
@@ -144,25 +159,44 @@ class AsyncIngestResource(AsyncAPIResource):
|
|
|
144
159
|
Ingest a request
|
|
145
160
|
|
|
146
161
|
Args:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
extra_query: Add additional query parameters to the request
|
|
150
|
-
|
|
151
|
-
extra_body: Add additional JSON properties to the request
|
|
162
|
+
category (str): The name of the category
|
|
152
163
|
|
|
153
|
-
|
|
164
|
+
resource (str): The name of the resource
|
|
165
|
+
|
|
166
|
+
input (int): The number of input units
|
|
167
|
+
|
|
168
|
+
output (int): The number of output units
|
|
169
|
+
|
|
170
|
+
event_timestamp: (datetime, None): The timestamp of the event. Defaults to None.
|
|
171
|
+
|
|
172
|
+
budget_ids (list[str], optional): The budget IDs to associate with the request. Defaults to None.
|
|
173
|
+
|
|
174
|
+
request_tags (list[str], optional): The request tags to associate with the request. Defaults to None.
|
|
175
|
+
|
|
176
|
+
extra_headers (Dict[str, str], optional): Additional headers for the request. Defaults to None.
|
|
177
|
+
|
|
178
|
+
extra_query (Dict[str, str], optional): Additional query parameters. Defaults to None.
|
|
179
|
+
|
|
180
|
+
extra_body (Dict[str, Any], optional): Additional body parameters. Defaults to None.
|
|
181
|
+
|
|
182
|
+
timeout (Union[float, None], optional): The timeout for the request in seconds. Defaults to None.
|
|
154
183
|
"""
|
|
155
184
|
valid_ids_str: str | NotGiven = NOT_GIVEN
|
|
156
185
|
valid_tags_str: str | NotGiven = NOT_GIVEN
|
|
157
186
|
|
|
158
|
-
if isinstance(budget_ids, NotGiven):
|
|
187
|
+
if budget_ids is None or isinstance(budget_ids, NotGiven):
|
|
159
188
|
valid_ids_str = NOT_GIVEN
|
|
189
|
+
elif not isinstance(budget_ids, list): # type: ignore
|
|
190
|
+
raise TypeError("budget_ids must be a list")
|
|
160
191
|
else:
|
|
161
192
|
# Proceed with the list comprehension if budget_ids is not NotGiven
|
|
162
193
|
valid_ids = [id.strip() for id in budget_ids if id.strip()]
|
|
163
194
|
valid_ids_str = ",".join(valid_ids) if valid_ids else NOT_GIVEN
|
|
164
|
-
|
|
195
|
+
|
|
196
|
+
if request_tags is None or isinstance(request_tags, NotGiven):
|
|
165
197
|
valid_tags_str = NOT_GIVEN
|
|
198
|
+
elif not isinstance(request_tags, list): # type: ignore
|
|
199
|
+
raise TypeError("request_tags must be a list")
|
|
166
200
|
else:
|
|
167
201
|
# Proceed with the list comprehension if budget_ids is not NotGiven
|
|
168
202
|
valid_tags = [tag.strip() for tag in request_tags if tag.strip()]
|
|
@@ -185,6 +219,7 @@ class AsyncIngestResource(AsyncAPIResource):
|
|
|
185
219
|
"input": input,
|
|
186
220
|
"output": output,
|
|
187
221
|
"resource": resource,
|
|
222
|
+
"event_timestamp": event_timestamp,
|
|
188
223
|
},
|
|
189
224
|
ingest_units_params.IngestUnitsParams,
|
|
190
225
|
),
|
payi/types/__init__.py
CHANGED
|
@@ -8,9 +8,15 @@ from .proxy_result import ProxyResult as ProxyResult
|
|
|
8
8
|
from .requests_data import RequestsData as RequestsData
|
|
9
9
|
from .budget_response import BudgetResponse as BudgetResponse
|
|
10
10
|
from .default_response import DefaultResponse as DefaultResponse
|
|
11
|
+
from .category_response import CategoryResponse as CategoryResponse
|
|
11
12
|
from .paged_budget_list import PagedBudgetList as PagedBudgetList
|
|
12
13
|
from .budget_list_params import BudgetListParams as BudgetListParams
|
|
13
14
|
from .ingest_units_params import IngestUnitsParams as IngestUnitsParams
|
|
14
15
|
from .budget_create_params import BudgetCreateParams as BudgetCreateParams
|
|
15
16
|
from .budget_update_params import BudgetUpdateParams as BudgetUpdateParams
|
|
17
|
+
from .category_list_response import CategoryListResponse as CategoryListResponse
|
|
16
18
|
from .budget_history_response import BudgetHistoryResponse as BudgetHistoryResponse
|
|
19
|
+
from .category_delete_response import CategoryDeleteResponse as CategoryDeleteResponse
|
|
20
|
+
from .category_resource_response import CategoryResourceResponse as CategoryResourceResponse
|
|
21
|
+
from .category_list_resources_response import CategoryListResourcesResponse as CategoryListResourcesResponse
|
|
22
|
+
from .category_delete_resource_response import CategoryDeleteResourceResponse as CategoryDeleteResourceResponse
|
|
@@ -15,10 +15,14 @@ class BudgetCreateParams(TypedDict, total=False):
|
|
|
15
15
|
|
|
16
16
|
base_cost_estimate: Literal["max"]
|
|
17
17
|
|
|
18
|
+
billing_model_id: Optional[int]
|
|
19
|
+
|
|
18
20
|
budget_response_type: Literal["block", "allow"]
|
|
19
21
|
|
|
20
22
|
budget_tags: Optional[List[str]]
|
|
21
23
|
|
|
22
24
|
budget_type: Literal["conservative", "liberal"]
|
|
23
25
|
|
|
26
|
+
cost_basis: Literal["base", "billed"]
|
|
27
|
+
|
|
24
28
|
currency: Literal["usd"]
|