88import httpx
99
1010from ..._types import Body , Omit , Query , Headers , NotGiven , SequenceNotStr , omit , not_given
11- from ..._utils import maybe_transform , async_maybe_transform
11+ from ..._utils import path_template , maybe_transform , async_maybe_transform
1212from ..._compat import cached_property
1313from ..._resource import SyncAPIResource , AsyncAPIResource
1414from ..._response import (
@@ -56,7 +56,7 @@ def with_streaming_response(self) -> WidgetsResourceWithStreamingResponse:
5656 def create (
5757 self ,
5858 * ,
59- account_id : str ,
59+ account_id : str | None = None ,
6060 domains : SequenceNotStr [WidgetDomain ],
6161 mode : Literal ["non-interactive" , "invisible" , "managed" ],
6262 name : str ,
@@ -129,10 +129,12 @@ def create(
129129
130130 timeout: Override the client-level default timeout for this request, in seconds
131131 """
132+ if account_id is None :
133+ account_id = self ._client ._get_account_id_path_param ()
132134 if not account_id :
133135 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
134136 return self ._post (
135- f "/accounts/{ account_id } /challenges/widgets" ,
137+ path_template ( "/accounts/{account_id}/challenges/widgets" , account_id = account_id ) ,
136138 body = maybe_transform (
137139 {
138140 "domains" : domains ,
@@ -170,7 +172,7 @@ def update(
170172 self ,
171173 sitekey : str ,
172174 * ,
173- account_id : str ,
175+ account_id : str | None = None ,
174176 domains : SequenceNotStr [WidgetDomain ],
175177 mode : Literal ["non-interactive" , "invisible" , "managed" ],
176178 name : str ,
@@ -220,12 +222,16 @@ def update(
220222
221223 timeout: Override the client-level default timeout for this request, in seconds
222224 """
225+ if account_id is None :
226+ account_id = self ._client ._get_account_id_path_param ()
223227 if not account_id :
224228 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
225229 if not sitekey :
226230 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
227231 return self ._put (
228- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } " ,
232+ path_template (
233+ "/accounts/{account_id}/challenges/widgets/{sitekey}" , account_id = account_id , sitekey = sitekey
234+ ),
229235 body = maybe_transform (
230236 {
231237 "domains" : domains ,
@@ -252,7 +258,7 @@ def update(
252258 def list (
253259 self ,
254260 * ,
255- account_id : str ,
261+ account_id : str | None = None ,
256262 direction : Literal ["asc" , "desc" ] | Omit = omit ,
257263 filter : str | Omit = omit ,
258264 order : Literal ["id" , "sitekey" , "name" , "created_on" , "modified_on" ] | Omit = omit ,
@@ -299,10 +305,12 @@ def list(
299305
300306 timeout: Override the client-level default timeout for this request, in seconds
301307 """
308+ if account_id is None :
309+ account_id = self ._client ._get_account_id_path_param ()
302310 if not account_id :
303311 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
304312 return self ._get_api_list (
305- f "/accounts/{ account_id } /challenges/widgets" ,
313+ path_template ( "/accounts/{account_id}/challenges/widgets" , account_id = account_id ) ,
306314 page = SyncV4PagePaginationArray [WidgetListResponse ],
307315 options = make_request_options (
308316 extra_headers = extra_headers ,
@@ -327,7 +335,7 @@ def delete(
327335 self ,
328336 sitekey : str ,
329337 * ,
330- account_id : str ,
338+ account_id : str | None = None ,
331339 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
332340 # The extra values given here take precedence over values defined on the client or passed to this method.
333341 extra_headers : Headers | None = None ,
@@ -351,12 +359,16 @@ def delete(
351359
352360 timeout: Override the client-level default timeout for this request, in seconds
353361 """
362+ if account_id is None :
363+ account_id = self ._client ._get_account_id_path_param ()
354364 if not account_id :
355365 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
356366 if not sitekey :
357367 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
358368 return self ._delete (
359- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } " ,
369+ path_template (
370+ "/accounts/{account_id}/challenges/widgets/{sitekey}" , account_id = account_id , sitekey = sitekey
371+ ),
360372 options = make_request_options (
361373 extra_headers = extra_headers ,
362374 extra_query = extra_query ,
@@ -371,7 +383,7 @@ def get(
371383 self ,
372384 sitekey : str ,
373385 * ,
374- account_id : str ,
386+ account_id : str | None = None ,
375387 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
376388 # The extra values given here take precedence over values defined on the client or passed to this method.
377389 extra_headers : Headers | None = None ,
@@ -395,12 +407,16 @@ def get(
395407
396408 timeout: Override the client-level default timeout for this request, in seconds
397409 """
410+ if account_id is None :
411+ account_id = self ._client ._get_account_id_path_param ()
398412 if not account_id :
399413 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
400414 if not sitekey :
401415 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
402416 return self ._get (
403- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } " ,
417+ path_template (
418+ "/accounts/{account_id}/challenges/widgets/{sitekey}" , account_id = account_id , sitekey = sitekey
419+ ),
404420 options = make_request_options (
405421 extra_headers = extra_headers ,
406422 extra_query = extra_query ,
@@ -415,7 +431,7 @@ def rotate_secret(
415431 self ,
416432 sitekey : str ,
417433 * ,
418- account_id : str ,
434+ account_id : str | None = None ,
419435 invalidate_immediately : bool | Omit = omit ,
420436 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
421437 # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -448,12 +464,18 @@ def rotate_secret(
448464
449465 timeout: Override the client-level default timeout for this request, in seconds
450466 """
467+ if account_id is None :
468+ account_id = self ._client ._get_account_id_path_param ()
451469 if not account_id :
452470 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
453471 if not sitekey :
454472 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
455473 return self ._post (
456- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } /rotate_secret" ,
474+ path_template (
475+ "/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret" ,
476+ account_id = account_id ,
477+ sitekey = sitekey ,
478+ ),
457479 body = maybe_transform (
458480 {"invalidate_immediately" : invalidate_immediately }, widget_rotate_secret_params .WidgetRotateSecretParams
459481 ),
@@ -491,7 +513,7 @@ def with_streaming_response(self) -> AsyncWidgetsResourceWithStreamingResponse:
491513 async def create (
492514 self ,
493515 * ,
494- account_id : str ,
516+ account_id : str | None = None ,
495517 domains : SequenceNotStr [WidgetDomain ],
496518 mode : Literal ["non-interactive" , "invisible" , "managed" ],
497519 name : str ,
@@ -564,10 +586,12 @@ async def create(
564586
565587 timeout: Override the client-level default timeout for this request, in seconds
566588 """
589+ if account_id is None :
590+ account_id = self ._client ._get_account_id_path_param ()
567591 if not account_id :
568592 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
569593 return await self ._post (
570- f "/accounts/{ account_id } /challenges/widgets" ,
594+ path_template ( "/accounts/{account_id}/challenges/widgets" , account_id = account_id ) ,
571595 body = await async_maybe_transform (
572596 {
573597 "domains" : domains ,
@@ -605,7 +629,7 @@ async def update(
605629 self ,
606630 sitekey : str ,
607631 * ,
608- account_id : str ,
632+ account_id : str | None = None ,
609633 domains : SequenceNotStr [WidgetDomain ],
610634 mode : Literal ["non-interactive" , "invisible" , "managed" ],
611635 name : str ,
@@ -655,12 +679,16 @@ async def update(
655679
656680 timeout: Override the client-level default timeout for this request, in seconds
657681 """
682+ if account_id is None :
683+ account_id = self ._client ._get_account_id_path_param ()
658684 if not account_id :
659685 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
660686 if not sitekey :
661687 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
662688 return await self ._put (
663- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } " ,
689+ path_template (
690+ "/accounts/{account_id}/challenges/widgets/{sitekey}" , account_id = account_id , sitekey = sitekey
691+ ),
664692 body = await async_maybe_transform (
665693 {
666694 "domains" : domains ,
@@ -687,7 +715,7 @@ async def update(
687715 def list (
688716 self ,
689717 * ,
690- account_id : str ,
718+ account_id : str | None = None ,
691719 direction : Literal ["asc" , "desc" ] | Omit = omit ,
692720 filter : str | Omit = omit ,
693721 order : Literal ["id" , "sitekey" , "name" , "created_on" , "modified_on" ] | Omit = omit ,
@@ -734,10 +762,12 @@ def list(
734762
735763 timeout: Override the client-level default timeout for this request, in seconds
736764 """
765+ if account_id is None :
766+ account_id = self ._client ._get_account_id_path_param ()
737767 if not account_id :
738768 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
739769 return self ._get_api_list (
740- f "/accounts/{ account_id } /challenges/widgets" ,
770+ path_template ( "/accounts/{account_id}/challenges/widgets" , account_id = account_id ) ,
741771 page = AsyncV4PagePaginationArray [WidgetListResponse ],
742772 options = make_request_options (
743773 extra_headers = extra_headers ,
@@ -762,7 +792,7 @@ async def delete(
762792 self ,
763793 sitekey : str ,
764794 * ,
765- account_id : str ,
795+ account_id : str | None = None ,
766796 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
767797 # The extra values given here take precedence over values defined on the client or passed to this method.
768798 extra_headers : Headers | None = None ,
@@ -786,12 +816,16 @@ async def delete(
786816
787817 timeout: Override the client-level default timeout for this request, in seconds
788818 """
819+ if account_id is None :
820+ account_id = self ._client ._get_account_id_path_param ()
789821 if not account_id :
790822 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
791823 if not sitekey :
792824 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
793825 return await self ._delete (
794- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } " ,
826+ path_template (
827+ "/accounts/{account_id}/challenges/widgets/{sitekey}" , account_id = account_id , sitekey = sitekey
828+ ),
795829 options = make_request_options (
796830 extra_headers = extra_headers ,
797831 extra_query = extra_query ,
@@ -806,7 +840,7 @@ async def get(
806840 self ,
807841 sitekey : str ,
808842 * ,
809- account_id : str ,
843+ account_id : str | None = None ,
810844 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
811845 # The extra values given here take precedence over values defined on the client or passed to this method.
812846 extra_headers : Headers | None = None ,
@@ -830,12 +864,16 @@ async def get(
830864
831865 timeout: Override the client-level default timeout for this request, in seconds
832866 """
867+ if account_id is None :
868+ account_id = self ._client ._get_account_id_path_param ()
833869 if not account_id :
834870 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
835871 if not sitekey :
836872 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
837873 return await self ._get (
838- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } " ,
874+ path_template (
875+ "/accounts/{account_id}/challenges/widgets/{sitekey}" , account_id = account_id , sitekey = sitekey
876+ ),
839877 options = make_request_options (
840878 extra_headers = extra_headers ,
841879 extra_query = extra_query ,
@@ -850,7 +888,7 @@ async def rotate_secret(
850888 self ,
851889 sitekey : str ,
852890 * ,
853- account_id : str ,
891+ account_id : str | None = None ,
854892 invalidate_immediately : bool | Omit = omit ,
855893 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
856894 # The extra values given here take precedence over values defined on the client or passed to this method.
@@ -883,12 +921,18 @@ async def rotate_secret(
883921
884922 timeout: Override the client-level default timeout for this request, in seconds
885923 """
924+ if account_id is None :
925+ account_id = self ._client ._get_account_id_path_param ()
886926 if not account_id :
887927 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
888928 if not sitekey :
889929 raise ValueError (f"Expected a non-empty value for `sitekey` but received { sitekey !r} " )
890930 return await self ._post (
891- f"/accounts/{ account_id } /challenges/widgets/{ sitekey } /rotate_secret" ,
931+ path_template (
932+ "/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret" ,
933+ account_id = account_id ,
934+ sitekey = sitekey ,
935+ ),
892936 body = await async_maybe_transform (
893937 {"invalidate_immediately" : invalidate_immediately }, widget_rotate_secret_params .WidgetRotateSecretParams
894938 ),
0 commit comments