Skip to content

Commit

Permalink
feat(api): api update (#2318)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 6, 2025
1 parent c6cf3dc commit 9229d53
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 346 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1489
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-de7ae109130349e5b0b35b4d0944270435dfddb3ce7079da9b85f5dffaf86639.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6dadcd4e513c89328f85b769caf9ab478a927d302533e01ebf511a2965ec8cd5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

from __future__ import annotations

from typing import Any, Type, Iterable, Optional, cast
from typing_extensions import Literal, overload
from typing import Type, Optional, cast
from typing_extensions import Literal

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import (
required_args,
maybe_transform,
async_maybe_transform,
)
Expand Down Expand Up @@ -58,7 +57,6 @@ def with_streaming_response(self) -> ImpersonationRegistryResourceWithStreamingR
"""
return ImpersonationRegistryResourceWithStreamingResponse(self)

@overload
def create(
self,
*,
Expand Down Expand Up @@ -87,79 +85,26 @@ def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
...

@overload
def create(
self,
*,
account_id: str,
body: Iterable[impersonation_registry_create_params.Variant1Body],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ImpersonationRegistryCreateResponse:
"""
Create an entry in impersonation registry
Args:
account_id: Account Identifier
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
...

@required_args(["account_id", "email", "is_email_regex", "name"], ["account_id", "body"])
def create(
self,
*,
account_id: str,
email: str | NotGiven = NOT_GIVEN,
is_email_regex: bool | NotGiven = NOT_GIVEN,
name: str | NotGiven = NOT_GIVEN,
body: Iterable[impersonation_registry_create_params.Variant1Body] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ImpersonationRegistryCreateResponse:
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return cast(
ImpersonationRegistryCreateResponse,
self._post(
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
body=maybe_transform(
{
"email": email,
"is_email_regex": is_email_regex,
"name": name,
"body": body,
},
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[ImpersonationRegistryCreateResponse]
), # Union types cannot be passed in as arguments in the type system
return self._post(
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
body=maybe_transform(
{
"email": email,
"is_email_regex": is_email_regex,
"name": name,
},
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
),
cast_to=cast(Type[ImpersonationRegistryCreateResponse], ResultWrapper[ImpersonationRegistryCreateResponse]),
)

def list(
Expand Down Expand Up @@ -383,7 +328,6 @@ def with_streaming_response(self) -> AsyncImpersonationRegistryResourceWithStrea
"""
return AsyncImpersonationRegistryResourceWithStreamingResponse(self)

@overload
async def create(
self,
*,
Expand Down Expand Up @@ -412,79 +356,26 @@ async def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
...

@overload
async def create(
self,
*,
account_id: str,
body: Iterable[impersonation_registry_create_params.Variant1Body],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ImpersonationRegistryCreateResponse:
"""
Create an entry in impersonation registry
Args:
account_id: Account Identifier
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
...

@required_args(["account_id", "email", "is_email_regex", "name"], ["account_id", "body"])
async def create(
self,
*,
account_id: str,
email: str | NotGiven = NOT_GIVEN,
is_email_regex: bool | NotGiven = NOT_GIVEN,
name: str | NotGiven = NOT_GIVEN,
body: Iterable[impersonation_registry_create_params.Variant1Body] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ImpersonationRegistryCreateResponse:
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return cast(
ImpersonationRegistryCreateResponse,
await self._post(
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
body=await async_maybe_transform(
{
"email": email,
"is_email_regex": is_email_regex,
"name": name,
"body": body,
},
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[ImpersonationRegistryCreateResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._post(
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
body=await async_maybe_transform(
{
"email": email,
"is_email_regex": is_email_regex,
"name": name,
},
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
),
cast_to=cast(Type[ImpersonationRegistryCreateResponse], ResultWrapper[ImpersonationRegistryCreateResponse]),
)

def list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

from __future__ import annotations

from typing import Union, Iterable
from typing_extensions import Required, TypeAlias, TypedDict
from typing_extensions import Required, TypedDict

__all__ = ["ImpersonationRegistryCreateParams", "EmailSecurityCreateDisplayName", "Variant1", "Variant1Body"]
__all__ = ["ImpersonationRegistryCreateParams"]


class EmailSecurityCreateDisplayName(TypedDict, total=False):
class ImpersonationRegistryCreateParams(TypedDict, total=False):
account_id: Required[str]
"""Account Identifier"""

Expand All @@ -17,21 +16,3 @@ class EmailSecurityCreateDisplayName(TypedDict, total=False):
is_email_regex: Required[bool]

name: Required[str]


class Variant1(TypedDict, total=False):
account_id: Required[str]
"""Account Identifier"""

body: Required[Iterable[Variant1Body]]


class Variant1Body(TypedDict, total=False):
email: Required[str]

is_email_regex: Required[bool]

name: Required[str]


ImpersonationRegistryCreateParams: TypeAlias = Union[EmailSecurityCreateDisplayName, Variant1]
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Union, Optional
from typing import Optional
from datetime import datetime
from typing_extensions import TypeAlias

from ...._models import BaseModel

__all__ = ["ImpersonationRegistryCreateResponse", "EmailSecurityDisplayName", "UnionMember1"]
__all__ = ["ImpersonationRegistryCreateResponse"]


class EmailSecurityDisplayName(BaseModel):
class ImpersonationRegistryCreateResponse(BaseModel):
id: int

created_at: datetime

is_email_regex: bool

last_modified: datetime

name: str

comments: Optional[str] = None

directory_id: Optional[int] = None

directory_node_id: Optional[int] = None

email: Optional[str] = None

external_directory_node_id: Optional[str] = None

provenance: Optional[str] = None


class UnionMember1(BaseModel):
id: int

created_at: datetime
email: str

is_email_regex: bool

Expand All @@ -50,11 +27,6 @@ class UnionMember1(BaseModel):

directory_node_id: Optional[int] = None

email: Optional[str] = None

external_directory_node_id: Optional[str] = None

provenance: Optional[str] = None


ImpersonationRegistryCreateResponse: TypeAlias = Union[EmailSecurityDisplayName, List[UnionMember1]]
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ImpersonationRegistryEditResponse(BaseModel):

created_at: datetime

email: str

is_email_regex: bool

last_modified: datetime
Expand All @@ -25,8 +27,6 @@ class ImpersonationRegistryEditResponse(BaseModel):

directory_node_id: Optional[int] = None

email: Optional[str] = None

external_directory_node_id: Optional[str] = None

provenance: Optional[str] = None
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ImpersonationRegistryGetResponse(BaseModel):

created_at: datetime

email: str

is_email_regex: bool

last_modified: datetime
Expand All @@ -25,8 +27,6 @@ class ImpersonationRegistryGetResponse(BaseModel):

directory_node_id: Optional[int] = None

email: Optional[str] = None

external_directory_node_id: Optional[str] = None

provenance: Optional[str] = None
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ImpersonationRegistryListResponse(BaseModel):

created_at: datetime

email: str

is_email_regex: bool

last_modified: datetime
Expand All @@ -25,8 +27,6 @@ class ImpersonationRegistryListResponse(BaseModel):

directory_node_id: Optional[int] = None

email: Optional[str] = None

external_directory_node_id: Optional[str] = None

provenance: Optional[str] = None
Loading

0 comments on commit 9229d53

Please sign in to comment.