Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #335

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/cloudflare/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ class Cloudflare(SyncAPIClient):
with_streaming_response: CloudflareWithStreamedResponse

# client options
api_token: str | None
api_key: str | None
api_email: str | None
api_token: str | None
user_service_key: str | None

def __init__(
self,
*,
api_token: str | None = None,
api_key: str | None = None,
api_email: str | None = None,
api_token: str | None = None,
user_service_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
Expand All @@ -165,11 +165,15 @@ def __init__(
"""Construct a new synchronous cloudflare client instance.

This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_token` from `CLOUDFLARE_API_TOKEN`
- `api_key` from `CLOUDFLARE_API_KEY`
- `api_email` from `CLOUDFLARE_EMAIL`
- `api_token` from `CLOUDFLARE_API_TOKEN`
- `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY`
"""
if api_token is None:
api_token = os.environ.get("CLOUDFLARE_API_TOKEN")
self.api_token = api_token

if api_key is None:
api_key = os.environ.get("CLOUDFLARE_API_KEY")
self.api_key = api_key
Expand All @@ -178,10 +182,6 @@ def __init__(
api_email = os.environ.get("CLOUDFLARE_EMAIL")
self.api_email = api_email

if api_token is None:
api_token = os.environ.get("CLOUDFLARE_API_TOKEN")
self.api_token = api_token

if user_service_key is None:
user_service_key = os.environ.get("CLOUDFLARE_API_USER_SERVICE_KEY")
self.user_service_key = user_service_key
Expand Down Expand Up @@ -371,9 +371,9 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
def copy(
self,
*,
api_token: str | None = None,
api_key: str | None = None,
api_email: str | None = None,
api_token: str | None = None,
user_service_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -408,9 +408,9 @@ def copy(

http_client = http_client or self._client
return self.__class__(
api_token=api_token or self.api_token,
api_key=api_key or self.api_key,
api_email=api_email or self.api_email,
api_token=api_token or self.api_token,
user_service_key=user_service_key or self.user_service_key,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
Expand Down Expand Up @@ -544,17 +544,17 @@ class AsyncCloudflare(AsyncAPIClient):
with_streaming_response: AsyncCloudflareWithStreamedResponse

# client options
api_token: str | None
api_key: str | None
api_email: str | None
api_token: str | None
user_service_key: str | None

def __init__(
self,
*,
api_token: str | None = None,
api_key: str | None = None,
api_email: str | None = None,
api_token: str | None = None,
user_service_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
Expand All @@ -578,11 +578,15 @@ def __init__(
"""Construct a new async cloudflare client instance.

This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_token` from `CLOUDFLARE_API_TOKEN`
- `api_key` from `CLOUDFLARE_API_KEY`
- `api_email` from `CLOUDFLARE_EMAIL`
- `api_token` from `CLOUDFLARE_API_TOKEN`
- `user_service_key` from `CLOUDFLARE_API_USER_SERVICE_KEY`
"""
if api_token is None:
api_token = os.environ.get("CLOUDFLARE_API_TOKEN")
self.api_token = api_token

if api_key is None:
api_key = os.environ.get("CLOUDFLARE_API_KEY")
self.api_key = api_key
Expand All @@ -591,10 +595,6 @@ def __init__(
api_email = os.environ.get("CLOUDFLARE_EMAIL")
self.api_email = api_email

if api_token is None:
api_token = os.environ.get("CLOUDFLARE_API_TOKEN")
self.api_token = api_token

if user_service_key is None:
user_service_key = os.environ.get("CLOUDFLARE_API_USER_SERVICE_KEY")
self.user_service_key = user_service_key
Expand Down Expand Up @@ -784,9 +784,9 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
def copy(
self,
*,
api_token: str | None = None,
api_key: str | None = None,
api_email: str | None = None,
api_token: str | None = None,
user_service_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -821,9 +821,9 @@ def copy(

http_client = http_client or self._client
return self.__class__(
api_token=api_token or self.api_token,
api_key=api_key or self.api_key,
api_email=api_email or self.api_email,
api_token=api_token or self.api_token,
user_service_key=user_service_key or self.user_service_key,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
Expand Down