44
55import httpx
66
7+ from ..types import extension_update_params , extension_upload_params
78from .._types import NOT_GIVEN , Body , Query , Headers , NotGiven
9+ from .._utils import maybe_transform , async_maybe_transform
810from .._compat import cached_property
911from .._resource import SyncAPIResource , AsyncAPIResource
1012from .._response import (
@@ -47,6 +49,8 @@ def update(
4749 self ,
4850 extension_id : str ,
4951 * ,
52+ file : object | NotGiven = NOT_GIVEN ,
53+ url : str | NotGiven = NOT_GIVEN ,
5054 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5155 # The extra values given here take precedence over values defined on the client or passed to this method.
5256 extra_headers : Headers | None = None ,
@@ -55,9 +59,14 @@ def update(
5559 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
5660 ) -> ExtensionUpdateResponse :
5761 """
58- Update a Chrome extension (.zip/.crx file) for the organization
62+ Update a Chrome extension (.zip/.crx file or Chrome Web Store URL) for the
63+ organization
5964
6065 Args:
66+ file: Extension .zip/.crx file
67+
68+ url: Extension URL
69+
6170 extra_headers: Send extra headers
6271
6372 extra_query: Add additional query parameters to the request
@@ -68,8 +77,19 @@ def update(
6877 """
6978 if not extension_id :
7079 raise ValueError (f"Expected a non-empty value for `extension_id` but received { extension_id !r} " )
80+ # It should be noted that the actual Content-Type header that will be
81+ # sent to the server will contain a `boundary` parameter, e.g.
82+ # multipart/form-data; boundary=---abc--
83+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
7184 return self ._put (
7285 f"/v1/extensions/{ extension_id } " ,
86+ body = maybe_transform (
87+ {
88+ "file" : file ,
89+ "url" : url ,
90+ },
91+ extension_update_params .ExtensionUpdateParams ,
92+ ),
7393 options = make_request_options (
7494 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
7595 ),
@@ -183,16 +203,45 @@ def download(
183203 def upload (
184204 self ,
185205 * ,
206+ file : object | NotGiven = NOT_GIVEN ,
207+ url : str | NotGiven = NOT_GIVEN ,
186208 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
187209 # The extra values given here take precedence over values defined on the client or passed to this method.
188210 extra_headers : Headers | None = None ,
189211 extra_query : Query | None = None ,
190212 extra_body : Body | None = None ,
191213 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
192214 ) -> ExtensionUploadResponse :
193- """Upload a Chrome extension (.zip/.crx file) for the organization"""
215+ """
216+ Upload a Chrome extension (.zip/.crx file or Chrome Web Store URL) for the
217+ organization
218+
219+ Args:
220+ file: Extension .zip/.crx file
221+
222+ url: Extension URL
223+
224+ extra_headers: Send extra headers
225+
226+ extra_query: Add additional query parameters to the request
227+
228+ extra_body: Add additional JSON properties to the request
229+
230+ timeout: Override the client-level default timeout for this request, in seconds
231+ """
232+ # It should be noted that the actual Content-Type header that will be
233+ # sent to the server will contain a `boundary` parameter, e.g.
234+ # multipart/form-data; boundary=---abc--
235+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
194236 return self ._post (
195237 "/v1/extensions" ,
238+ body = maybe_transform (
239+ {
240+ "file" : file ,
241+ "url" : url ,
242+ },
243+ extension_upload_params .ExtensionUploadParams ,
244+ ),
196245 options = make_request_options (
197246 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
198247 ),
@@ -224,6 +273,8 @@ async def update(
224273 self ,
225274 extension_id : str ,
226275 * ,
276+ file : object | NotGiven = NOT_GIVEN ,
277+ url : str | NotGiven = NOT_GIVEN ,
227278 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
228279 # The extra values given here take precedence over values defined on the client or passed to this method.
229280 extra_headers : Headers | None = None ,
@@ -232,9 +283,14 @@ async def update(
232283 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
233284 ) -> ExtensionUpdateResponse :
234285 """
235- Update a Chrome extension (.zip/.crx file) for the organization
286+ Update a Chrome extension (.zip/.crx file or Chrome Web Store URL) for the
287+ organization
236288
237289 Args:
290+ file: Extension .zip/.crx file
291+
292+ url: Extension URL
293+
238294 extra_headers: Send extra headers
239295
240296 extra_query: Add additional query parameters to the request
@@ -245,8 +301,19 @@ async def update(
245301 """
246302 if not extension_id :
247303 raise ValueError (f"Expected a non-empty value for `extension_id` but received { extension_id !r} " )
304+ # It should be noted that the actual Content-Type header that will be
305+ # sent to the server will contain a `boundary` parameter, e.g.
306+ # multipart/form-data; boundary=---abc--
307+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
248308 return await self ._put (
249309 f"/v1/extensions/{ extension_id } " ,
310+ body = await async_maybe_transform (
311+ {
312+ "file" : file ,
313+ "url" : url ,
314+ },
315+ extension_update_params .ExtensionUpdateParams ,
316+ ),
250317 options = make_request_options (
251318 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
252319 ),
@@ -360,16 +427,45 @@ async def download(
360427 async def upload (
361428 self ,
362429 * ,
430+ file : object | NotGiven = NOT_GIVEN ,
431+ url : str | NotGiven = NOT_GIVEN ,
363432 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
364433 # The extra values given here take precedence over values defined on the client or passed to this method.
365434 extra_headers : Headers | None = None ,
366435 extra_query : Query | None = None ,
367436 extra_body : Body | None = None ,
368437 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
369438 ) -> ExtensionUploadResponse :
370- """Upload a Chrome extension (.zip/.crx file) for the organization"""
439+ """
440+ Upload a Chrome extension (.zip/.crx file or Chrome Web Store URL) for the
441+ organization
442+
443+ Args:
444+ file: Extension .zip/.crx file
445+
446+ url: Extension URL
447+
448+ extra_headers: Send extra headers
449+
450+ extra_query: Add additional query parameters to the request
451+
452+ extra_body: Add additional JSON properties to the request
453+
454+ timeout: Override the client-level default timeout for this request, in seconds
455+ """
456+ # It should be noted that the actual Content-Type header that will be
457+ # sent to the server will contain a `boundary` parameter, e.g.
458+ # multipart/form-data; boundary=---abc--
459+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
371460 return await self ._post (
372461 "/v1/extensions" ,
462+ body = await async_maybe_transform (
463+ {
464+ "file" : file ,
465+ "url" : url ,
466+ },
467+ extension_upload_params .ExtensionUploadParams ,
468+ ),
373469 options = make_request_options (
374470 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
375471 ),
0 commit comments