diff --git a/.stats.yml b/.stats.yml index 0dc472c0233..b1ee01299ac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml +configured_endpoints: 1335 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ac33a501d722d88a0ebf590d74e32c77066a57b327cb3a2fae156558b6e7b75c.yml diff --git a/api.md b/api.md index b961effc2c3..59465cfbc9f 100644 --- a/api.md +++ b/api.md @@ -3361,6 +3361,40 @@ Methods: # Addressing +## RegionalHostnames + +Types: + +```python +from cloudflare.types.addressing import ( + RegionalHostnameCreateResponse, + RegionalHostnameListResponse, + RegionalHostnameDeleteResponse, + RegionalHostnameEditResponse, + RegionalHostnameGetResponse, +) +``` + +Methods: + +- client.addressing.regional_hostnames.create(\*, zone_id, \*\*params) -> Optional +- client.addressing.regional_hostnames.list(\*, zone_id) -> SyncSinglePage[RegionalHostnameListResponse] +- client.addressing.regional_hostnames.delete(hostname, \*, zone_id) -> RegionalHostnameDeleteResponse +- client.addressing.regional_hostnames.edit(hostname, \*, zone_id, \*\*params) -> Optional +- client.addressing.regional_hostnames.get(hostname, \*, zone_id) -> Optional + +### Regions + +Types: + +```python +from cloudflare.types.addressing.regional_hostnames import RegionListResponse +``` + +Methods: + +- client.addressing.regional_hostnames.regions.list(\*, account_id) -> SyncSinglePage[RegionListResponse] + ## Services Types: @@ -3907,6 +3941,26 @@ Types: from cloudflare.types.magic_transit import HealthCheck, HealthCheckRate, HealthCheckType ``` +## Apps + +Types: + +```python +from cloudflare.types.magic_transit import ( + AppCreateResponse, + AppUpdateResponse, + AppListResponse, + AppDeleteResponse, +) +``` + +Methods: + +- client.magic_transit.apps.create(\*, account_id, \*\*params) -> Optional +- client.magic_transit.apps.update(account_app_id, \*, account_id, \*\*params) -> Optional +- client.magic_transit.apps.list(\*, account_id) -> SyncSinglePage[AppListResponse] +- client.magic_transit.apps.delete(account_app_id, \*, account_id) -> Optional + ## CfInterconnects Types: @@ -4073,6 +4127,28 @@ Methods: - client.magic_transit.sites.wans.edit(wan_id, \*, account_id, site_id, \*\*params) -> WAN - client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WAN +### Sites + +#### AppConfiguration + +Types: + +```python +from cloudflare.types.magic_transit.sites.sites import ( + AppConfigurationCreateResponse, + AppConfigurationUpdateResponse, + AppConfigurationListResponse, + AppConfigurationDeleteResponse, +) +``` + +Methods: + +- client.magic_transit.sites.sites.app_configuration.create(site_id, \*, account_id, \*\*params) -> Optional +- client.magic_transit.sites.sites.app_configuration.update(app_config_id, \*, account_id, site_id, \*\*params) -> Optional +- client.magic_transit.sites.sites.app_configuration.list(site_id, \*, account_id) -> SyncSinglePage[AppConfigurationListResponse] +- client.magic_transit.sites.sites.app_configuration.delete(app_config_id, \*, account_id, site_id) -> Optional + ## Connectors Types: diff --git a/src/cloudflare/resources/addressing/__init__.py b/src/cloudflare/resources/addressing/__init__.py index 662ac0127d3..7abbb395744 100644 --- a/src/cloudflare/resources/addressing/__init__.py +++ b/src/cloudflare/resources/addressing/__init__.py @@ -40,8 +40,22 @@ LOADocumentsResourceWithStreamingResponse, AsyncLOADocumentsResourceWithStreamingResponse, ) +from .regional_hostnames import ( + RegionalHostnamesResource, + AsyncRegionalHostnamesResource, + RegionalHostnamesResourceWithRawResponse, + AsyncRegionalHostnamesResourceWithRawResponse, + RegionalHostnamesResourceWithStreamingResponse, + AsyncRegionalHostnamesResourceWithStreamingResponse, +) __all__ = [ + "RegionalHostnamesResource", + "AsyncRegionalHostnamesResource", + "RegionalHostnamesResourceWithRawResponse", + "AsyncRegionalHostnamesResourceWithRawResponse", + "RegionalHostnamesResourceWithStreamingResponse", + "AsyncRegionalHostnamesResourceWithStreamingResponse", "ServicesResource", "AsyncServicesResource", "ServicesResourceWithRawResponse", diff --git a/src/cloudflare/resources/addressing/addressing.py b/src/cloudflare/resources/addressing/addressing.py index c0e0cd3b374..8157035d32f 100644 --- a/src/cloudflare/resources/addressing/addressing.py +++ b/src/cloudflare/resources/addressing/addressing.py @@ -37,13 +37,26 @@ AsyncLOADocumentsResourceWithStreamingResponse, ) from .prefixes.prefixes import PrefixesResource, AsyncPrefixesResource +from .regional_hostnames import ( + RegionalHostnamesResource, + AsyncRegionalHostnamesResource, + RegionalHostnamesResourceWithRawResponse, + AsyncRegionalHostnamesResourceWithRawResponse, + RegionalHostnamesResourceWithStreamingResponse, + AsyncRegionalHostnamesResourceWithStreamingResponse, +) from .address_maps.address_maps import AddressMapsResource, AsyncAddressMapsResource from .loa_documents.loa_documents import LOADocumentsResource, AsyncLOADocumentsResource +from .regional_hostnames.regional_hostnames import RegionalHostnamesResource, AsyncRegionalHostnamesResource __all__ = ["AddressingResource", "AsyncAddressingResource"] class AddressingResource(SyncAPIResource): + @cached_property + def regional_hostnames(self) -> RegionalHostnamesResource: + return RegionalHostnamesResource(self._client) + @cached_property def services(self) -> ServicesResource: return ServicesResource(self._client) @@ -70,6 +83,10 @@ def with_streaming_response(self) -> AddressingResourceWithStreamingResponse: class AsyncAddressingResource(AsyncAPIResource): + @cached_property + def regional_hostnames(self) -> AsyncRegionalHostnamesResource: + return AsyncRegionalHostnamesResource(self._client) + @cached_property def services(self) -> AsyncServicesResource: return AsyncServicesResource(self._client) @@ -99,6 +116,10 @@ class AddressingResourceWithRawResponse: def __init__(self, addressing: AddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> RegionalHostnamesResourceWithRawResponse: + return RegionalHostnamesResourceWithRawResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> ServicesResourceWithRawResponse: return ServicesResourceWithRawResponse(self._addressing.services) @@ -120,6 +141,10 @@ class AsyncAddressingResourceWithRawResponse: def __init__(self, addressing: AsyncAddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> AsyncRegionalHostnamesResourceWithRawResponse: + return AsyncRegionalHostnamesResourceWithRawResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> AsyncServicesResourceWithRawResponse: return AsyncServicesResourceWithRawResponse(self._addressing.services) @@ -141,6 +166,10 @@ class AddressingResourceWithStreamingResponse: def __init__(self, addressing: AddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> RegionalHostnamesResourceWithStreamingResponse: + return RegionalHostnamesResourceWithStreamingResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> ServicesResourceWithStreamingResponse: return ServicesResourceWithStreamingResponse(self._addressing.services) @@ -162,6 +191,10 @@ class AsyncAddressingResourceWithStreamingResponse: def __init__(self, addressing: AsyncAddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> AsyncRegionalHostnamesResourceWithStreamingResponse: + return AsyncRegionalHostnamesResourceWithStreamingResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> AsyncServicesResourceWithStreamingResponse: return AsyncServicesResourceWithStreamingResponse(self._addressing.services) diff --git a/src/cloudflare/resources/addressing/regional_hostnames/__init__.py b/src/cloudflare/resources/addressing/regional_hostnames/__init__.py new file mode 100644 index 00000000000..b81e8f7c300 --- /dev/null +++ b/src/cloudflare/resources/addressing/regional_hostnames/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .regions import ( + RegionsResource, + AsyncRegionsResource, + RegionsResourceWithRawResponse, + AsyncRegionsResourceWithRawResponse, + RegionsResourceWithStreamingResponse, + AsyncRegionsResourceWithStreamingResponse, +) +from .regional_hostnames import ( + RegionalHostnamesResource, + AsyncRegionalHostnamesResource, + RegionalHostnamesResourceWithRawResponse, + AsyncRegionalHostnamesResourceWithRawResponse, + RegionalHostnamesResourceWithStreamingResponse, + AsyncRegionalHostnamesResourceWithStreamingResponse, +) + +__all__ = [ + "RegionsResource", + "AsyncRegionsResource", + "RegionsResourceWithRawResponse", + "AsyncRegionsResourceWithRawResponse", + "RegionsResourceWithStreamingResponse", + "AsyncRegionsResourceWithStreamingResponse", + "RegionalHostnamesResource", + "AsyncRegionalHostnamesResource", + "RegionalHostnamesResourceWithRawResponse", + "AsyncRegionalHostnamesResourceWithRawResponse", + "RegionalHostnamesResourceWithStreamingResponse", + "AsyncRegionalHostnamesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py new file mode 100644 index 00000000000..1524d3e06bc --- /dev/null +++ b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py @@ -0,0 +1,633 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from .regions import ( + RegionsResource, + AsyncRegionsResource, + RegionsResourceWithRawResponse, + AsyncRegionsResourceWithRawResponse, + RegionsResourceWithStreamingResponse, + AsyncRegionsResourceWithStreamingResponse, +) +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 SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.addressing import regional_hostname_edit_params, regional_hostname_create_params +from ....types.addressing.regional_hostname_get_response import RegionalHostnameGetResponse +from ....types.addressing.regional_hostname_edit_response import RegionalHostnameEditResponse +from ....types.addressing.regional_hostname_list_response import RegionalHostnameListResponse +from ....types.addressing.regional_hostname_create_response import RegionalHostnameCreateResponse +from ....types.addressing.regional_hostname_delete_response import RegionalHostnameDeleteResponse + +__all__ = ["RegionalHostnamesResource", "AsyncRegionalHostnamesResource"] + + +class RegionalHostnamesResource(SyncAPIResource): + @cached_property + def regions(self) -> RegionsResource: + return RegionsResource(self._client) + + @cached_property + def with_raw_response(self) -> RegionalHostnamesResourceWithRawResponse: + return RegionalHostnamesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RegionalHostnamesResourceWithStreamingResponse: + return RegionalHostnamesResourceWithStreamingResponse(self) + + def create( + self, + *, + zone_id: str, + hostname: str, + region_key: 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[RegionalHostnameCreateResponse]: + """Create a new Regional Hostname entry. + + Cloudflare will only use data centers that + are physically located within the chosen region to decrypt and service HTTPS + traffic. Learn more about + [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._post( + f"/zones/{zone_id}/addressing/regional_hostnames", + body=maybe_transform( + { + "hostname": hostname, + "region_key": region_key, + }, + regional_hostname_create_params.RegionalHostnameCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameCreateResponse]], ResultWrapper[RegionalHostnameCreateResponse]), + ) + + def list( + self, + *, + zone_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, + ) -> SyncSinglePage[RegionalHostnameListResponse]: + """ + List all Regional Hostnames within a zone. + + Args: + zone_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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/addressing/regional_hostnames", + page=SyncSinglePage[RegionalHostnameListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionalHostnameListResponse, + ) + + def delete( + self, + hostname: str, + *, + zone_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, + ) -> RegionalHostnameDeleteResponse: + """ + Delete the region configuration for a specific Regional Hostname. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return self._delete( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RegionalHostnameDeleteResponse, + ) + + def edit( + self, + hostname: str, + *, + zone_id: str, + region_key: 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[RegionalHostnameEditResponse]: + """Update the configuration for a specific Regional Hostname. + + Only the region_key + of a hostname is mutable. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return self._patch( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + body=maybe_transform({"region_key": region_key}, regional_hostname_edit_params.RegionalHostnameEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameEditResponse]], ResultWrapper[RegionalHostnameEditResponse]), + ) + + def get( + self, + hostname: str, + *, + zone_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[RegionalHostnameGetResponse]: + """ + Fetch the configuration for a specific Regional Hostname, within a zone. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return self._get( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameGetResponse]], ResultWrapper[RegionalHostnameGetResponse]), + ) + + +class AsyncRegionalHostnamesResource(AsyncAPIResource): + @cached_property + def regions(self) -> AsyncRegionsResource: + return AsyncRegionsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncRegionalHostnamesResourceWithRawResponse: + return AsyncRegionalHostnamesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRegionalHostnamesResourceWithStreamingResponse: + return AsyncRegionalHostnamesResourceWithStreamingResponse(self) + + async def create( + self, + *, + zone_id: str, + hostname: str, + region_key: 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[RegionalHostnameCreateResponse]: + """Create a new Regional Hostname entry. + + Cloudflare will only use data centers that + are physically located within the chosen region to decrypt and service HTTPS + traffic. Learn more about + [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._post( + f"/zones/{zone_id}/addressing/regional_hostnames", + body=await async_maybe_transform( + { + "hostname": hostname, + "region_key": region_key, + }, + regional_hostname_create_params.RegionalHostnameCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameCreateResponse]], ResultWrapper[RegionalHostnameCreateResponse]), + ) + + def list( + self, + *, + zone_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, + ) -> AsyncPaginator[RegionalHostnameListResponse, AsyncSinglePage[RegionalHostnameListResponse]]: + """ + List all Regional Hostnames within a zone. + + Args: + zone_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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/addressing/regional_hostnames", + page=AsyncSinglePage[RegionalHostnameListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionalHostnameListResponse, + ) + + async def delete( + self, + hostname: str, + *, + zone_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, + ) -> RegionalHostnameDeleteResponse: + """ + Delete the region configuration for a specific Regional Hostname. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return await self._delete( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RegionalHostnameDeleteResponse, + ) + + async def edit( + self, + hostname: str, + *, + zone_id: str, + region_key: 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[RegionalHostnameEditResponse]: + """Update the configuration for a specific Regional Hostname. + + Only the region_key + of a hostname is mutable. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return await self._patch( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + body=await async_maybe_transform( + {"region_key": region_key}, regional_hostname_edit_params.RegionalHostnameEditParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameEditResponse]], ResultWrapper[RegionalHostnameEditResponse]), + ) + + async def get( + self, + hostname: str, + *, + zone_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[RegionalHostnameGetResponse]: + """ + Fetch the configuration for a specific Regional Hostname, within a zone. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return await self._get( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameGetResponse]], ResultWrapper[RegionalHostnameGetResponse]), + ) + + +class RegionalHostnamesResourceWithRawResponse: + def __init__(self, regional_hostnames: RegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = to_raw_response_wrapper( + regional_hostnames.create, + ) + self.list = to_raw_response_wrapper( + regional_hostnames.list, + ) + self.delete = to_raw_response_wrapper( + regional_hostnames.delete, + ) + self.edit = to_raw_response_wrapper( + regional_hostnames.edit, + ) + self.get = to_raw_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> RegionsResourceWithRawResponse: + return RegionsResourceWithRawResponse(self._regional_hostnames.regions) + + +class AsyncRegionalHostnamesResourceWithRawResponse: + def __init__(self, regional_hostnames: AsyncRegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = async_to_raw_response_wrapper( + regional_hostnames.create, + ) + self.list = async_to_raw_response_wrapper( + regional_hostnames.list, + ) + self.delete = async_to_raw_response_wrapper( + regional_hostnames.delete, + ) + self.edit = async_to_raw_response_wrapper( + regional_hostnames.edit, + ) + self.get = async_to_raw_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> AsyncRegionsResourceWithRawResponse: + return AsyncRegionsResourceWithRawResponse(self._regional_hostnames.regions) + + +class RegionalHostnamesResourceWithStreamingResponse: + def __init__(self, regional_hostnames: RegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = to_streamed_response_wrapper( + regional_hostnames.create, + ) + self.list = to_streamed_response_wrapper( + regional_hostnames.list, + ) + self.delete = to_streamed_response_wrapper( + regional_hostnames.delete, + ) + self.edit = to_streamed_response_wrapper( + regional_hostnames.edit, + ) + self.get = to_streamed_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> RegionsResourceWithStreamingResponse: + return RegionsResourceWithStreamingResponse(self._regional_hostnames.regions) + + +class AsyncRegionalHostnamesResourceWithStreamingResponse: + def __init__(self, regional_hostnames: AsyncRegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = async_to_streamed_response_wrapper( + regional_hostnames.create, + ) + self.list = async_to_streamed_response_wrapper( + regional_hostnames.list, + ) + self.delete = async_to_streamed_response_wrapper( + regional_hostnames.delete, + ) + self.edit = async_to_streamed_response_wrapper( + regional_hostnames.edit, + ) + self.get = async_to_streamed_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> AsyncRegionsResourceWithStreamingResponse: + return AsyncRegionsResourceWithStreamingResponse(self._regional_hostnames.regions) diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regions.py b/src/cloudflare/resources/addressing/regional_hostnames/regions.py new file mode 100644 index 00000000000..7340ffab77f --- /dev/null +++ b/src/cloudflare/resources/addressing/regional_hostnames/regions.py @@ -0,0 +1,151 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +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 ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.addressing.regional_hostnames.region_list_response import RegionListResponse + +__all__ = ["RegionsResource", "AsyncRegionsResource"] + + +class RegionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RegionsResourceWithRawResponse: + return RegionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RegionsResourceWithStreamingResponse: + return RegionsResourceWithStreamingResponse(self) + + def list( + self, + *, + 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, + ) -> SyncSinglePage[RegionListResponse]: + """ + List all Regional Services regions available for use by this account. + + Args: + account_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}") + return self._get_api_list( + f"/accounts/{account_id}/addressing/regional_hostnames/regions", + page=SyncSinglePage[RegionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionListResponse, + ) + + +class AsyncRegionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRegionsResourceWithRawResponse: + return AsyncRegionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRegionsResourceWithStreamingResponse: + return AsyncRegionsResourceWithStreamingResponse(self) + + def list( + self, + *, + 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, + ) -> AsyncPaginator[RegionListResponse, AsyncSinglePage[RegionListResponse]]: + """ + List all Regional Services regions available for use by this account. + + Args: + account_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}") + return self._get_api_list( + f"/accounts/{account_id}/addressing/regional_hostnames/regions", + page=AsyncSinglePage[RegionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionListResponse, + ) + + +class RegionsResourceWithRawResponse: + def __init__(self, regions: RegionsResource) -> None: + self._regions = regions + + self.list = to_raw_response_wrapper( + regions.list, + ) + + +class AsyncRegionsResourceWithRawResponse: + def __init__(self, regions: AsyncRegionsResource) -> None: + self._regions = regions + + self.list = async_to_raw_response_wrapper( + regions.list, + ) + + +class RegionsResourceWithStreamingResponse: + def __init__(self, regions: RegionsResource) -> None: + self._regions = regions + + self.list = to_streamed_response_wrapper( + regions.list, + ) + + +class AsyncRegionsResourceWithStreamingResponse: + def __init__(self, regions: AsyncRegionsResource) -> None: + self._regions = regions + + self.list = async_to_streamed_response_wrapper( + regions.list, + ) diff --git a/src/cloudflare/resources/magic_transit/__init__.py b/src/cloudflare/resources/magic_transit/__init__.py index 842f6cfd86a..db6f2e65c99 100644 --- a/src/cloudflare/resources/magic_transit/__init__.py +++ b/src/cloudflare/resources/magic_transit/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .apps import ( + AppsResource, + AsyncAppsResource, + AppsResourceWithRawResponse, + AsyncAppsResourceWithRawResponse, + AppsResourceWithStreamingResponse, + AsyncAppsResourceWithStreamingResponse, +) from .sites import ( SitesResource, AsyncSitesResource, @@ -58,6 +66,12 @@ ) __all__ = [ + "AppsResource", + "AsyncAppsResource", + "AppsResourceWithRawResponse", + "AsyncAppsResourceWithRawResponse", + "AppsResourceWithStreamingResponse", + "AsyncAppsResourceWithStreamingResponse", "CfInterconnectsResource", "AsyncCfInterconnectsResource", "CfInterconnectsResourceWithRawResponse", diff --git a/src/cloudflare/resources/magic_transit/apps.py b/src/cloudflare/resources/magic_transit/apps.py new file mode 100644 index 00000000000..c0e9b974eec --- /dev/null +++ b/src/cloudflare/resources/magic_transit/apps.py @@ -0,0 +1,777 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Type, Optional, cast, overload + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + required_args, + 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 SyncSinglePage, AsyncSinglePage +from ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.magic_transit import app_create_params, app_update_params +from ...types.magic_transit.app_list_response import AppListResponse +from ...types.magic_transit.app_create_response import AppCreateResponse +from ...types.magic_transit.app_delete_response import AppDeleteResponse +from ...types.magic_transit.app_update_response import AppUpdateResponse + +__all__ = ["AppsResource", "AsyncAppsResource"] + + +class AppsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AppsResourceWithRawResponse: + return AppsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AppsResourceWithStreamingResponse: + return AppsResourceWithStreamingResponse(self) + + @overload + def create( + 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[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_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 + """ + ... + + @overload + def create( + 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[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_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 + """ + ... + + @required_args(["account_id", "body"]) + def create( + 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[AppCreateResponse]: + 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}/magic/apps", + body=maybe_transform(body, app_create_params.AppCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppCreateResponse]], ResultWrapper[AppCreateResponse]), + ) + + @overload + def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @overload + def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @overload + def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @overload + def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @required_args(["account_id", "body"]) + def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return self._put( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + body=maybe_transform(body, app_update_params.AppUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppUpdateResponse]], ResultWrapper[AppUpdateResponse]), + ) + + def list( + self, + *, + 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, + ) -> SyncSinglePage[AppListResponse]: + """ + Lists Apps associated with an account. + + Args: + account_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}") + return self._get_api_list( + f"/accounts/{account_id}/magic/apps", + page=SyncSinglePage[AppListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=cast(Any, AppListResponse), # Union types cannot be passed in as arguments in the type system + ) + + def delete( + self, + account_app_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[AppDeleteResponse]: + """ + Deletes specific Account App. + + Args: + account_id: Identifier + + account_app_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 account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppDeleteResponse]], ResultWrapper[AppDeleteResponse]), + ) + + +class AsyncAppsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAppsResourceWithRawResponse: + return AsyncAppsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAppsResourceWithStreamingResponse: + return AsyncAppsResourceWithStreamingResponse(self) + + @overload + async def create( + 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[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_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 + """ + ... + + @overload + async def create( + 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[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_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 + """ + ... + + @required_args(["account_id", "body"]) + async def create( + 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[AppCreateResponse]: + 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}/magic/apps", + body=await async_maybe_transform(body, app_create_params.AppCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppCreateResponse]], ResultWrapper[AppCreateResponse]), + ) + + @overload + async def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @overload + async def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @overload + async def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @overload + async def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_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 + """ + ... + + @required_args(["account_id", "body"]) + async def update( + self, + account_app_id: str, + *, + 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[AppUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + body=await async_maybe_transform(body, app_update_params.AppUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppUpdateResponse]], ResultWrapper[AppUpdateResponse]), + ) + + def list( + self, + *, + 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, + ) -> AsyncPaginator[AppListResponse, AsyncSinglePage[AppListResponse]]: + """ + Lists Apps associated with an account. + + Args: + account_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}") + return self._get_api_list( + f"/accounts/{account_id}/magic/apps", + page=AsyncSinglePage[AppListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=cast(Any, AppListResponse), # Union types cannot be passed in as arguments in the type system + ) + + async def delete( + self, + account_app_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[AppDeleteResponse]: + """ + Deletes specific Account App. + + Args: + account_id: Identifier + + account_app_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 account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppDeleteResponse]], ResultWrapper[AppDeleteResponse]), + ) + + +class AppsResourceWithRawResponse: + def __init__(self, apps: AppsResource) -> None: + self._apps = apps + + self.create = to_raw_response_wrapper( + apps.create, + ) + self.update = to_raw_response_wrapper( + apps.update, + ) + self.list = to_raw_response_wrapper( + apps.list, + ) + self.delete = to_raw_response_wrapper( + apps.delete, + ) + + +class AsyncAppsResourceWithRawResponse: + def __init__(self, apps: AsyncAppsResource) -> None: + self._apps = apps + + self.create = async_to_raw_response_wrapper( + apps.create, + ) + self.update = async_to_raw_response_wrapper( + apps.update, + ) + self.list = async_to_raw_response_wrapper( + apps.list, + ) + self.delete = async_to_raw_response_wrapper( + apps.delete, + ) + + +class AppsResourceWithStreamingResponse: + def __init__(self, apps: AppsResource) -> None: + self._apps = apps + + self.create = to_streamed_response_wrapper( + apps.create, + ) + self.update = to_streamed_response_wrapper( + apps.update, + ) + self.list = to_streamed_response_wrapper( + apps.list, + ) + self.delete = to_streamed_response_wrapper( + apps.delete, + ) + + +class AsyncAppsResourceWithStreamingResponse: + def __init__(self, apps: AsyncAppsResource) -> None: + self._apps = apps + + self.create = async_to_streamed_response_wrapper( + apps.create, + ) + self.update = async_to_streamed_response_wrapper( + apps.update, + ) + self.list = async_to_streamed_response_wrapper( + apps.list, + ) + self.delete = async_to_streamed_response_wrapper( + apps.delete, + ) diff --git a/src/cloudflare/resources/magic_transit/magic_transit.py b/src/cloudflare/resources/magic_transit/magic_transit.py index 26c772232f2..7eeb84551cf 100644 --- a/src/cloudflare/resources/magic_transit/magic_transit.py +++ b/src/cloudflare/resources/magic_transit/magic_transit.py @@ -2,6 +2,14 @@ from __future__ import annotations +from .apps import ( + AppsResource, + AsyncAppsResource, + AppsResourceWithRawResponse, + AsyncAppsResourceWithRawResponse, + AppsResourceWithStreamingResponse, + AsyncAppsResourceWithStreamingResponse, +) from .sites import ( SitesResource, AsyncSitesResource, @@ -58,6 +66,10 @@ class MagicTransitResource(SyncAPIResource): + @cached_property + def apps(self) -> AppsResource: + return AppsResource(self._client) + @cached_property def cf_interconnects(self) -> CfInterconnectsResource: return CfInterconnectsResource(self._client) @@ -92,6 +104,10 @@ def with_streaming_response(self) -> MagicTransitResourceWithStreamingResponse: class AsyncMagicTransitResource(AsyncAPIResource): + @cached_property + def apps(self) -> AsyncAppsResource: + return AsyncAppsResource(self._client) + @cached_property def cf_interconnects(self) -> AsyncCfInterconnectsResource: return AsyncCfInterconnectsResource(self._client) @@ -129,6 +145,10 @@ class MagicTransitResourceWithRawResponse: def __init__(self, magic_transit: MagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AppsResourceWithRawResponse: + return AppsResourceWithRawResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> CfInterconnectsResourceWithRawResponse: return CfInterconnectsResourceWithRawResponse(self._magic_transit.cf_interconnects) @@ -158,6 +178,10 @@ class AsyncMagicTransitResourceWithRawResponse: def __init__(self, magic_transit: AsyncMagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AsyncAppsResourceWithRawResponse: + return AsyncAppsResourceWithRawResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> AsyncCfInterconnectsResourceWithRawResponse: return AsyncCfInterconnectsResourceWithRawResponse(self._magic_transit.cf_interconnects) @@ -187,6 +211,10 @@ class MagicTransitResourceWithStreamingResponse: def __init__(self, magic_transit: MagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AppsResourceWithStreamingResponse: + return AppsResourceWithStreamingResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> CfInterconnectsResourceWithStreamingResponse: return CfInterconnectsResourceWithStreamingResponse(self._magic_transit.cf_interconnects) @@ -216,6 +244,10 @@ class AsyncMagicTransitResourceWithStreamingResponse: def __init__(self, magic_transit: AsyncMagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AsyncAppsResourceWithStreamingResponse: + return AsyncAppsResourceWithStreamingResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> AsyncCfInterconnectsResourceWithStreamingResponse: return AsyncCfInterconnectsResourceWithStreamingResponse(self._magic_transit.cf_interconnects) diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py index 67c24a85c6f..c8a502834c7 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites.py +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -30,6 +30,15 @@ WANsResourceWithStreamingResponse, AsyncWANsResourceWithStreamingResponse, ) +from .sites import ( + SitesResource, + AsyncSitesResource, + SitesResourceWithRawResponse, + AsyncSitesResourceWithRawResponse, + SitesResourceWithStreamingResponse, + AsyncSitesResourceWithStreamingResponse, + sites, +) from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ...._utils import ( maybe_transform, @@ -74,6 +83,10 @@ def lans(self) -> LANsResource: def wans(self) -> WANsResource: return WANsResource(self._client) + @cached_property + def sites(self) -> sites.SitesResource: + return SitesResource(self._client) + @cached_property def with_raw_response(self) -> SitesResourceWithRawResponse: return SitesResourceWithRawResponse(self) @@ -431,6 +444,10 @@ def lans(self) -> AsyncLANsResource: def wans(self) -> AsyncWANsResource: return AsyncWANsResource(self._client) + @cached_property + def sites(self) -> sites.AsyncSitesResource: + return AsyncSitesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncSitesResourceWithRawResponse: return AsyncSitesResourceWithRawResponse(self) @@ -810,6 +827,10 @@ def lans(self) -> LANsResourceWithRawResponse: def wans(self) -> WANsResourceWithRawResponse: return WANsResourceWithRawResponse(self._sites.wans) + @cached_property + def sites(self) -> SitesResourceWithRawResponse: + return SitesResourceWithRawResponse(self._sites.sites) + class AsyncSitesResourceWithRawResponse: def __init__(self, sites: AsyncSitesResource) -> None: @@ -846,6 +867,10 @@ def lans(self) -> AsyncLANsResourceWithRawResponse: def wans(self) -> AsyncWANsResourceWithRawResponse: return AsyncWANsResourceWithRawResponse(self._sites.wans) + @cached_property + def sites(self) -> AsyncSitesResourceWithRawResponse: + return AsyncSitesResourceWithRawResponse(self._sites.sites) + class SitesResourceWithStreamingResponse: def __init__(self, sites: SitesResource) -> None: @@ -882,6 +907,10 @@ def lans(self) -> LANsResourceWithStreamingResponse: def wans(self) -> WANsResourceWithStreamingResponse: return WANsResourceWithStreamingResponse(self._sites.wans) + @cached_property + def sites(self) -> SitesResourceWithStreamingResponse: + return SitesResourceWithStreamingResponse(self._sites.sites) + class AsyncSitesResourceWithStreamingResponse: def __init__(self, sites: AsyncSitesResource) -> None: @@ -917,3 +946,7 @@ def lans(self) -> AsyncLANsResourceWithStreamingResponse: @cached_property def wans(self) -> AsyncWANsResourceWithStreamingResponse: return AsyncWANsResourceWithStreamingResponse(self._sites.wans) + + @cached_property + def sites(self) -> AsyncSitesResourceWithStreamingResponse: + return AsyncSitesResourceWithStreamingResponse(self._sites.sites) diff --git a/src/cloudflare/resources/magic_transit/sites/sites/__init__.py b/src/cloudflare/resources/magic_transit/sites/sites/__init__.py new file mode 100644 index 00000000000..01aea158619 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/sites/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .sites import ( + SitesResource, + AsyncSitesResource, + SitesResourceWithRawResponse, + AsyncSitesResourceWithRawResponse, + SitesResourceWithStreamingResponse, + AsyncSitesResourceWithStreamingResponse, +) +from .app_configuration import ( + AppConfigurationResource, + AsyncAppConfigurationResource, + AppConfigurationResourceWithRawResponse, + AsyncAppConfigurationResourceWithRawResponse, + AppConfigurationResourceWithStreamingResponse, + AsyncAppConfigurationResourceWithStreamingResponse, +) + +__all__ = [ + "AppConfigurationResource", + "AsyncAppConfigurationResource", + "AppConfigurationResourceWithRawResponse", + "AsyncAppConfigurationResourceWithRawResponse", + "AppConfigurationResourceWithStreamingResponse", + "AsyncAppConfigurationResourceWithStreamingResponse", + "SitesResource", + "AsyncSitesResource", + "SitesResourceWithRawResponse", + "AsyncSitesResourceWithRawResponse", + "SitesResourceWithStreamingResponse", + "AsyncSitesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py b/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py new file mode 100644 index 00000000000..7e61a793203 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py @@ -0,0 +1,1049 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast, overload + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + required_args, + 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 SyncSinglePage, AsyncSinglePage +from ....._base_client import ( + AsyncPaginator, + make_request_options, +) +from .....types.magic_transit.sites.sites import app_configuration_create_params, app_configuration_update_params +from .....types.magic_transit.sites.sites.app_configuration_list_response import AppConfigurationListResponse +from .....types.magic_transit.sites.sites.app_configuration_create_response import AppConfigurationCreateResponse +from .....types.magic_transit.sites.sites.app_configuration_delete_response import AppConfigurationDeleteResponse +from .....types.magic_transit.sites.sites.app_configuration_update_response import AppConfigurationUpdateResponse + +__all__ = ["AppConfigurationResource", "AsyncAppConfigurationResource"] + + +class AppConfigurationResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AppConfigurationResourceWithRawResponse: + return AppConfigurationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AppConfigurationResourceWithStreamingResponse: + return AppConfigurationResourceWithStreamingResponse(self) + + @overload + def create( + self, + site_id: str, + *, + account_id: str, + account_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + account_app_id: Magic account app ID. + + 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 + """ + ... + + @overload + def create( + self, + site_id: str, + *, + account_id: str, + managed_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + managed_app_id: Managed app ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["account_id", "account_app_id"], ["account_id", "managed_app_id"]) + def create( + self, + site_id: str, + *, + account_id: str, + account_app_id: str | NotGiven = NOT_GIVEN, + managed_app_id: 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[AppConfigurationCreateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + body=maybe_transform( + { + "account_app_id": account_app_id, + "managed_app_id": managed_app_id, + }, + app_configuration_create_params.AppConfigurationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationCreateResponse]], ResultWrapper[AppConfigurationCreateResponse]), + ) + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app ID. + + 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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + managed_app_id: Managed app ID. + + 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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: str, + managed_app_id: Optional[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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app ID. + + managed_app_id: **Must be set to null** + + 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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: Optional[str], + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: **Must be set to null** + + managed_app_id: Managed app ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + ["account_id", "site_id", "body"], + ["account_id", "site_id", "account_app_id"], + ["account_id", "site_id", "managed_app_id"], + ["account_id", "site_id", "account_app_id", "managed_app_id"], + ) + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object | NotGiven = NOT_GIVEN, + account_app_id: str | None | NotGiven = NOT_GIVEN, + managed_app_id: str | None | 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[AppConfigurationUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + body=maybe_transform(body, app_configuration_update_params.AppConfigurationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationUpdateResponse]], ResultWrapper[AppConfigurationUpdateResponse]), + ) + + def list( + self, + site_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, + ) -> SyncSinglePage[AppConfigurationListResponse]: + """ + Lists App Configs associated with a site. + + Args: + account_id: Identifier + + site_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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + page=SyncSinglePage[AppConfigurationListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=AppConfigurationListResponse, + ) + + def delete( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationDeleteResponse]: + """ + Deletes specific App Config associated with a site. + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationDeleteResponse]], ResultWrapper[AppConfigurationDeleteResponse]), + ) + + +class AsyncAppConfigurationResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAppConfigurationResourceWithRawResponse: + return AsyncAppConfigurationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAppConfigurationResourceWithStreamingResponse: + return AsyncAppConfigurationResourceWithStreamingResponse(self) + + @overload + async def create( + self, + site_id: str, + *, + account_id: str, + account_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + account_app_id: Magic account app ID. + + 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 + """ + ... + + @overload + async def create( + self, + site_id: str, + *, + account_id: str, + managed_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + managed_app_id: Managed app ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["account_id", "account_app_id"], ["account_id", "managed_app_id"]) + async def create( + self, + site_id: str, + *, + account_id: str, + account_app_id: str | NotGiven = NOT_GIVEN, + managed_app_id: 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[AppConfigurationCreateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + body=await async_maybe_transform( + { + "account_app_id": account_app_id, + "managed_app_id": managed_app_id, + }, + app_configuration_create_params.AppConfigurationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationCreateResponse]], ResultWrapper[AppConfigurationCreateResponse]), + ) + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app ID. + + 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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + managed_app_id: Managed app ID. + + 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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: str, + managed_app_id: Optional[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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app ID. + + managed_app_id: **Must be set to null** + + 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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: Optional[str], + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: **Must be set to null** + + managed_app_id: Managed app ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + ["account_id", "site_id", "body"], + ["account_id", "site_id", "account_app_id"], + ["account_id", "site_id", "managed_app_id"], + ["account_id", "site_id", "account_app_id", "managed_app_id"], + ) + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object | NotGiven = NOT_GIVEN, + account_app_id: str | None | NotGiven = NOT_GIVEN, + managed_app_id: str | None | 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[AppConfigurationUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + body=await async_maybe_transform(body, app_configuration_update_params.AppConfigurationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationUpdateResponse]], ResultWrapper[AppConfigurationUpdateResponse]), + ) + + def list( + self, + site_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, + ) -> AsyncPaginator[AppConfigurationListResponse, AsyncSinglePage[AppConfigurationListResponse]]: + """ + Lists App Configs associated with a site. + + Args: + account_id: Identifier + + site_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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + page=AsyncSinglePage[AppConfigurationListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=AppConfigurationListResponse, + ) + + async def delete( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationDeleteResponse]: + """ + Deletes specific App Config associated with a site. + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationDeleteResponse]], ResultWrapper[AppConfigurationDeleteResponse]), + ) + + +class AppConfigurationResourceWithRawResponse: + def __init__(self, app_configuration: AppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = to_raw_response_wrapper( + app_configuration.create, + ) + self.update = to_raw_response_wrapper( + app_configuration.update, + ) + self.list = to_raw_response_wrapper( + app_configuration.list, + ) + self.delete = to_raw_response_wrapper( + app_configuration.delete, + ) + + +class AsyncAppConfigurationResourceWithRawResponse: + def __init__(self, app_configuration: AsyncAppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = async_to_raw_response_wrapper( + app_configuration.create, + ) + self.update = async_to_raw_response_wrapper( + app_configuration.update, + ) + self.list = async_to_raw_response_wrapper( + app_configuration.list, + ) + self.delete = async_to_raw_response_wrapper( + app_configuration.delete, + ) + + +class AppConfigurationResourceWithStreamingResponse: + def __init__(self, app_configuration: AppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = to_streamed_response_wrapper( + app_configuration.create, + ) + self.update = to_streamed_response_wrapper( + app_configuration.update, + ) + self.list = to_streamed_response_wrapper( + app_configuration.list, + ) + self.delete = to_streamed_response_wrapper( + app_configuration.delete, + ) + + +class AsyncAppConfigurationResourceWithStreamingResponse: + def __init__(self, app_configuration: AsyncAppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = async_to_streamed_response_wrapper( + app_configuration.create, + ) + self.update = async_to_streamed_response_wrapper( + app_configuration.update, + ) + self.list = async_to_streamed_response_wrapper( + app_configuration.list, + ) + self.delete = async_to_streamed_response_wrapper( + app_configuration.delete, + ) diff --git a/src/cloudflare/resources/magic_transit/sites/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites/sites.py new file mode 100644 index 00000000000..04377a5750e --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/sites/sites.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from .app_configuration import ( + AppConfigurationResource, + AsyncAppConfigurationResource, + AppConfigurationResourceWithRawResponse, + AsyncAppConfigurationResourceWithRawResponse, + AppConfigurationResourceWithStreamingResponse, + AsyncAppConfigurationResourceWithStreamingResponse, +) + +__all__ = ["SitesResource", "AsyncSitesResource"] + + +class SitesResource(SyncAPIResource): + @cached_property + def app_configuration(self) -> AppConfigurationResource: + return AppConfigurationResource(self._client) + + @cached_property + def with_raw_response(self) -> SitesResourceWithRawResponse: + return SitesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SitesResourceWithStreamingResponse: + return SitesResourceWithStreamingResponse(self) + + +class AsyncSitesResource(AsyncAPIResource): + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResource: + return AsyncAppConfigurationResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSitesResourceWithRawResponse: + return AsyncSitesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSitesResourceWithStreamingResponse: + return AsyncSitesResourceWithStreamingResponse(self) + + +class SitesResourceWithRawResponse: + def __init__(self, sites: SitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AppConfigurationResourceWithRawResponse: + return AppConfigurationResourceWithRawResponse(self._sites.app_configuration) + + +class AsyncSitesResourceWithRawResponse: + def __init__(self, sites: AsyncSitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResourceWithRawResponse: + return AsyncAppConfigurationResourceWithRawResponse(self._sites.app_configuration) + + +class SitesResourceWithStreamingResponse: + def __init__(self, sites: SitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AppConfigurationResourceWithStreamingResponse: + return AppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) + + +class AsyncSitesResourceWithStreamingResponse: + def __init__(self, sites: AsyncSitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResourceWithStreamingResponse: + return AsyncAppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) diff --git a/src/cloudflare/types/addressing/__init__.py b/src/cloudflare/types/addressing/__init__.py index 2ea66f6d7f8..1c96d654c50 100644 --- a/src/cloudflare/types/addressing/__init__.py +++ b/src/cloudflare/types/addressing/__init__.py @@ -16,3 +16,10 @@ from .address_map_create_response import AddressMapCreateResponse as AddressMapCreateResponse from .address_map_delete_response import AddressMapDeleteResponse as AddressMapDeleteResponse from .loa_document_create_response import LOADocumentCreateResponse as LOADocumentCreateResponse +from .regional_hostname_edit_params import RegionalHostnameEditParams as RegionalHostnameEditParams +from .regional_hostname_get_response import RegionalHostnameGetResponse as RegionalHostnameGetResponse +from .regional_hostname_create_params import RegionalHostnameCreateParams as RegionalHostnameCreateParams +from .regional_hostname_edit_response import RegionalHostnameEditResponse as RegionalHostnameEditResponse +from .regional_hostname_list_response import RegionalHostnameListResponse as RegionalHostnameListResponse +from .regional_hostname_create_response import RegionalHostnameCreateResponse as RegionalHostnameCreateResponse +from .regional_hostname_delete_response import RegionalHostnameDeleteResponse as RegionalHostnameDeleteResponse diff --git a/src/cloudflare/types/addressing/regional_hostname_create_params.py b/src/cloudflare/types/addressing/regional_hostname_create_params.py new file mode 100644 index 00000000000..630c2f0bed3 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_create_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["RegionalHostnameCreateParams"] + + +class RegionalHostnameCreateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + hostname: Required[str] + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: Required[str] + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_create_response.py b/src/cloudflare/types/addressing/regional_hostname_create_response.py new file mode 100644 index 00000000000..f2717ccf6ed --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_create_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameCreateResponse"] + + +class RegionalHostnameCreateResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_delete_response.py b/src/cloudflare/types/addressing/regional_hostname_delete_response.py new file mode 100644 index 00000000000..1031166663d --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_delete_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo + +__all__ = ["RegionalHostnameDeleteResponse"] + + +class RegionalHostnameDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/addressing/regional_hostname_edit_params.py b/src/cloudflare/types/addressing/regional_hostname_edit_params.py new file mode 100644 index 00000000000..a205f2de604 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_edit_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["RegionalHostnameEditParams"] + + +class RegionalHostnameEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + region_key: Required[str] + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_edit_response.py b/src/cloudflare/types/addressing/regional_hostname_edit_response.py new file mode 100644 index 00000000000..06a760610de --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_edit_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameEditResponse"] + + +class RegionalHostnameEditResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_get_response.py b/src/cloudflare/types/addressing/regional_hostname_get_response.py new file mode 100644 index 00000000000..24fe021f2fe --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_get_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameGetResponse"] + + +class RegionalHostnameGetResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_list_response.py b/src/cloudflare/types/addressing/regional_hostname_list_response.py new file mode 100644 index 00000000000..fe454021dc0 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_list_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameListResponse"] + + +class RegionalHostnameListResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostnames/__init__.py b/src/cloudflare/types/addressing/regional_hostnames/__init__.py new file mode 100644 index 00000000000..cf8fe425ff5 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostnames/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .region_list_response import RegionListResponse as RegionListResponse diff --git a/src/cloudflare/types/addressing/regional_hostnames/region_list_response.py b/src/cloudflare/types/addressing/regional_hostnames/region_list_response.py new file mode 100644 index 00000000000..d17c6577e43 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostnames/region_list_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["RegionListResponse"] + + +class RegionListResponse(BaseModel): + key: Optional[str] = None + """Identifying key for the region""" + + label: Optional[str] = None + """Human-readable text label for the region""" diff --git a/src/cloudflare/types/magic_transit/__init__.py b/src/cloudflare/types/magic_transit/__init__.py index 298acb27b50..ad2327c5724 100644 --- a/src/cloudflare/types/magic_transit/__init__.py +++ b/src/cloudflare/types/magic_transit/__init__.py @@ -10,12 +10,18 @@ from .site_location import SiteLocation as SiteLocation from .site_edit_params import SiteEditParams as SiteEditParams from .site_list_params import SiteListParams as SiteListParams +from .app_create_params import AppCreateParams as AppCreateParams +from .app_list_response import AppListResponse as AppListResponse +from .app_update_params import AppUpdateParams as AppUpdateParams from .health_check_rate import HealthCheckRate as HealthCheckRate from .health_check_type import HealthCheckType as HealthCheckType from .health_check_param import HealthCheckParam as HealthCheckParam from .route_get_response import RouteGetResponse as RouteGetResponse from .site_create_params import SiteCreateParams as SiteCreateParams from .site_update_params import SiteUpdateParams as SiteUpdateParams +from .app_create_response import AppCreateResponse as AppCreateResponse +from .app_delete_response import AppDeleteResponse as AppDeleteResponse +from .app_update_response import AppUpdateResponse as AppUpdateResponse from .route_create_params import RouteCreateParams as RouteCreateParams from .route_list_response import RouteListResponse as RouteListResponse from .route_update_params import RouteUpdateParams as RouteUpdateParams diff --git a/src/cloudflare/types/magic_transit/app_create_params.py b/src/cloudflare/types/magic_transit/app_create_params.py new file mode 100644 index 00000000000..663405d69c1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_create_params.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Required, TypedDict + +__all__ = ["AppCreateParams", "Hostnames", "Subnets"] + + +class Hostnames(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class Subnets(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +AppCreateParams = Union[Hostnames, Subnets] diff --git a/src/cloudflare/types/magic_transit/app_create_response.py b/src/cloudflare/types/magic_transit/app_create_response.py new file mode 100644 index 00000000000..109887e4753 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_create_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["AppCreateResponse"] + + +class AppCreateResponse(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_delete_response.py b/src/cloudflare/types/magic_transit/app_delete_response.py new file mode 100644 index 00000000000..0eafc15562c --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_delete_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["AppDeleteResponse"] + + +class AppDeleteResponse(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_list_response.py b/src/cloudflare/types/magic_transit/app_list_response.py new file mode 100644 index 00000000000..a7ef5d8cbd3 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_list_response.py @@ -0,0 +1,44 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional + +from ..._models import BaseModel + +__all__ = ["AppListResponse", "MagicAccountApp", "MagicManagedApp"] + + +class MagicAccountApp(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" + + +class MagicManagedApp(BaseModel): + managed_app_id: str + """Managed app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" + + +AppListResponse = Union[MagicAccountApp, MagicManagedApp] diff --git a/src/cloudflare/types/magic_transit/app_update_params.py b/src/cloudflare/types/magic_transit/app_update_params.py new file mode 100644 index 00000000000..4aa43a96678 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_update_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Required, TypedDict + +__all__ = ["AppUpdateParams", "UpdateAppName", "UpdateAppType", "UpdateAppHostnames", "UpdateAppSubnets"] + + +class UpdateAppName(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAppType(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAppHostnames(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAppSubnets(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +AppUpdateParams = Union[UpdateAppName, UpdateAppType, UpdateAppHostnames, UpdateAppSubnets] diff --git a/src/cloudflare/types/magic_transit/app_update_response.py b/src/cloudflare/types/magic_transit/app_update_response.py new file mode 100644 index 00000000000..fb98877f021 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_update_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["AppUpdateResponse"] + + +class AppUpdateResponse(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/sites/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/sites/__init__.py new file mode 100644 index 00000000000..4b8fd25c1d0 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/__init__.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .app_configuration_create_params import AppConfigurationCreateParams as AppConfigurationCreateParams +from .app_configuration_list_response import AppConfigurationListResponse as AppConfigurationListResponse +from .app_configuration_update_params import AppConfigurationUpdateParams as AppConfigurationUpdateParams +from .app_configuration_create_response import AppConfigurationCreateResponse as AppConfigurationCreateResponse +from .app_configuration_delete_response import AppConfigurationDeleteResponse as AppConfigurationDeleteResponse +from .app_configuration_update_response import AppConfigurationUpdateResponse as AppConfigurationUpdateResponse diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py new file mode 100644 index 00000000000..e5293390127 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Required, TypedDict + +__all__ = ["AppConfigurationCreateParams", "AccountApp", "ManagedApp"] + + +class AccountApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + account_app_id: Required[str] + """Magic account app ID.""" + + +class ManagedApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + managed_app_id: Required[str] + """Managed app ID.""" + + +AppConfigurationCreateParams = Union[AccountApp, ManagedApp] diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py new file mode 100644 index 00000000000..3b1c31a4251 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationCreateResponse"] + + +class AppConfigurationCreateResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py new file mode 100644 index 00000000000..1c5daf9c4fc --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationDeleteResponse"] + + +class AppConfigurationDeleteResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py new file mode 100644 index 00000000000..9c508e2a035 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationListResponse"] + + +class AppConfigurationListResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py new file mode 100644 index 00000000000..eb81278baa2 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py @@ -0,0 +1,96 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Optional +from typing_extensions import Required, TypedDict + +__all__ = [ + "AppConfigurationUpdateParams", + "ChangeBreakoutBehavior", + "ChangePriority", + "UpdateAccountAppID", + "UpdateManagedAppID", + "AccountAppManagedApp", + "ManagedAppAccountApp", +] + + +class ChangeBreakoutBehavior(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + body: Required[object] + + +class ChangePriority(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAccountAppID(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + account_app_id: Required[str] + """Magic account app ID.""" + + +class UpdateManagedAppID(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + managed_app_id: Required[str] + """Managed app ID.""" + + +class AccountAppManagedApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + account_app_id: Required[str] + """Magic account app ID.""" + + managed_app_id: Required[Optional[str]] + """**Must be set to null**""" + + +class ManagedAppAccountApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + account_app_id: Required[Optional[str]] + """**Must be set to null**""" + + managed_app_id: Required[str] + """Managed app ID.""" + + +AppConfigurationUpdateParams = Union[ + ChangeBreakoutBehavior, + ChangePriority, + UpdateAccountAppID, + UpdateManagedAppID, + AccountAppManagedApp, + ManagedAppAccountApp, +] diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py new file mode 100644 index 00000000000..01ef039b4e6 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationUpdateResponse"] + + +class AppConfigurationUpdateResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/tests/api_resources/addressing/regional_hostnames/__init__.py b/tests/api_resources/addressing/regional_hostnames/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/addressing/regional_hostnames/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/addressing/regional_hostnames/test_regions.py b/tests/api_resources/addressing/regional_hostnames/test_regions.py new file mode 100644 index 00000000000..5d23799e1bf --- /dev/null +++ b/tests/api_resources/addressing/regional_hostnames/test_regions.py @@ -0,0 +1,99 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.addressing.regional_hostnames import RegionListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRegions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + region = client.addressing.regional_hostnames.regions.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + region = response.parse() + assert_matches_type(SyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.regions.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + region = response.parse() + assert_matches_type(SyncSinglePage[RegionListResponse], region, 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.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="", + ) + + +class TestAsyncRegions: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + region = await async_client.addressing.regional_hostnames.regions.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + region = await response.parse() + assert_matches_type(AsyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.regions.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + region = await response.parse() + assert_matches_type(AsyncSinglePage[RegionListResponse], region, 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.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="", + ) diff --git a/tests/api_resources/addressing/test_regional_hostnames.py b/tests/api_resources/addressing/test_regional_hostnames.py new file mode 100644 index 00000000000..3dc5d085fba --- /dev/null +++ b/tests/api_resources/addressing/test_regional_hostnames.py @@ -0,0 +1,495 @@ +# 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 SyncSinglePage, AsyncSinglePage +from cloudflare.types.addressing import ( + RegionalHostnameGetResponse, + RegionalHostnameEditResponse, + RegionalHostnameListResponse, + RegionalHostnameCreateResponse, + RegionalHostnameDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRegionalHostnames: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, 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 `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.create( + zone_id="", + hostname="foo.example.com", + region_key="ca", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(SyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(SyncSinglePage[RegionalHostnameListResponse], regional_hostname, 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 `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.list( + zone_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, 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 `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + client.addressing.regional_hostnames.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, 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 `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="", + region_key="ca", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + client.addressing.regional_hostnames.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, 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 `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + client.addressing.regional_hostnames.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncRegionalHostnames: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, 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 `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.create( + zone_id="", + hostname="foo.example.com", + region_key="ca", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(AsyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(AsyncSinglePage[RegionalHostnameListResponse], regional_hostname, 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 `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.list( + zone_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, 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 `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, 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 `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="", + region_key="ca", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, 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 `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/sites/sites/__init__.py b/tests/api_resources/magic_transit/sites/sites/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/magic_transit/sites/sites/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py b/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py new file mode 100644 index 00000000000..65670e86460 --- /dev/null +++ b/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py @@ -0,0 +1,1272 @@ +# 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 SyncSinglePage, AsyncSinglePage +from cloudflare.types.magic_transit.sites.sites import ( + AppConfigurationListResponse, + AppConfigurationCreateResponse, + AppConfigurationDeleteResponse, + AppConfigurationUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAppConfiguration: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create_overload_1(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + def test_method_update_overload_1(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_3(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + def test_method_update_overload_4(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + def test_method_update_overload_5(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_5(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + @parametrize + def test_method_update_overload_6(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_6(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncAppConfiguration: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + @parametrize + async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_apps.py b/tests/api_resources/magic_transit/test_apps.py new file mode 100644 index 00000000000..32ba34bf644 --- /dev/null +++ b/tests/api_resources/magic_transit/test_apps.py @@ -0,0 +1,792 @@ +# 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 SyncSinglePage, AsyncSinglePage +from cloudflare.types.magic_transit import ( + AppListResponse, + AppCreateResponse, + AppDeleteResponse, + AppUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestApps: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create_overload_1(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + def test_method_update_overload_1(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_3(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_4(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(SyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(SyncSinglePage[AppListResponse], app, 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.magic_transit.apps.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, 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.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncApps: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(AsyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(AsyncSinglePage[AppListResponse], app, 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.magic_transit.apps.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, 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.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + )