mirror of
https://github.com/cloudflare/cloudflare-python.git
synced 2026-01-16 23:01:03 +00:00
feat(dns): split account and zone DNS settings
This commit is contained in:
parent
9d3d8eca6f
commit
3b17a90f6f
21 changed files with 1 additions and 1808 deletions
|
|
@ -1,2 +1,2 @@
|
|||
configured_endpoints: 1572
|
||||
configured_endpoints: 1567
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-49794d21f9c5b1d528a53fc9c10d5d9de6eed9bd412a262d1cad78fa453be1b4.yml
|
||||
|
|
|
|||
24
api.md
24
api.md
|
|
@ -1134,30 +1134,6 @@ Types:
|
|||
from cloudflare.types.dns import DNSSetting
|
||||
```
|
||||
|
||||
### Zone
|
||||
|
||||
#### Views
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from cloudflare.types.dns.settings.zone import (
|
||||
ViewCreateResponse,
|
||||
ViewListResponse,
|
||||
ViewDeleteResponse,
|
||||
ViewEditResponse,
|
||||
ViewGetResponse,
|
||||
)
|
||||
```
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="post /accounts/{account_id}/dns_settings/views">client.dns.settings.zone.views.<a href="./src/cloudflare/resources/dns/settings/zone/views.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/dns/settings/zone/view_create_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/settings/zone/view_create_response.py">Optional[ViewCreateResponse]</a></code>
|
||||
- <code title="get /accounts/{account_id}/dns_settings/views">client.dns.settings.zone.views.<a href="./src/cloudflare/resources/dns/settings/zone/views.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/dns/settings/zone/view_list_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/settings/zone/view_list_response.py">SyncV4PagePaginationArray[ViewListResponse]</a></code>
|
||||
- <code title="delete /accounts/{account_id}/dns_settings/views/{view_id}">client.dns.settings.zone.views.<a href="./src/cloudflare/resources/dns/settings/zone/views.py">delete</a>(view_id, \*, account_id) -> <a href="./src/cloudflare/types/dns/settings/zone/view_delete_response.py">Optional[ViewDeleteResponse]</a></code>
|
||||
- <code title="patch /accounts/{account_id}/dns_settings/views/{view_id}">client.dns.settings.zone.views.<a href="./src/cloudflare/resources/dns/settings/zone/views.py">edit</a>(view_id, \*, account_id, \*\*<a href="src/cloudflare/types/dns/settings/zone/view_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/dns/settings/zone/view_edit_response.py">Optional[ViewEditResponse]</a></code>
|
||||
- <code title="get /accounts/{account_id}/dns_settings/views/{view_id}">client.dns.settings.zone.views.<a href="./src/cloudflare/resources/dns/settings/zone/views.py">get</a>(view_id, \*, account_id) -> <a href="./src/cloudflare/types/dns/settings/zone/view_get_response.py">Optional[ViewGetResponse]</a></code>
|
||||
|
||||
## Analytics
|
||||
|
||||
### Reports
|
||||
|
|
|
|||
|
|
@ -24,14 +24,6 @@ from .records import (
|
|||
RecordsResourceWithStreamingResponse,
|
||||
AsyncRecordsResourceWithStreamingResponse,
|
||||
)
|
||||
from .settings import (
|
||||
SettingsResource,
|
||||
AsyncSettingsResource,
|
||||
SettingsResourceWithRawResponse,
|
||||
AsyncSettingsResourceWithRawResponse,
|
||||
SettingsResourceWithStreamingResponse,
|
||||
AsyncSettingsResourceWithStreamingResponse,
|
||||
)
|
||||
from .analytics import (
|
||||
AnalyticsResource,
|
||||
AsyncAnalyticsResource,
|
||||
|
|
@ -62,12 +54,6 @@ __all__ = [
|
|||
"AsyncRecordsResourceWithRawResponse",
|
||||
"RecordsResourceWithStreamingResponse",
|
||||
"AsyncRecordsResourceWithStreamingResponse",
|
||||
"SettingsResource",
|
||||
"AsyncSettingsResource",
|
||||
"SettingsResourceWithRawResponse",
|
||||
"AsyncSettingsResourceWithRawResponse",
|
||||
"SettingsResourceWithStreamingResponse",
|
||||
"AsyncSettingsResourceWithStreamingResponse",
|
||||
"AnalyticsResource",
|
||||
"AsyncAnalyticsResource",
|
||||
"AnalyticsResourceWithRawResponse",
|
||||
|
|
|
|||
|
|
@ -20,14 +20,6 @@ from .records import (
|
|||
)
|
||||
from ..._compat import cached_property
|
||||
from ..._resource import SyncAPIResource, AsyncAPIResource
|
||||
from .settings.settings import (
|
||||
SettingsResource,
|
||||
AsyncSettingsResource,
|
||||
SettingsResourceWithRawResponse,
|
||||
AsyncSettingsResourceWithRawResponse,
|
||||
SettingsResourceWithStreamingResponse,
|
||||
AsyncSettingsResourceWithStreamingResponse,
|
||||
)
|
||||
from .analytics.analytics import (
|
||||
AnalyticsResource,
|
||||
AsyncAnalyticsResource,
|
||||
|
|
@ -57,10 +49,6 @@ class DNSResource(SyncAPIResource):
|
|||
def records(self) -> RecordsResource:
|
||||
return RecordsResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def settings(self) -> SettingsResource:
|
||||
return SettingsResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def analytics(self) -> AnalyticsResource:
|
||||
return AnalyticsResource(self._client)
|
||||
|
|
@ -98,10 +86,6 @@ class AsyncDNSResource(AsyncAPIResource):
|
|||
def records(self) -> AsyncRecordsResource:
|
||||
return AsyncRecordsResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def settings(self) -> AsyncSettingsResource:
|
||||
return AsyncSettingsResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def analytics(self) -> AsyncAnalyticsResource:
|
||||
return AsyncAnalyticsResource(self._client)
|
||||
|
|
@ -142,10 +126,6 @@ class DNSResourceWithRawResponse:
|
|||
def records(self) -> RecordsResourceWithRawResponse:
|
||||
return RecordsResourceWithRawResponse(self._dns.records)
|
||||
|
||||
@cached_property
|
||||
def settings(self) -> SettingsResourceWithRawResponse:
|
||||
return SettingsResourceWithRawResponse(self._dns.settings)
|
||||
|
||||
@cached_property
|
||||
def analytics(self) -> AnalyticsResourceWithRawResponse:
|
||||
return AnalyticsResourceWithRawResponse(self._dns.analytics)
|
||||
|
|
@ -167,10 +147,6 @@ class AsyncDNSResourceWithRawResponse:
|
|||
def records(self) -> AsyncRecordsResourceWithRawResponse:
|
||||
return AsyncRecordsResourceWithRawResponse(self._dns.records)
|
||||
|
||||
@cached_property
|
||||
def settings(self) -> AsyncSettingsResourceWithRawResponse:
|
||||
return AsyncSettingsResourceWithRawResponse(self._dns.settings)
|
||||
|
||||
@cached_property
|
||||
def analytics(self) -> AsyncAnalyticsResourceWithRawResponse:
|
||||
return AsyncAnalyticsResourceWithRawResponse(self._dns.analytics)
|
||||
|
|
@ -192,10 +168,6 @@ class DNSResourceWithStreamingResponse:
|
|||
def records(self) -> RecordsResourceWithStreamingResponse:
|
||||
return RecordsResourceWithStreamingResponse(self._dns.records)
|
||||
|
||||
@cached_property
|
||||
def settings(self) -> SettingsResourceWithStreamingResponse:
|
||||
return SettingsResourceWithStreamingResponse(self._dns.settings)
|
||||
|
||||
@cached_property
|
||||
def analytics(self) -> AnalyticsResourceWithStreamingResponse:
|
||||
return AnalyticsResourceWithStreamingResponse(self._dns.analytics)
|
||||
|
|
@ -217,10 +189,6 @@ class AsyncDNSResourceWithStreamingResponse:
|
|||
def records(self) -> AsyncRecordsResourceWithStreamingResponse:
|
||||
return AsyncRecordsResourceWithStreamingResponse(self._dns.records)
|
||||
|
||||
@cached_property
|
||||
def settings(self) -> AsyncSettingsResourceWithStreamingResponse:
|
||||
return AsyncSettingsResourceWithStreamingResponse(self._dns.settings)
|
||||
|
||||
@cached_property
|
||||
def analytics(self) -> AsyncAnalyticsResourceWithStreamingResponse:
|
||||
return AsyncAnalyticsResourceWithStreamingResponse(self._dns.analytics)
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from .zone import (
|
||||
ZoneResource,
|
||||
AsyncZoneResource,
|
||||
ZoneResourceWithRawResponse,
|
||||
AsyncZoneResourceWithRawResponse,
|
||||
ZoneResourceWithStreamingResponse,
|
||||
AsyncZoneResourceWithStreamingResponse,
|
||||
)
|
||||
from .settings import (
|
||||
SettingsResource,
|
||||
AsyncSettingsResource,
|
||||
SettingsResourceWithRawResponse,
|
||||
AsyncSettingsResourceWithRawResponse,
|
||||
SettingsResourceWithStreamingResponse,
|
||||
AsyncSettingsResourceWithStreamingResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ZoneResource",
|
||||
"AsyncZoneResource",
|
||||
"ZoneResourceWithRawResponse",
|
||||
"AsyncZoneResourceWithRawResponse",
|
||||
"ZoneResourceWithStreamingResponse",
|
||||
"AsyncZoneResourceWithStreamingResponse",
|
||||
"SettingsResource",
|
||||
"AsyncSettingsResource",
|
||||
"SettingsResourceWithRawResponse",
|
||||
"AsyncSettingsResourceWithRawResponse",
|
||||
"SettingsResourceWithStreamingResponse",
|
||||
"AsyncSettingsResourceWithStreamingResponse",
|
||||
]
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .zone.zone import (
|
||||
ZoneResource,
|
||||
AsyncZoneResource,
|
||||
ZoneResourceWithRawResponse,
|
||||
AsyncZoneResourceWithRawResponse,
|
||||
ZoneResourceWithStreamingResponse,
|
||||
AsyncZoneResourceWithStreamingResponse,
|
||||
)
|
||||
from ...._compat import cached_property
|
||||
from ...._resource import SyncAPIResource, AsyncAPIResource
|
||||
|
||||
__all__ = ["SettingsResource", "AsyncSettingsResource"]
|
||||
|
||||
|
||||
class SettingsResource(SyncAPIResource):
|
||||
@cached_property
|
||||
def zone(self) -> ZoneResource:
|
||||
return ZoneResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> SettingsResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return SettingsResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> SettingsResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return SettingsResourceWithStreamingResponse(self)
|
||||
|
||||
|
||||
class AsyncSettingsResource(AsyncAPIResource):
|
||||
@cached_property
|
||||
def zone(self) -> AsyncZoneResource:
|
||||
return AsyncZoneResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncSettingsResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncSettingsResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return AsyncSettingsResourceWithStreamingResponse(self)
|
||||
|
||||
|
||||
class SettingsResourceWithRawResponse:
|
||||
def __init__(self, settings: SettingsResource) -> None:
|
||||
self._settings = settings
|
||||
|
||||
@cached_property
|
||||
def zone(self) -> ZoneResourceWithRawResponse:
|
||||
return ZoneResourceWithRawResponse(self._settings.zone)
|
||||
|
||||
|
||||
class AsyncSettingsResourceWithRawResponse:
|
||||
def __init__(self, settings: AsyncSettingsResource) -> None:
|
||||
self._settings = settings
|
||||
|
||||
@cached_property
|
||||
def zone(self) -> AsyncZoneResourceWithRawResponse:
|
||||
return AsyncZoneResourceWithRawResponse(self._settings.zone)
|
||||
|
||||
|
||||
class SettingsResourceWithStreamingResponse:
|
||||
def __init__(self, settings: SettingsResource) -> None:
|
||||
self._settings = settings
|
||||
|
||||
@cached_property
|
||||
def zone(self) -> ZoneResourceWithStreamingResponse:
|
||||
return ZoneResourceWithStreamingResponse(self._settings.zone)
|
||||
|
||||
|
||||
class AsyncSettingsResourceWithStreamingResponse:
|
||||
def __init__(self, settings: AsyncSettingsResource) -> None:
|
||||
self._settings = settings
|
||||
|
||||
@cached_property
|
||||
def zone(self) -> AsyncZoneResourceWithStreamingResponse:
|
||||
return AsyncZoneResourceWithStreamingResponse(self._settings.zone)
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from .zone import (
|
||||
ZoneResource,
|
||||
AsyncZoneResource,
|
||||
ZoneResourceWithRawResponse,
|
||||
AsyncZoneResourceWithRawResponse,
|
||||
ZoneResourceWithStreamingResponse,
|
||||
AsyncZoneResourceWithStreamingResponse,
|
||||
)
|
||||
from .views import (
|
||||
ViewsResource,
|
||||
AsyncViewsResource,
|
||||
ViewsResourceWithRawResponse,
|
||||
AsyncViewsResourceWithRawResponse,
|
||||
ViewsResourceWithStreamingResponse,
|
||||
AsyncViewsResourceWithStreamingResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ViewsResource",
|
||||
"AsyncViewsResource",
|
||||
"ViewsResourceWithRawResponse",
|
||||
"AsyncViewsResourceWithRawResponse",
|
||||
"ViewsResourceWithStreamingResponse",
|
||||
"AsyncViewsResourceWithStreamingResponse",
|
||||
"ZoneResource",
|
||||
"AsyncZoneResource",
|
||||
"ZoneResourceWithRawResponse",
|
||||
"AsyncZoneResourceWithRawResponse",
|
||||
"ZoneResourceWithStreamingResponse",
|
||||
"AsyncZoneResourceWithStreamingResponse",
|
||||
]
|
||||
|
|
@ -1,705 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Type, Optional, cast
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
||||
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
||||
from ....._utils import (
|
||||
maybe_transform,
|
||||
async_maybe_transform,
|
||||
)
|
||||
from ....._compat import cached_property
|
||||
from ....._resource import SyncAPIResource, AsyncAPIResource
|
||||
from ....._response import (
|
||||
to_raw_response_wrapper,
|
||||
to_streamed_response_wrapper,
|
||||
async_to_raw_response_wrapper,
|
||||
async_to_streamed_response_wrapper,
|
||||
)
|
||||
from ....._wrappers import ResultWrapper
|
||||
from .....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
|
||||
from ....._base_client import AsyncPaginator, make_request_options
|
||||
from .....types.dns.settings.zone import view_edit_params, view_list_params, view_create_params
|
||||
from .....types.dns.settings.zone.view_get_response import ViewGetResponse
|
||||
from .....types.dns.settings.zone.view_edit_response import ViewEditResponse
|
||||
from .....types.dns.settings.zone.view_list_response import ViewListResponse
|
||||
from .....types.dns.settings.zone.view_create_response import ViewCreateResponse
|
||||
from .....types.dns.settings.zone.view_delete_response import ViewDeleteResponse
|
||||
|
||||
__all__ = ["ViewsResource", "AsyncViewsResource"]
|
||||
|
||||
|
||||
class ViewsResource(SyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> ViewsResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return ViewsResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> ViewsResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return ViewsResourceWithStreamingResponse(self)
|
||||
|
||||
def create(
|
||||
self,
|
||||
*,
|
||||
account_id: str,
|
||||
name: str,
|
||||
zones: List[str],
|
||||
# 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[ViewCreateResponse]:
|
||||
"""
|
||||
Create Internal DNS View for an account
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
name: The name of the view.
|
||||
|
||||
zones: The list of zones linked to this view.
|
||||
|
||||
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}/dns_settings/views",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"name": name,
|
||||
"zones": zones,
|
||||
},
|
||||
view_create_params.ViewCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewCreateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewCreateResponse]], ResultWrapper[ViewCreateResponse]),
|
||||
)
|
||||
|
||||
def list(
|
||||
self,
|
||||
*,
|
||||
account_id: str,
|
||||
direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
||||
match: Literal["any", "all"] | NotGiven = NOT_GIVEN,
|
||||
name: view_list_params.Name | NotGiven = NOT_GIVEN,
|
||||
order: Literal["name", "created_on", "modified_on"] | NotGiven = NOT_GIVEN,
|
||||
page: float | NotGiven = NOT_GIVEN,
|
||||
per_page: float | NotGiven = NOT_GIVEN,
|
||||
zone_id: str | NotGiven = NOT_GIVEN,
|
||||
zone_name: str | 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,
|
||||
) -> SyncV4PagePaginationArray[ViewListResponse]:
|
||||
"""
|
||||
List DNS Internal Views for an Account
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
direction: Direction to order DNS views in.
|
||||
|
||||
match: Whether to match all search requirements or at least one (any). If set to `all`,
|
||||
acts like a logical AND between filters. If set to `any`, acts like a logical OR
|
||||
instead.
|
||||
|
||||
order: Field to order DNS views by.
|
||||
|
||||
page: Page number of paginated results.
|
||||
|
||||
per_page: Number of DNS views per page.
|
||||
|
||||
zone_id: A zone ID that exists in the zones list for the view.
|
||||
|
||||
zone_name: A zone name that exists in the zones list for the view.
|
||||
|
||||
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._get_api_list(
|
||||
f"/accounts/{account_id}/dns_settings/views",
|
||||
page=SyncV4PagePaginationArray[ViewListResponse],
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
query=maybe_transform(
|
||||
{
|
||||
"direction": direction,
|
||||
"match": match,
|
||||
"name": name,
|
||||
"order": order,
|
||||
"page": page,
|
||||
"per_page": per_page,
|
||||
"zone_id": zone_id,
|
||||
"zone_name": zone_name,
|
||||
},
|
||||
view_list_params.ViewListParams,
|
||||
),
|
||||
),
|
||||
model=ViewListResponse,
|
||||
)
|
||||
|
||||
def delete(
|
||||
self,
|
||||
view_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
# 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[ViewDeleteResponse]:
|
||||
"""
|
||||
Delete an existing Internal DNS View
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
view_id: 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
|
||||
"""
|
||||
if not account_id:
|
||||
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
|
||||
if not view_id:
|
||||
raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}")
|
||||
return self._delete(
|
||||
f"/accounts/{account_id}/dns_settings/views/{view_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewDeleteResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewDeleteResponse]], ResultWrapper[ViewDeleteResponse]),
|
||||
)
|
||||
|
||||
def edit(
|
||||
self,
|
||||
view_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
name: str | NotGiven = NOT_GIVEN,
|
||||
zones: List[str] | 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,
|
||||
) -> Optional[ViewEditResponse]:
|
||||
"""
|
||||
Update an existing Internal DNS View
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
view_id: Identifier
|
||||
|
||||
name: The name of the view.
|
||||
|
||||
zones: The list of zones linked to this view.
|
||||
|
||||
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}")
|
||||
if not view_id:
|
||||
raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}")
|
||||
return self._patch(
|
||||
f"/accounts/{account_id}/dns_settings/views/{view_id}",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"name": name,
|
||||
"zones": zones,
|
||||
},
|
||||
view_edit_params.ViewEditParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewEditResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewEditResponse]], ResultWrapper[ViewEditResponse]),
|
||||
)
|
||||
|
||||
def get(
|
||||
self,
|
||||
view_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
# 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[ViewGetResponse]:
|
||||
"""
|
||||
Get DNS Internal View
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
view_id: 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
|
||||
"""
|
||||
if not account_id:
|
||||
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
|
||||
if not view_id:
|
||||
raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}")
|
||||
return self._get(
|
||||
f"/accounts/{account_id}/dns_settings/views/{view_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewGetResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewGetResponse]], ResultWrapper[ViewGetResponse]),
|
||||
)
|
||||
|
||||
|
||||
class AsyncViewsResource(AsyncAPIResource):
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncViewsResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncViewsResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncViewsResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return AsyncViewsResourceWithStreamingResponse(self)
|
||||
|
||||
async def create(
|
||||
self,
|
||||
*,
|
||||
account_id: str,
|
||||
name: str,
|
||||
zones: List[str],
|
||||
# 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[ViewCreateResponse]:
|
||||
"""
|
||||
Create Internal DNS View for an account
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
name: The name of the view.
|
||||
|
||||
zones: The list of zones linked to this view.
|
||||
|
||||
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}/dns_settings/views",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"name": name,
|
||||
"zones": zones,
|
||||
},
|
||||
view_create_params.ViewCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewCreateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewCreateResponse]], ResultWrapper[ViewCreateResponse]),
|
||||
)
|
||||
|
||||
def list(
|
||||
self,
|
||||
*,
|
||||
account_id: str,
|
||||
direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
|
||||
match: Literal["any", "all"] | NotGiven = NOT_GIVEN,
|
||||
name: view_list_params.Name | NotGiven = NOT_GIVEN,
|
||||
order: Literal["name", "created_on", "modified_on"] | NotGiven = NOT_GIVEN,
|
||||
page: float | NotGiven = NOT_GIVEN,
|
||||
per_page: float | NotGiven = NOT_GIVEN,
|
||||
zone_id: str | NotGiven = NOT_GIVEN,
|
||||
zone_name: str | 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,
|
||||
) -> AsyncPaginator[ViewListResponse, AsyncV4PagePaginationArray[ViewListResponse]]:
|
||||
"""
|
||||
List DNS Internal Views for an Account
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
direction: Direction to order DNS views in.
|
||||
|
||||
match: Whether to match all search requirements or at least one (any). If set to `all`,
|
||||
acts like a logical AND between filters. If set to `any`, acts like a logical OR
|
||||
instead.
|
||||
|
||||
order: Field to order DNS views by.
|
||||
|
||||
page: Page number of paginated results.
|
||||
|
||||
per_page: Number of DNS views per page.
|
||||
|
||||
zone_id: A zone ID that exists in the zones list for the view.
|
||||
|
||||
zone_name: A zone name that exists in the zones list for the view.
|
||||
|
||||
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._get_api_list(
|
||||
f"/accounts/{account_id}/dns_settings/views",
|
||||
page=AsyncV4PagePaginationArray[ViewListResponse],
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
query=maybe_transform(
|
||||
{
|
||||
"direction": direction,
|
||||
"match": match,
|
||||
"name": name,
|
||||
"order": order,
|
||||
"page": page,
|
||||
"per_page": per_page,
|
||||
"zone_id": zone_id,
|
||||
"zone_name": zone_name,
|
||||
},
|
||||
view_list_params.ViewListParams,
|
||||
),
|
||||
),
|
||||
model=ViewListResponse,
|
||||
)
|
||||
|
||||
async def delete(
|
||||
self,
|
||||
view_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
# 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[ViewDeleteResponse]:
|
||||
"""
|
||||
Delete an existing Internal DNS View
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
view_id: 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
|
||||
"""
|
||||
if not account_id:
|
||||
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
|
||||
if not view_id:
|
||||
raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}")
|
||||
return await self._delete(
|
||||
f"/accounts/{account_id}/dns_settings/views/{view_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewDeleteResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewDeleteResponse]], ResultWrapper[ViewDeleteResponse]),
|
||||
)
|
||||
|
||||
async def edit(
|
||||
self,
|
||||
view_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
name: str | NotGiven = NOT_GIVEN,
|
||||
zones: List[str] | 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,
|
||||
) -> Optional[ViewEditResponse]:
|
||||
"""
|
||||
Update an existing Internal DNS View
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
view_id: Identifier
|
||||
|
||||
name: The name of the view.
|
||||
|
||||
zones: The list of zones linked to this view.
|
||||
|
||||
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}")
|
||||
if not view_id:
|
||||
raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}")
|
||||
return await self._patch(
|
||||
f"/accounts/{account_id}/dns_settings/views/{view_id}",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"name": name,
|
||||
"zones": zones,
|
||||
},
|
||||
view_edit_params.ViewEditParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewEditResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewEditResponse]], ResultWrapper[ViewEditResponse]),
|
||||
)
|
||||
|
||||
async def get(
|
||||
self,
|
||||
view_id: str,
|
||||
*,
|
||||
account_id: str,
|
||||
# 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[ViewGetResponse]:
|
||||
"""
|
||||
Get DNS Internal View
|
||||
|
||||
Args:
|
||||
account_id: Identifier
|
||||
|
||||
view_id: 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
|
||||
"""
|
||||
if not account_id:
|
||||
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
|
||||
if not view_id:
|
||||
raise ValueError(f"Expected a non-empty value for `view_id` but received {view_id!r}")
|
||||
return await self._get(
|
||||
f"/accounts/{account_id}/dns_settings/views/{view_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ViewGetResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Optional[ViewGetResponse]], ResultWrapper[ViewGetResponse]),
|
||||
)
|
||||
|
||||
|
||||
class ViewsResourceWithRawResponse:
|
||||
def __init__(self, views: ViewsResource) -> None:
|
||||
self._views = views
|
||||
|
||||
self.create = to_raw_response_wrapper(
|
||||
views.create,
|
||||
)
|
||||
self.list = to_raw_response_wrapper(
|
||||
views.list,
|
||||
)
|
||||
self.delete = to_raw_response_wrapper(
|
||||
views.delete,
|
||||
)
|
||||
self.edit = to_raw_response_wrapper(
|
||||
views.edit,
|
||||
)
|
||||
self.get = to_raw_response_wrapper(
|
||||
views.get,
|
||||
)
|
||||
|
||||
|
||||
class AsyncViewsResourceWithRawResponse:
|
||||
def __init__(self, views: AsyncViewsResource) -> None:
|
||||
self._views = views
|
||||
|
||||
self.create = async_to_raw_response_wrapper(
|
||||
views.create,
|
||||
)
|
||||
self.list = async_to_raw_response_wrapper(
|
||||
views.list,
|
||||
)
|
||||
self.delete = async_to_raw_response_wrapper(
|
||||
views.delete,
|
||||
)
|
||||
self.edit = async_to_raw_response_wrapper(
|
||||
views.edit,
|
||||
)
|
||||
self.get = async_to_raw_response_wrapper(
|
||||
views.get,
|
||||
)
|
||||
|
||||
|
||||
class ViewsResourceWithStreamingResponse:
|
||||
def __init__(self, views: ViewsResource) -> None:
|
||||
self._views = views
|
||||
|
||||
self.create = to_streamed_response_wrapper(
|
||||
views.create,
|
||||
)
|
||||
self.list = to_streamed_response_wrapper(
|
||||
views.list,
|
||||
)
|
||||
self.delete = to_streamed_response_wrapper(
|
||||
views.delete,
|
||||
)
|
||||
self.edit = to_streamed_response_wrapper(
|
||||
views.edit,
|
||||
)
|
||||
self.get = to_streamed_response_wrapper(
|
||||
views.get,
|
||||
)
|
||||
|
||||
|
||||
class AsyncViewsResourceWithStreamingResponse:
|
||||
def __init__(self, views: AsyncViewsResource) -> None:
|
||||
self._views = views
|
||||
|
||||
self.create = async_to_streamed_response_wrapper(
|
||||
views.create,
|
||||
)
|
||||
self.list = async_to_streamed_response_wrapper(
|
||||
views.list,
|
||||
)
|
||||
self.delete = async_to_streamed_response_wrapper(
|
||||
views.delete,
|
||||
)
|
||||
self.edit = async_to_streamed_response_wrapper(
|
||||
views.edit,
|
||||
)
|
||||
self.get = async_to_streamed_response_wrapper(
|
||||
views.get,
|
||||
)
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .views import (
|
||||
ViewsResource,
|
||||
AsyncViewsResource,
|
||||
ViewsResourceWithRawResponse,
|
||||
AsyncViewsResourceWithRawResponse,
|
||||
ViewsResourceWithStreamingResponse,
|
||||
AsyncViewsResourceWithStreamingResponse,
|
||||
)
|
||||
from ....._compat import cached_property
|
||||
from ....._resource import SyncAPIResource, AsyncAPIResource
|
||||
|
||||
__all__ = ["ZoneResource", "AsyncZoneResource"]
|
||||
|
||||
|
||||
class ZoneResource(SyncAPIResource):
|
||||
@cached_property
|
||||
def views(self) -> ViewsResource:
|
||||
return ViewsResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> ZoneResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return ZoneResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> ZoneResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return ZoneResourceWithStreamingResponse(self)
|
||||
|
||||
|
||||
class AsyncZoneResource(AsyncAPIResource):
|
||||
@cached_property
|
||||
def views(self) -> AsyncViewsResource:
|
||||
return AsyncViewsResource(self._client)
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncZoneResourceWithRawResponse:
|
||||
"""
|
||||
This property can be used as a prefix for any HTTP method call to return
|
||||
the raw response object instead of the parsed content.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
|
||||
"""
|
||||
return AsyncZoneResourceWithRawResponse(self)
|
||||
|
||||
@cached_property
|
||||
def with_streaming_response(self) -> AsyncZoneResourceWithStreamingResponse:
|
||||
"""
|
||||
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
||||
|
||||
For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
|
||||
"""
|
||||
return AsyncZoneResourceWithStreamingResponse(self)
|
||||
|
||||
|
||||
class ZoneResourceWithRawResponse:
|
||||
def __init__(self, zone: ZoneResource) -> None:
|
||||
self._zone = zone
|
||||
|
||||
@cached_property
|
||||
def views(self) -> ViewsResourceWithRawResponse:
|
||||
return ViewsResourceWithRawResponse(self._zone.views)
|
||||
|
||||
|
||||
class AsyncZoneResourceWithRawResponse:
|
||||
def __init__(self, zone: AsyncZoneResource) -> None:
|
||||
self._zone = zone
|
||||
|
||||
@cached_property
|
||||
def views(self) -> AsyncViewsResourceWithRawResponse:
|
||||
return AsyncViewsResourceWithRawResponse(self._zone.views)
|
||||
|
||||
|
||||
class ZoneResourceWithStreamingResponse:
|
||||
def __init__(self, zone: ZoneResource) -> None:
|
||||
self._zone = zone
|
||||
|
||||
@cached_property
|
||||
def views(self) -> ViewsResourceWithStreamingResponse:
|
||||
return ViewsResourceWithStreamingResponse(self._zone.views)
|
||||
|
||||
|
||||
class AsyncZoneResourceWithStreamingResponse:
|
||||
def __init__(self, zone: AsyncZoneResource) -> None:
|
||||
self._zone = zone
|
||||
|
||||
@cached_property
|
||||
def views(self) -> AsyncViewsResourceWithStreamingResponse:
|
||||
return AsyncViewsResourceWithStreamingResponse(self._zone.views)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .view_edit_params import ViewEditParams as ViewEditParams
|
||||
from .view_list_params import ViewListParams as ViewListParams
|
||||
from .view_get_response import ViewGetResponse as ViewGetResponse
|
||||
from .view_create_params import ViewCreateParams as ViewCreateParams
|
||||
from .view_edit_response import ViewEditResponse as ViewEditResponse
|
||||
from .view_list_response import ViewListResponse as ViewListResponse
|
||||
from .view_create_response import ViewCreateResponse as ViewCreateResponse
|
||||
from .view_delete_response import ViewDeleteResponse as ViewDeleteResponse
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List
|
||||
from typing_extensions import Required, TypedDict
|
||||
|
||||
__all__ = ["ViewCreateParams"]
|
||||
|
||||
|
||||
class ViewCreateParams(TypedDict, total=False):
|
||||
account_id: Required[str]
|
||||
"""Identifier"""
|
||||
|
||||
name: Required[str]
|
||||
"""The name of the view."""
|
||||
|
||||
zones: Required[List[str]]
|
||||
"""The list of zones linked to this view."""
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import List
|
||||
from datetime import datetime
|
||||
|
||||
from ....._models import BaseModel
|
||||
|
||||
__all__ = ["ViewCreateResponse"]
|
||||
|
||||
|
||||
class ViewCreateResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
created_time: datetime
|
||||
"""When the view was created."""
|
||||
|
||||
modified_time: datetime
|
||||
"""When the view was last modified."""
|
||||
|
||||
name: str
|
||||
"""The name of the view."""
|
||||
|
||||
zones: List[str]
|
||||
"""The list of zones linked to this view."""
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from ....._models import BaseModel
|
||||
|
||||
__all__ = ["ViewDeleteResponse"]
|
||||
|
||||
|
||||
class ViewDeleteResponse(BaseModel):
|
||||
id: Optional[str] = None
|
||||
"""Identifier"""
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List
|
||||
from typing_extensions import Required, TypedDict
|
||||
|
||||
__all__ = ["ViewEditParams"]
|
||||
|
||||
|
||||
class ViewEditParams(TypedDict, total=False):
|
||||
account_id: Required[str]
|
||||
"""Identifier"""
|
||||
|
||||
name: str
|
||||
"""The name of the view."""
|
||||
|
||||
zones: List[str]
|
||||
"""The list of zones linked to this view."""
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import List
|
||||
from datetime import datetime
|
||||
|
||||
from ....._models import BaseModel
|
||||
|
||||
__all__ = ["ViewEditResponse"]
|
||||
|
||||
|
||||
class ViewEditResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
created_time: datetime
|
||||
"""When the view was created."""
|
||||
|
||||
modified_time: datetime
|
||||
"""When the view was last modified."""
|
||||
|
||||
name: str
|
||||
"""The name of the view."""
|
||||
|
||||
zones: List[str]
|
||||
"""The list of zones linked to this view."""
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import List
|
||||
from datetime import datetime
|
||||
|
||||
from ....._models import BaseModel
|
||||
|
||||
__all__ = ["ViewGetResponse"]
|
||||
|
||||
|
||||
class ViewGetResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
created_time: datetime
|
||||
"""When the view was created."""
|
||||
|
||||
modified_time: datetime
|
||||
"""When the view was last modified."""
|
||||
|
||||
name: str
|
||||
"""The name of the view."""
|
||||
|
||||
zones: List[str]
|
||||
"""The list of zones linked to this view."""
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Literal, Required, TypedDict
|
||||
|
||||
__all__ = ["ViewListParams", "Name"]
|
||||
|
||||
|
||||
class ViewListParams(TypedDict, total=False):
|
||||
account_id: Required[str]
|
||||
"""Identifier"""
|
||||
|
||||
direction: Literal["asc", "desc"]
|
||||
"""Direction to order DNS views in."""
|
||||
|
||||
match: Literal["any", "all"]
|
||||
"""Whether to match all search requirements or at least one (any).
|
||||
|
||||
If set to `all`, acts like a logical AND between filters. If set to `any`, acts
|
||||
like a logical OR instead.
|
||||
"""
|
||||
|
||||
name: Name
|
||||
|
||||
order: Literal["name", "created_on", "modified_on"]
|
||||
"""Field to order DNS views by."""
|
||||
|
||||
page: float
|
||||
"""Page number of paginated results."""
|
||||
|
||||
per_page: float
|
||||
"""Number of DNS views per page."""
|
||||
|
||||
zone_id: str
|
||||
"""A zone ID that exists in the zones list for the view."""
|
||||
|
||||
zone_name: str
|
||||
"""A zone name that exists in the zones list for the view."""
|
||||
|
||||
|
||||
class Name(TypedDict, total=False):
|
||||
contains: str
|
||||
"""Substring of the DNS view name."""
|
||||
|
||||
endswith: str
|
||||
"""Suffix of the DNS view name."""
|
||||
|
||||
exact: str
|
||||
"""Exact value of the DNS view name."""
|
||||
|
||||
startswith: str
|
||||
"""Prefix of the DNS view name."""
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import List
|
||||
from datetime import datetime
|
||||
|
||||
from ....._models import BaseModel
|
||||
|
||||
__all__ = ["ViewListResponse"]
|
||||
|
||||
|
||||
class ViewListResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
created_time: datetime
|
||||
"""When the view was created."""
|
||||
|
||||
modified_time: datetime
|
||||
"""When the view was last modified."""
|
||||
|
||||
name: str
|
||||
"""The name of the view."""
|
||||
|
||||
zones: List[str]
|
||||
"""The list of zones linked to this view."""
|
||||
|
|
@ -1 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
|
@ -1 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
|
@ -1,545 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import pytest
|
||||
|
||||
from cloudflare import Cloudflare, AsyncCloudflare
|
||||
from tests.utils import assert_matches_type
|
||||
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
|
||||
from cloudflare.types.dns.settings.zone import (
|
||||
ViewGetResponse,
|
||||
ViewEditResponse,
|
||||
ViewListResponse,
|
||||
ViewCreateResponse,
|
||||
ViewDeleteResponse,
|
||||
)
|
||||
|
||||
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
|
||||
|
||||
|
||||
class TestViews:
|
||||
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
|
||||
|
||||
@parametrize
|
||||
def test_method_create(self, client: Cloudflare) -> None:
|
||||
view = client.dns.settings.zone.views.create(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
assert_matches_type(Optional[ViewCreateResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_create(self, client: Cloudflare) -> None:
|
||||
response = client.dns.settings.zone.views.with_raw_response.create(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewCreateResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_create(self, client: Cloudflare) -> None:
|
||||
with client.dns.settings.zone.views.with_streaming_response.create(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewCreateResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_create(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.create(
|
||||
account_id="",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_list(self, client: Cloudflare) -> None:
|
||||
view = client.dns.settings.zone.views.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(SyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
|
||||
view = client.dns.settings.zone.views.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
direction="asc",
|
||||
match="any",
|
||||
name={
|
||||
"contains": "view",
|
||||
"endswith": "ew",
|
||||
"exact": "my view",
|
||||
"startswith": "my",
|
||||
},
|
||||
order="name",
|
||||
page=1,
|
||||
per_page=5,
|
||||
zone_id="ae29bea30e2e427ba9cd8d78b628177b",
|
||||
zone_name="www.example.com",
|
||||
)
|
||||
assert_matches_type(SyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_list(self, client: Cloudflare) -> None:
|
||||
response = client.dns.settings.zone.views.with_raw_response.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = response.parse()
|
||||
assert_matches_type(SyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_list(self, client: Cloudflare) -> None:
|
||||
with client.dns.settings.zone.views.with_streaming_response.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = response.parse()
|
||||
assert_matches_type(SyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_list(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.list(
|
||||
account_id="",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_delete(self, client: Cloudflare) -> None:
|
||||
view = client.dns.settings.zone.views.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[ViewDeleteResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_delete(self, client: Cloudflare) -> None:
|
||||
response = client.dns.settings.zone.views.with_raw_response.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewDeleteResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_delete(self, client: Cloudflare) -> None:
|
||||
with client.dns.settings.zone.views.with_streaming_response.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewDeleteResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_delete(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `view_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.delete(
|
||||
view_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_edit(self, client: Cloudflare) -> None:
|
||||
view = client.dns.settings.zone.views.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
|
||||
view = client.dns.settings.zone.views.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_edit(self, client: Cloudflare) -> None:
|
||||
response = client.dns.settings.zone.views.with_raw_response.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_edit(self, client: Cloudflare) -> None:
|
||||
with client.dns.settings.zone.views.with_streaming_response.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_edit(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `view_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.edit(
|
||||
view_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_get(self, client: Cloudflare) -> None:
|
||||
view = client.dns.settings.zone.views.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[ViewGetResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_get(self, client: Cloudflare) -> None:
|
||||
response = client.dns.settings.zone.views.with_raw_response.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewGetResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_get(self, client: Cloudflare) -> None:
|
||||
with client.dns.settings.zone.views.with_streaming_response.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = response.parse()
|
||||
assert_matches_type(Optional[ViewGetResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
def test_path_params_get(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `view_id` but received ''"):
|
||||
client.dns.settings.zone.views.with_raw_response.get(
|
||||
view_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
|
||||
class TestAsyncViews:
|
||||
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
|
||||
view = await async_client.dns.settings.zone.views.create(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
assert_matches_type(Optional[ViewCreateResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.dns.settings.zone.views.with_raw_response.create(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewCreateResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.dns.settings.zone.views.with_streaming_response.create(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewCreateResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.create(
|
||||
account_id="",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
|
||||
view = await async_client.dns.settings.zone.views.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(AsyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
view = await async_client.dns.settings.zone.views.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
direction="asc",
|
||||
match="any",
|
||||
name={
|
||||
"contains": "view",
|
||||
"endswith": "ew",
|
||||
"exact": "my view",
|
||||
"startswith": "my",
|
||||
},
|
||||
order="name",
|
||||
page=1,
|
||||
per_page=5,
|
||||
zone_id="ae29bea30e2e427ba9cd8d78b628177b",
|
||||
zone_name="www.example.com",
|
||||
)
|
||||
assert_matches_type(AsyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.dns.settings.zone.views.with_raw_response.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = await response.parse()
|
||||
assert_matches_type(AsyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.dns.settings.zone.views.with_streaming_response.list(
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = await response.parse()
|
||||
assert_matches_type(AsyncV4PagePaginationArray[ViewListResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.list(
|
||||
account_id="",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
view = await async_client.dns.settings.zone.views.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[ViewDeleteResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.dns.settings.zone.views.with_raw_response.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewDeleteResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.dns.settings.zone.views.with_streaming_response.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewDeleteResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.delete(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `view_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.delete(
|
||||
view_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
view = await async_client.dns.settings.zone.views.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
view = await async_client.dns.settings.zone.views.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
name="my view",
|
||||
zones=["372e67954025e0ba6aaa6d586b9e0b59"],
|
||||
)
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.dns.settings.zone.views.with_raw_response.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.dns.settings.zone.views.with_streaming_response.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewEditResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.edit(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `view_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.edit(
|
||||
view_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
|
||||
view = await async_client.dns.settings.zone.views.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Optional[ViewGetResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.dns.settings.zone.views.with_raw_response.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewGetResponse], view, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.dns.settings.zone.views.with_streaming_response.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
view = await response.parse()
|
||||
assert_matches_type(Optional[ViewGetResponse], view, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
@parametrize
|
||||
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.get(
|
||||
view_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
account_id="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `view_id` but received ''"):
|
||||
await async_client.dns.settings.zone.views.with_raw_response.get(
|
||||
view_id="",
|
||||
account_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue