2
2
3
3
from __future__ import annotations
4
4
5
- from typing import Any , cast
5
+ from typing import Any , Dict , Optional , cast
6
6
7
7
import httpx
8
8
9
9
from ... import _legacy_response
10
10
from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
11
+ from ..._utils import (
12
+ maybe_transform ,
13
+ async_maybe_transform ,
14
+ )
11
15
from ..._compat import cached_property
12
16
from ..._resource import SyncAPIResource , AsyncAPIResource
13
17
from ..._response import to_streamed_response_wrapper , async_to_streamed_response_wrapper
14
18
from ...types .price import Price
15
19
from ..._base_client import make_request_options
20
+ from ...types .prices import external_price_id_update_params
16
21
17
22
__all__ = ["ExternalPriceID" , "AsyncExternalPriceID" ]
18
23
@@ -26,6 +31,60 @@ def with_raw_response(self) -> ExternalPriceIDWithRawResponse:
26
31
def with_streaming_response (self ) -> ExternalPriceIDWithStreamingResponse :
27
32
return ExternalPriceIDWithStreamingResponse (self )
28
33
34
+ def update (
35
+ self ,
36
+ external_price_id : str ,
37
+ * ,
38
+ metadata : Optional [Dict [str , Optional [str ]]] | NotGiven = NOT_GIVEN ,
39
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
40
+ # The extra values given here take precedence over values defined on the client or passed to this method.
41
+ extra_headers : Headers | None = None ,
42
+ extra_query : Query | None = None ,
43
+ extra_body : Body | None = None ,
44
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
45
+ idempotency_key : str | None = None ,
46
+ ) -> Price :
47
+ """This endpoint allows you to update the `metadata` property on a price.
48
+
49
+ If you
50
+ pass null for the metadata value, it will clear any existing metadata for that
51
+ price.
52
+
53
+ Args:
54
+ metadata: User-specified key/value pairs for the resource. Individual keys can be removed
55
+ by setting the value to `null`, and the entire metadata mapping can be cleared
56
+ by setting `metadata` to `null`.
57
+
58
+ extra_headers: Send extra headers
59
+
60
+ extra_query: Add additional query parameters to the request
61
+
62
+ extra_body: Add additional JSON properties to the request
63
+
64
+ timeout: Override the client-level default timeout for this request, in seconds
65
+
66
+ idempotency_key: Specify a custom idempotency key for this request
67
+ """
68
+ if not external_price_id :
69
+ raise ValueError (f"Expected a non-empty value for `external_price_id` but received { external_price_id !r} " )
70
+ return cast (
71
+ Price ,
72
+ self ._put (
73
+ f"/prices/external_price_id/{ external_price_id } " ,
74
+ body = maybe_transform (
75
+ {"metadata" : metadata }, external_price_id_update_params .ExternalPriceIDUpdateParams
76
+ ),
77
+ options = make_request_options (
78
+ extra_headers = extra_headers ,
79
+ extra_query = extra_query ,
80
+ extra_body = extra_body ,
81
+ timeout = timeout ,
82
+ idempotency_key = idempotency_key ,
83
+ ),
84
+ cast_to = cast (Any , Price ), # Union types cannot be passed in as arguments in the type system
85
+ ),
86
+ )
87
+
29
88
def fetch (
30
89
self ,
31
90
external_price_id : str ,
@@ -75,6 +134,60 @@ def with_raw_response(self) -> AsyncExternalPriceIDWithRawResponse:
75
134
def with_streaming_response (self ) -> AsyncExternalPriceIDWithStreamingResponse :
76
135
return AsyncExternalPriceIDWithStreamingResponse (self )
77
136
137
+ async def update (
138
+ self ,
139
+ external_price_id : str ,
140
+ * ,
141
+ metadata : Optional [Dict [str , Optional [str ]]] | NotGiven = NOT_GIVEN ,
142
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
143
+ # The extra values given here take precedence over values defined on the client or passed to this method.
144
+ extra_headers : Headers | None = None ,
145
+ extra_query : Query | None = None ,
146
+ extra_body : Body | None = None ,
147
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
148
+ idempotency_key : str | None = None ,
149
+ ) -> Price :
150
+ """This endpoint allows you to update the `metadata` property on a price.
151
+
152
+ If you
153
+ pass null for the metadata value, it will clear any existing metadata for that
154
+ price.
155
+
156
+ Args:
157
+ metadata: User-specified key/value pairs for the resource. Individual keys can be removed
158
+ by setting the value to `null`, and the entire metadata mapping can be cleared
159
+ by setting `metadata` to `null`.
160
+
161
+ extra_headers: Send extra headers
162
+
163
+ extra_query: Add additional query parameters to the request
164
+
165
+ extra_body: Add additional JSON properties to the request
166
+
167
+ timeout: Override the client-level default timeout for this request, in seconds
168
+
169
+ idempotency_key: Specify a custom idempotency key for this request
170
+ """
171
+ if not external_price_id :
172
+ raise ValueError (f"Expected a non-empty value for `external_price_id` but received { external_price_id !r} " )
173
+ return cast (
174
+ Price ,
175
+ await self ._put (
176
+ f"/prices/external_price_id/{ external_price_id } " ,
177
+ body = await async_maybe_transform (
178
+ {"metadata" : metadata }, external_price_id_update_params .ExternalPriceIDUpdateParams
179
+ ),
180
+ options = make_request_options (
181
+ extra_headers = extra_headers ,
182
+ extra_query = extra_query ,
183
+ extra_body = extra_body ,
184
+ timeout = timeout ,
185
+ idempotency_key = idempotency_key ,
186
+ ),
187
+ cast_to = cast (Any , Price ), # Union types cannot be passed in as arguments in the type system
188
+ ),
189
+ )
190
+
78
191
async def fetch (
79
192
self ,
80
193
external_price_id : str ,
@@ -119,6 +232,9 @@ class ExternalPriceIDWithRawResponse:
119
232
def __init__ (self , external_price_id : ExternalPriceID ) -> None :
120
233
self ._external_price_id = external_price_id
121
234
235
+ self .update = _legacy_response .to_raw_response_wrapper (
236
+ external_price_id .update ,
237
+ )
122
238
self .fetch = _legacy_response .to_raw_response_wrapper (
123
239
external_price_id .fetch ,
124
240
)
@@ -128,6 +244,9 @@ class AsyncExternalPriceIDWithRawResponse:
128
244
def __init__ (self , external_price_id : AsyncExternalPriceID ) -> None :
129
245
self ._external_price_id = external_price_id
130
246
247
+ self .update = _legacy_response .async_to_raw_response_wrapper (
248
+ external_price_id .update ,
249
+ )
131
250
self .fetch = _legacy_response .async_to_raw_response_wrapper (
132
251
external_price_id .fetch ,
133
252
)
@@ -137,6 +256,9 @@ class ExternalPriceIDWithStreamingResponse:
137
256
def __init__ (self , external_price_id : ExternalPriceID ) -> None :
138
257
self ._external_price_id = external_price_id
139
258
259
+ self .update = to_streamed_response_wrapper (
260
+ external_price_id .update ,
261
+ )
140
262
self .fetch = to_streamed_response_wrapper (
141
263
external_price_id .fetch ,
142
264
)
@@ -146,6 +268,9 @@ class AsyncExternalPriceIDWithStreamingResponse:
146
268
def __init__ (self , external_price_id : AsyncExternalPriceID ) -> None :
147
269
self ._external_price_id = external_price_id
148
270
271
+ self .update = async_to_streamed_response_wrapper (
272
+ external_price_id .update ,
273
+ )
149
274
self .fetch = async_to_streamed_response_wrapper (
150
275
external_price_id .fetch ,
151
276
)
0 commit comments