@@ -131,17 +131,17 @@ class Cloudflare(SyncAPIClient):
131
131
with_streaming_response : CloudflareWithStreamedResponse
132
132
133
133
# client options
134
+ api_token : str | None
134
135
api_key : str | None
135
136
api_email : str | None
136
- api_token : str | None
137
137
user_service_key : str | None
138
138
139
139
def __init__ (
140
140
self ,
141
141
* ,
142
+ api_token : str | None = None ,
142
143
api_key : str | None = None ,
143
144
api_email : str | None = None ,
144
- api_token : str | None = None ,
145
145
user_service_key : str | None = None ,
146
146
base_url : str | httpx .URL | None = None ,
147
147
timeout : Union [float , Timeout , None , NotGiven ] = NOT_GIVEN ,
@@ -165,11 +165,15 @@ def __init__(
165
165
"""Construct a new synchronous cloudflare client instance.
166
166
167
167
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
168
+ - `api_token` from `CLOUDFLARE_API_TOKEN`
168
169
- `api_key` from `CLOUDFLARE_API_KEY`
169
170
- `api_email` from `CLOUDFLARE_EMAIL`
170
- - `api_token` from `CLOUDFLARE_API_TOKEN`
171
171
- `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY`
172
172
"""
173
+ if api_token is None :
174
+ api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
175
+ self .api_token = api_token
176
+
173
177
if api_key is None :
174
178
api_key = os .environ .get ("CLOUDFLARE_API_KEY" )
175
179
self .api_key = api_key
@@ -178,10 +182,6 @@ def __init__(
178
182
api_email = os .environ .get ("CLOUDFLARE_EMAIL" )
179
183
self .api_email = api_email
180
184
181
- if api_token is None :
182
- api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
183
- self .api_token = api_token
184
-
185
185
if user_service_key is None :
186
186
user_service_key = os .environ .get ("CLOUDFLARE_API_USER_SERVICE_KEY" )
187
187
self .user_service_key = user_service_key
@@ -371,9 +371,9 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
371
371
def copy (
372
372
self ,
373
373
* ,
374
+ api_token : str | None = None ,
374
375
api_key : str | None = None ,
375
376
api_email : str | None = None ,
376
- api_token : str | None = None ,
377
377
user_service_key : str | None = None ,
378
378
base_url : str | httpx .URL | None = None ,
379
379
timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
@@ -408,9 +408,9 @@ def copy(
408
408
409
409
http_client = http_client or self ._client
410
410
return self .__class__ (
411
+ api_token = api_token or self .api_token ,
411
412
api_key = api_key or self .api_key ,
412
413
api_email = api_email or self .api_email ,
413
- api_token = api_token or self .api_token ,
414
414
user_service_key = user_service_key or self .user_service_key ,
415
415
base_url = base_url or self .base_url ,
416
416
timeout = self .timeout if isinstance (timeout , NotGiven ) else timeout ,
@@ -544,17 +544,17 @@ class AsyncCloudflare(AsyncAPIClient):
544
544
with_streaming_response : AsyncCloudflareWithStreamedResponse
545
545
546
546
# client options
547
+ api_token : str | None
547
548
api_key : str | None
548
549
api_email : str | None
549
- api_token : str | None
550
550
user_service_key : str | None
551
551
552
552
def __init__ (
553
553
self ,
554
554
* ,
555
+ api_token : str | None = None ,
555
556
api_key : str | None = None ,
556
557
api_email : str | None = None ,
557
- api_token : str | None = None ,
558
558
user_service_key : str | None = None ,
559
559
base_url : str | httpx .URL | None = None ,
560
560
timeout : Union [float , Timeout , None , NotGiven ] = NOT_GIVEN ,
@@ -578,11 +578,15 @@ def __init__(
578
578
"""Construct a new async cloudflare client instance.
579
579
580
580
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
581
+ - `api_token` from `CLOUDFLARE_API_TOKEN`
581
582
- `api_key` from `CLOUDFLARE_API_KEY`
582
583
- `api_email` from `CLOUDFLARE_EMAIL`
583
- - `api_token` from `CLOUDFLARE_API_TOKEN`
584
584
- `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY`
585
585
"""
586
+ if api_token is None :
587
+ api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
588
+ self .api_token = api_token
589
+
586
590
if api_key is None :
587
591
api_key = os .environ .get ("CLOUDFLARE_API_KEY" )
588
592
self .api_key = api_key
@@ -591,10 +595,6 @@ def __init__(
591
595
api_email = os .environ .get ("CLOUDFLARE_EMAIL" )
592
596
self .api_email = api_email
593
597
594
- if api_token is None :
595
- api_token = os .environ .get ("CLOUDFLARE_API_TOKEN" )
596
- self .api_token = api_token
597
-
598
598
if user_service_key is None :
599
599
user_service_key = os .environ .get ("CLOUDFLARE_API_USER_SERVICE_KEY" )
600
600
self .user_service_key = user_service_key
@@ -784,9 +784,9 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
784
784
def copy (
785
785
self ,
786
786
* ,
787
+ api_token : str | None = None ,
787
788
api_key : str | None = None ,
788
789
api_email : str | None = None ,
789
- api_token : str | None = None ,
790
790
user_service_key : str | None = None ,
791
791
base_url : str | httpx .URL | None = None ,
792
792
timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
@@ -821,9 +821,9 @@ def copy(
821
821
822
822
http_client = http_client or self ._client
823
823
return self .__class__ (
824
+ api_token = api_token or self .api_token ,
824
825
api_key = api_key or self .api_key ,
825
826
api_email = api_email or self .api_email ,
826
- api_token = api_token or self .api_token ,
827
827
user_service_key = user_service_key or self .user_service_key ,
828
828
base_url = base_url or self .base_url ,
829
829
timeout = self .timeout if isinstance (timeout , NotGiven ) else timeout ,
0 commit comments