Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 7, 2024
1 parent 89bb6c5 commit 32e92cf
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 331 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1275
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-66b404214530cc73c44f34f297dad6bc8da0645b63e61d9d4fcbeb301e127e65.yml
configured_endpoints: 1274
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6ad087215145bdd87a8fb698a148f42cf8f61d66010b60edb5e4842345953810.yml
4 changes: 1 addition & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1571,17 +1571,15 @@ from cloudflare.types.custom_nameservers import (
CustomNameserverDeleteResponse,
CustomNameserverAvailabiltyResponse,
CustomNameserverGetResponse,
CustomNameserverVerifyResponse,
)
```

Methods:

- <code title="post /accounts/{account_id}/custom_ns">client.custom_nameservers.<a href="./src/cloudflare/resources/custom_nameservers.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/custom_nameservers/custom_nameserver_create_params.py">params</a>) -> <a href="./src/cloudflare/types/custom_nameservers/custom_nameserver.py">CustomNameserver</a></code>
- <code title="post /accounts/{account_id}/custom_ns">client.custom_nameservers.<a href="./src/cloudflare/resources/custom_nameservers.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/custom_nameservers/custom_nameserver_create_params.py">params</a>) -> <a href="./src/cloudflare/types/custom_nameservers/custom_nameserver.py">Optional</a></code>
- <code title="delete /accounts/{account_id}/custom_ns/{custom_ns_id}">client.custom_nameservers.<a href="./src/cloudflare/resources/custom_nameservers.py">delete</a>(custom_ns_id, \*, account_id) -> <a href="./src/cloudflare/types/custom_nameservers/custom_nameserver_delete_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/custom_ns/availability">client.custom_nameservers.<a href="./src/cloudflare/resources/custom_nameservers.py">availabilty</a>(\*, account_id) -> <a href="./src/cloudflare/types/custom_nameservers/custom_nameserver_availabilty_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/custom_ns">client.custom_nameservers.<a href="./src/cloudflare/resources/custom_nameservers.py">get</a>(\*, account_id) -> <a href="./src/cloudflare/types/custom_nameservers/custom_nameserver_get_response.py">Optional</a></code>
- <code title="post /accounts/{account_id}/custom_ns/verify">client.custom_nameservers.<a href="./src/cloudflare/resources/custom_nameservers.py">verify</a>(\*, account_id, \*\*<a href="src/cloudflare/types/custom_nameservers/custom_nameserver_verify_params.py">params</a>) -> <a href="./src/cloudflare/types/custom_nameservers/custom_nameserver_verify_response.py">Optional</a></code>

# DNS

Expand Down
157 changes: 26 additions & 131 deletions src/cloudflare/resources/custom_nameservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, Type, Optional, cast
from typing import Type, Optional, cast

import httpx

Expand All @@ -23,11 +23,10 @@
from .._base_client import (
make_request_options,
)
from ..types.custom_nameservers import custom_nameserver_create_params, custom_nameserver_verify_params
from ..types.custom_nameservers import custom_nameserver_create_params
from ..types.custom_nameservers.custom_nameserver import CustomNameserver
from ..types.custom_nameservers.custom_nameserver_get_response import CustomNameserverGetResponse
from ..types.custom_nameservers.custom_nameserver_delete_response import CustomNameserverDeleteResponse
from ..types.custom_nameservers.custom_nameserver_verify_response import CustomNameserverVerifyResponse
from ..types.custom_nameservers.custom_nameserver_availabilty_response import CustomNameserverAvailabiltyResponse

__all__ = ["CustomNameserversResource", "AsyncCustomNameserversResource"]
Expand All @@ -54,7 +53,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> CustomNameserver:
) -> Optional[CustomNameserver]:
"""
Add Account Custom Nameserver
Expand Down Expand Up @@ -89,9 +88,9 @@ def create(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[CustomNameserver]._unwrapper,
post_parser=ResultWrapper[Optional[CustomNameserver]]._unwrapper,
),
cast_to=cast(Type[CustomNameserver], ResultWrapper[CustomNameserver]),
cast_to=cast(Type[Optional[CustomNameserver]], ResultWrapper[CustomNameserver]),
)

def delete(
Expand Down Expand Up @@ -126,21 +125,16 @@ def delete(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not custom_ns_id:
raise ValueError(f"Expected a non-empty value for `custom_ns_id` but received {custom_ns_id!r}")
return cast(
Optional[CustomNameserverDeleteResponse],
self._delete(
f"/accounts/{account_id}/custom_ns/{custom_ns_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CustomNameserverDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[CustomNameserverDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return self._delete(
f"/accounts/{account_id}/custom_ns/{custom_ns_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CustomNameserverDeleteResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[CustomNameserverDeleteResponse]], ResultWrapper[CustomNameserverDeleteResponse]),
)

def availabilty(
Expand Down Expand Up @@ -223,47 +217,6 @@ def get(
cast_to=cast(Type[Optional[CustomNameserverGetResponse]], ResultWrapper[CustomNameserverGetResponse]),
)

def verify(
self,
*,
account_id: str,
body: object,
# 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,
) -> Optional[CustomNameserverVerifyResponse]:
"""
Verify Account Custom Nameserver Glue Records
Args:
account_id: Account identifier tag.
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
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._post(
f"/accounts/{account_id}/custom_ns/verify",
body=maybe_transform(body, custom_nameserver_verify_params.CustomNameserverVerifyParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CustomNameserverVerifyResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[CustomNameserverVerifyResponse]], ResultWrapper[CustomNameserverVerifyResponse]),
)


class AsyncCustomNameserversResource(AsyncAPIResource):
@cached_property
Expand All @@ -286,7 +239,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> CustomNameserver:
) -> Optional[CustomNameserver]:
"""
Add Account Custom Nameserver
Expand Down Expand Up @@ -321,9 +274,9 @@ async def create(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[CustomNameserver]._unwrapper,
post_parser=ResultWrapper[Optional[CustomNameserver]]._unwrapper,
),
cast_to=cast(Type[CustomNameserver], ResultWrapper[CustomNameserver]),
cast_to=cast(Type[Optional[CustomNameserver]], ResultWrapper[CustomNameserver]),
)

async def delete(
Expand Down Expand Up @@ -358,21 +311,16 @@ async def delete(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not custom_ns_id:
raise ValueError(f"Expected a non-empty value for `custom_ns_id` but received {custom_ns_id!r}")
return cast(
Optional[CustomNameserverDeleteResponse],
await self._delete(
f"/accounts/{account_id}/custom_ns/{custom_ns_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CustomNameserverDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[CustomNameserverDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._delete(
f"/accounts/{account_id}/custom_ns/{custom_ns_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CustomNameserverDeleteResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[CustomNameserverDeleteResponse]], ResultWrapper[CustomNameserverDeleteResponse]),
)

async def availabilty(
Expand Down Expand Up @@ -455,47 +403,6 @@ async def get(
cast_to=cast(Type[Optional[CustomNameserverGetResponse]], ResultWrapper[CustomNameserverGetResponse]),
)

async def verify(
self,
*,
account_id: str,
body: object,
# 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,
) -> Optional[CustomNameserverVerifyResponse]:
"""
Verify Account Custom Nameserver Glue Records
Args:
account_id: Account identifier tag.
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
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._post(
f"/accounts/{account_id}/custom_ns/verify",
body=await async_maybe_transform(body, custom_nameserver_verify_params.CustomNameserverVerifyParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CustomNameserverVerifyResponse]]._unwrapper,
),
cast_to=cast(Type[Optional[CustomNameserverVerifyResponse]], ResultWrapper[CustomNameserverVerifyResponse]),
)


class CustomNameserversResourceWithRawResponse:
def __init__(self, custom_nameservers: CustomNameserversResource) -> None:
Expand All @@ -513,9 +420,6 @@ def __init__(self, custom_nameservers: CustomNameserversResource) -> None:
self.get = to_raw_response_wrapper(
custom_nameservers.get,
)
self.verify = to_raw_response_wrapper(
custom_nameservers.verify,
)


class AsyncCustomNameserversResourceWithRawResponse:
Expand All @@ -534,9 +438,6 @@ def __init__(self, custom_nameservers: AsyncCustomNameserversResource) -> None:
self.get = async_to_raw_response_wrapper(
custom_nameservers.get,
)
self.verify = async_to_raw_response_wrapper(
custom_nameservers.verify,
)


class CustomNameserversResourceWithStreamingResponse:
Expand All @@ -555,9 +456,6 @@ def __init__(self, custom_nameservers: CustomNameserversResource) -> None:
self.get = to_streamed_response_wrapper(
custom_nameservers.get,
)
self.verify = to_streamed_response_wrapper(
custom_nameservers.verify,
)


class AsyncCustomNameserversResourceWithStreamingResponse:
Expand All @@ -576,6 +474,3 @@ def __init__(self, custom_nameservers: AsyncCustomNameserversResource) -> None:
self.get = async_to_streamed_response_wrapper(
custom_nameservers.get,
)
self.verify = async_to_streamed_response_wrapper(
custom_nameservers.verify,
)
Loading

0 comments on commit 32e92cf

Please sign in to comment.