Skip to content

Commit 9229d53

Browse files
feat(api): api update (#2318)
1 parent c6cf3dc commit 9229d53

File tree

8 files changed

+58
-346
lines changed

8 files changed

+58
-346
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1489
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-de7ae109130349e5b0b35b4d0944270435dfddb3ce7079da9b85f5dffaf86639.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6dadcd4e513c89328f85b769caf9ab478a927d302533e01ebf511a2965ec8cd5.yml

src/cloudflare/resources/email_security/settings/impersonation_registry.py

+36-145
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
from __future__ import annotations
44

5-
from typing import Any, Type, Iterable, Optional, cast
6-
from typing_extensions import Literal, overload
5+
from typing import Type, Optional, cast
6+
from typing_extensions import Literal
77

88
import httpx
99

1010
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1111
from ...._utils import (
12-
required_args,
1312
maybe_transform,
1413
async_maybe_transform,
1514
)
@@ -58,7 +57,6 @@ def with_streaming_response(self) -> ImpersonationRegistryResourceWithStreamingR
5857
"""
5958
return ImpersonationRegistryResourceWithStreamingResponse(self)
6059

61-
@overload
6260
def create(
6361
self,
6462
*,
@@ -87,79 +85,26 @@ def create(
8785
8886
timeout: Override the client-level default timeout for this request, in seconds
8987
"""
90-
...
91-
92-
@overload
93-
def create(
94-
self,
95-
*,
96-
account_id: str,
97-
body: Iterable[impersonation_registry_create_params.Variant1Body],
98-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
99-
# The extra values given here take precedence over values defined on the client or passed to this method.
100-
extra_headers: Headers | None = None,
101-
extra_query: Query | None = None,
102-
extra_body: Body | None = None,
103-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
104-
) -> ImpersonationRegistryCreateResponse:
105-
"""
106-
Create an entry in impersonation registry
107-
108-
Args:
109-
account_id: Account Identifier
110-
111-
extra_headers: Send extra headers
112-
113-
extra_query: Add additional query parameters to the request
114-
115-
extra_body: Add additional JSON properties to the request
116-
117-
timeout: Override the client-level default timeout for this request, in seconds
118-
"""
119-
...
120-
121-
@required_args(["account_id", "email", "is_email_regex", "name"], ["account_id", "body"])
122-
def create(
123-
self,
124-
*,
125-
account_id: str,
126-
email: str | NotGiven = NOT_GIVEN,
127-
is_email_regex: bool | NotGiven = NOT_GIVEN,
128-
name: str | NotGiven = NOT_GIVEN,
129-
body: Iterable[impersonation_registry_create_params.Variant1Body] | NotGiven = NOT_GIVEN,
130-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
131-
# The extra values given here take precedence over values defined on the client or passed to this method.
132-
extra_headers: Headers | None = None,
133-
extra_query: Query | None = None,
134-
extra_body: Body | None = None,
135-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
136-
) -> ImpersonationRegistryCreateResponse:
13788
if not account_id:
13889
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
139-
return cast(
140-
ImpersonationRegistryCreateResponse,
141-
self._post(
142-
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
143-
body=maybe_transform(
144-
{
145-
"email": email,
146-
"is_email_regex": is_email_regex,
147-
"name": name,
148-
"body": body,
149-
},
150-
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
151-
),
152-
options=make_request_options(
153-
extra_headers=extra_headers,
154-
extra_query=extra_query,
155-
extra_body=extra_body,
156-
timeout=timeout,
157-
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
158-
),
159-
cast_to=cast(
160-
Any, ResultWrapper[ImpersonationRegistryCreateResponse]
161-
), # Union types cannot be passed in as arguments in the type system
90+
return self._post(
91+
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
92+
body=maybe_transform(
93+
{
94+
"email": email,
95+
"is_email_regex": is_email_regex,
96+
"name": name,
97+
},
98+
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
99+
),
100+
options=make_request_options(
101+
extra_headers=extra_headers,
102+
extra_query=extra_query,
103+
extra_body=extra_body,
104+
timeout=timeout,
105+
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
162106
),
107+
cast_to=cast(Type[ImpersonationRegistryCreateResponse], ResultWrapper[ImpersonationRegistryCreateResponse]),
163108
)
164109

165110
def list(
@@ -383,7 +328,6 @@ def with_streaming_response(self) -> AsyncImpersonationRegistryResourceWithStrea
383328
"""
384329
return AsyncImpersonationRegistryResourceWithStreamingResponse(self)
385330

386-
@overload
387331
async def create(
388332
self,
389333
*,
@@ -412,79 +356,26 @@ async def create(
412356
413357
timeout: Override the client-level default timeout for this request, in seconds
414358
"""
415-
...
416-
417-
@overload
418-
async def create(
419-
self,
420-
*,
421-
account_id: str,
422-
body: Iterable[impersonation_registry_create_params.Variant1Body],
423-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
424-
# The extra values given here take precedence over values defined on the client or passed to this method.
425-
extra_headers: Headers | None = None,
426-
extra_query: Query | None = None,
427-
extra_body: Body | None = None,
428-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
429-
) -> ImpersonationRegistryCreateResponse:
430-
"""
431-
Create an entry in impersonation registry
432-
433-
Args:
434-
account_id: Account Identifier
435-
436-
extra_headers: Send extra headers
437-
438-
extra_query: Add additional query parameters to the request
439-
440-
extra_body: Add additional JSON properties to the request
441-
442-
timeout: Override the client-level default timeout for this request, in seconds
443-
"""
444-
...
445-
446-
@required_args(["account_id", "email", "is_email_regex", "name"], ["account_id", "body"])
447-
async def create(
448-
self,
449-
*,
450-
account_id: str,
451-
email: str | NotGiven = NOT_GIVEN,
452-
is_email_regex: bool | NotGiven = NOT_GIVEN,
453-
name: str | NotGiven = NOT_GIVEN,
454-
body: Iterable[impersonation_registry_create_params.Variant1Body] | NotGiven = NOT_GIVEN,
455-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
456-
# The extra values given here take precedence over values defined on the client or passed to this method.
457-
extra_headers: Headers | None = None,
458-
extra_query: Query | None = None,
459-
extra_body: Body | None = None,
460-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
461-
) -> ImpersonationRegistryCreateResponse:
462359
if not account_id:
463360
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
464-
return cast(
465-
ImpersonationRegistryCreateResponse,
466-
await self._post(
467-
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
468-
body=await async_maybe_transform(
469-
{
470-
"email": email,
471-
"is_email_regex": is_email_regex,
472-
"name": name,
473-
"body": body,
474-
},
475-
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
476-
),
477-
options=make_request_options(
478-
extra_headers=extra_headers,
479-
extra_query=extra_query,
480-
extra_body=extra_body,
481-
timeout=timeout,
482-
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
483-
),
484-
cast_to=cast(
485-
Any, ResultWrapper[ImpersonationRegistryCreateResponse]
486-
), # Union types cannot be passed in as arguments in the type system
361+
return await self._post(
362+
f"/accounts/{account_id}/email-security/settings/impersonation_registry",
363+
body=await async_maybe_transform(
364+
{
365+
"email": email,
366+
"is_email_regex": is_email_regex,
367+
"name": name,
368+
},
369+
impersonation_registry_create_params.ImpersonationRegistryCreateParams,
370+
),
371+
options=make_request_options(
372+
extra_headers=extra_headers,
373+
extra_query=extra_query,
374+
extra_body=extra_body,
375+
timeout=timeout,
376+
post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper,
487377
),
378+
cast_to=cast(Type[ImpersonationRegistryCreateResponse], ResultWrapper[ImpersonationRegistryCreateResponse]),
488379
)
489380

490381
def list(

src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py

+3-22
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
from __future__ import annotations
44

5-
from typing import Union, Iterable
6-
from typing_extensions import Required, TypeAlias, TypedDict
5+
from typing_extensions import Required, TypedDict
76

8-
__all__ = ["ImpersonationRegistryCreateParams", "EmailSecurityCreateDisplayName", "Variant1", "Variant1Body"]
7+
__all__ = ["ImpersonationRegistryCreateParams"]
98

109

11-
class EmailSecurityCreateDisplayName(TypedDict, total=False):
10+
class ImpersonationRegistryCreateParams(TypedDict, total=False):
1211
account_id: Required[str]
1312
"""Account Identifier"""
1413

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

1918
name: Required[str]
20-
21-
22-
class Variant1(TypedDict, total=False):
23-
account_id: Required[str]
24-
"""Account Identifier"""
25-
26-
body: Required[Iterable[Variant1Body]]
27-
28-
29-
class Variant1Body(TypedDict, total=False):
30-
email: Required[str]
31-
32-
is_email_regex: Required[bool]
33-
34-
name: Required[str]
35-
36-
37-
ImpersonationRegistryCreateParams: TypeAlias = Union[EmailSecurityCreateDisplayName, Variant1]
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,19 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List, Union, Optional
3+
from typing import Optional
44
from datetime import datetime
5-
from typing_extensions import TypeAlias
65

76
from ...._models import BaseModel
87

9-
__all__ = ["ImpersonationRegistryCreateResponse", "EmailSecurityDisplayName", "UnionMember1"]
8+
__all__ = ["ImpersonationRegistryCreateResponse"]
109

1110

12-
class EmailSecurityDisplayName(BaseModel):
11+
class ImpersonationRegistryCreateResponse(BaseModel):
1312
id: int
1413

1514
created_at: datetime
1615

17-
is_email_regex: bool
18-
19-
last_modified: datetime
20-
21-
name: str
22-
23-
comments: Optional[str] = None
24-
25-
directory_id: Optional[int] = None
26-
27-
directory_node_id: Optional[int] = None
28-
29-
email: Optional[str] = None
30-
31-
external_directory_node_id: Optional[str] = None
32-
33-
provenance: Optional[str] = None
34-
35-
36-
class UnionMember1(BaseModel):
37-
id: int
38-
39-
created_at: datetime
16+
email: str
4017

4118
is_email_regex: bool
4219

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

5128
directory_node_id: Optional[int] = None
5229

53-
email: Optional[str] = None
54-
5530
external_directory_node_id: Optional[str] = None
5631

5732
provenance: Optional[str] = None
58-
59-
60-
ImpersonationRegistryCreateResponse: TypeAlias = Union[EmailSecurityDisplayName, List[UnionMember1]]

src/cloudflare/types/email_security/settings/impersonation_registry_edit_response.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class ImpersonationRegistryEditResponse(BaseModel):
1313

1414
created_at: datetime
1515

16+
email: str
17+
1618
is_email_regex: bool
1719

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

2628
directory_node_id: Optional[int] = None
2729

28-
email: Optional[str] = None
29-
3030
external_directory_node_id: Optional[str] = None
3131

3232
provenance: Optional[str] = None

src/cloudflare/types/email_security/settings/impersonation_registry_get_response.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class ImpersonationRegistryGetResponse(BaseModel):
1313

1414
created_at: datetime
1515

16+
email: str
17+
1618
is_email_regex: bool
1719

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

2628
directory_node_id: Optional[int] = None
2729

28-
email: Optional[str] = None
29-
3030
external_directory_node_id: Optional[str] = None
3131

3232
provenance: Optional[str] = None

src/cloudflare/types/email_security/settings/impersonation_registry_list_response.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class ImpersonationRegistryListResponse(BaseModel):
1313

1414
created_at: datetime
1515

16+
email: str
17+
1618
is_email_regex: bool
1719

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

2628
directory_node_id: Optional[int] = None
2729

28-
email: Optional[str] = None
29-
3030
external_directory_node_id: Optional[str] = None
3131

3232
provenance: Optional[str] = None

0 commit comments

Comments
 (0)