@@ -131,17 +131,17 @@ class Cloudflare(SyncAPIClient):
131131 with_streaming_response : CloudflareWithStreamedResponse
132132
133133 # client options
134+ api_token : str | None
134135 api_key : str | None
135136 api_email : str | None
136- api_token : str | None
137137 user_service_key : str | None
138138
139139 def __init__ (
140140 self ,
141141 * ,
142+ api_token : str | None = None ,
142143 api_key : str | None = None ,
143144 api_email : str | None = None ,
144- api_token : str | None = None ,
145145 user_service_key : str | None = None ,
146146 base_url : str | httpx .URL | None = None ,
147147 timeout : Union [float , Timeout , None , NotGiven ] = NOT_GIVEN ,
@@ -165,11 +165,15 @@ def __init__(
165165 """Construct a new synchronous cloudflare client instance.
166166
167167 This automatically infers the following arguments from their corresponding environment variables if they are not provided:
168+ - `api_token` from `CLOUDFLARE_API_TOKEN`
168169 - `api_key` from `CLOUDFLARE_API_KEY`
169170 - `api_email` from `CLOUDFLARE_EMAIL`
170- - `api_token` from `CLOUDFLARE_API_TOKEN`
171171 - `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY`
172172 """
173+ if api_token is None :
174+ api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
175+ self .api_token = api_token
176+
173177 if api_key is None :
174178 api_key = os .environ .get ("CLOUDFLARE_API_KEY" )
175179 self .api_key = api_key
@@ -178,10 +182,6 @@ def __init__(
178182 api_email = os .environ .get ("CLOUDFLARE_EMAIL" )
179183 self .api_email = api_email
180184
181- if api_token is None :
182- api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
183- self .api_token = api_token
184-
185185 if user_service_key is None :
186186 user_service_key = os .environ .get ("CLOUDFLARE_API_USER_SERVICE_KEY" )
187187 self .user_service_key = user_service_key
@@ -371,9 +371,9 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
371371 def copy (
372372 self ,
373373 * ,
374+ api_token : str | None = None ,
374375 api_key : str | None = None ,
375376 api_email : str | None = None ,
376- api_token : str | None = None ,
377377 user_service_key : str | None = None ,
378378 base_url : str | httpx .URL | None = None ,
379379 timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
@@ -408,9 +408,9 @@ def copy(
408408
409409 http_client = http_client or self ._client
410410 return self .__class__ (
411+ api_token = api_token or self .api_token ,
411412 api_key = api_key or self .api_key ,
412413 api_email = api_email or self .api_email ,
413- api_token = api_token or self .api_token ,
414414 user_service_key = user_service_key or self .user_service_key ,
415415 base_url = base_url or self .base_url ,
416416 timeout = self .timeout if isinstance (timeout , NotGiven ) else timeout ,
@@ -544,17 +544,17 @@ class AsyncCloudflare(AsyncAPIClient):
544544 with_streaming_response : AsyncCloudflareWithStreamedResponse
545545
546546 # client options
547+ api_token : str | None
547548 api_key : str | None
548549 api_email : str | None
549- api_token : str | None
550550 user_service_key : str | None
551551
552552 def __init__ (
553553 self ,
554554 * ,
555+ api_token : str | None = None ,
555556 api_key : str | None = None ,
556557 api_email : str | None = None ,
557- api_token : str | None = None ,
558558 user_service_key : str | None = None ,
559559 base_url : str | httpx .URL | None = None ,
560560 timeout : Union [float , Timeout , None , NotGiven ] = NOT_GIVEN ,
@@ -578,11 +578,15 @@ def __init__(
578578 """Construct a new async cloudflare client instance.
579579
580580 This automatically infers the following arguments from their corresponding environment variables if they are not provided:
581+ - `api_token` from `CLOUDFLARE_API_TOKEN`
581582 - `api_key` from `CLOUDFLARE_API_KEY`
582583 - `api_email` from `CLOUDFLARE_EMAIL`
583- - `api_token` from `CLOUDFLARE_API_TOKEN`
584584 - `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY`
585585 """
586+ if api_token is None :
587+ api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
588+ self .api_token = api_token
589+
586590 if api_key is None :
587591 api_key = os .environ .get ("CLOUDFLARE_API_KEY" )
588592 self .api_key = api_key
@@ -591,10 +595,6 @@ def __init__(
591595 api_email = os .environ .get ("CLOUDFLARE_EMAIL" )
592596 self .api_email = api_email
593597
594- if api_token is None :
595- api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
596- self .api_token = api_token
597-
598598 if user_service_key is None :
599599 user_service_key = os .environ .get ("CLOUDFLARE_API_USER_SERVICE_KEY" )
600600 self .user_service_key = user_service_key
@@ -784,9 +784,9 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
784784 def copy (
785785 self ,
786786 * ,
787+ api_token : str | None = None ,
787788 api_key : str | None = None ,
788789 api_email : str | None = None ,
789- api_token : str | None = None ,
790790 user_service_key : str | None = None ,
791791 base_url : str | httpx .URL | None = None ,
792792 timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
@@ -821,9 +821,9 @@ def copy(
821821
822822 http_client = http_client or self ._client
823823 return self .__class__ (
824+ api_token = api_token or self .api_token ,
824825 api_key = api_key or self .api_key ,
825826 api_email = api_email or self .api_email ,
826- api_token = api_token or self .api_token ,
827827 user_service_key = user_service_key or self .user_service_key ,
828828 base_url = base_url or self .base_url ,
829829 timeout = self .timeout if isinstance (timeout , NotGiven ) else timeout ,
0 commit comments