diff --git a/.stats.yml b/.stats.yml index eba8f42b0c8..674596d454d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1448 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96e28d4d04ac2f1a00dda1130ef53e8bd9f2f1590e5d7ba8bed38cad29f8b2de.yml +configured_endpoints: 1436 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-511887ff04241247ce592a1c095e403a0fc8b376f7072c28bc59ced11f82e547.yml diff --git a/api.md b/api.md index a11b220bf61..a5fba1794a8 100644 --- a/api.md +++ b/api.md @@ -8274,62 +8274,14 @@ Types: ```python from cloudflare.types.resource_sharing import ( ResourceSharingCreateResponse, - ResourceSharingUpdateResponse, ResourceSharingListResponse, - ResourceSharingDeleteResponse, - ResourceSharingGetResponse, ) ``` Methods: - client.resource_sharing.create(\*, account_id, \*\*params) -> Optional -- client.resource_sharing.update(share_identifier, \*, account_id, \*\*params) -> Optional - client.resource_sharing.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[ResourceSharingListResponse] -- client.resource_sharing.delete(share_identifier, \*, account_id) -> Optional -- client.resource_sharing.get(share_identifier, \*, account_id) -> Optional - -## Recipients - -Types: - -```python -from cloudflare.types.resource_sharing import ( - RecipientCreateResponse, - RecipientListResponse, - RecipientDeleteResponse, - RecipientGetResponse, -) -``` - -Methods: - -- client.resource_sharing.recipients.create(share_identifier, \*, path_account_id, \*\*params) -> Optional -- client.resource_sharing.recipients.list(share_identifier, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[RecipientListResponse] -- client.resource_sharing.recipients.delete(recipient_identifier, \*, account_id, share_identifier) -> Optional -- client.resource_sharing.recipients.get(recipient_identifier, \*, account_id, share_identifier) -> Optional - -## Resources - -Types: - -```python -from cloudflare.types.resource_sharing import ( - ResourceCreateResponse, - ResourceUpdateResponse, - ResourceListResponse, - ResourceDeleteResponse, - ResourceGetResponse, -) -``` - -Methods: - -- client.resource_sharing.resources.create(share_identifier, \*, account_id, \*\*params) -> Optional -- client.resource_sharing.resources.update(resource_identifier, \*, account_id, share_identifier, \*\*params) -> Optional -- client.resource_sharing.resources.list(share_identifier, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ResourceListResponse] -- client.resource_sharing.resources.delete(resource_identifier, \*, account_id, share_identifier) -> Optional -- client.resource_sharing.resources.get(resource_identifier, \*, account_id, share_identifier) -> Optional # LeakedCredentialChecks diff --git a/src/cloudflare/resources/resource_sharing/__init__.py b/src/cloudflare/resources/resource_sharing/__init__.py index 3f72b0bc713..ecae72f2f38 100644 --- a/src/cloudflare/resources/resource_sharing/__init__.py +++ b/src/cloudflare/resources/resource_sharing/__init__.py @@ -1,21 +1,5 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from .resources import ( - ResourcesResource, - AsyncResourcesResource, - ResourcesResourceWithRawResponse, - AsyncResourcesResourceWithRawResponse, - ResourcesResourceWithStreamingResponse, - AsyncResourcesResourceWithStreamingResponse, -) -from .recipients import ( - RecipientsResource, - AsyncRecipientsResource, - RecipientsResourceWithRawResponse, - AsyncRecipientsResourceWithRawResponse, - RecipientsResourceWithStreamingResponse, - AsyncRecipientsResourceWithStreamingResponse, -) from .resource_sharing import ( ResourceSharingResource, AsyncResourceSharingResource, @@ -26,18 +10,6 @@ ) __all__ = [ - "RecipientsResource", - "AsyncRecipientsResource", - "RecipientsResourceWithRawResponse", - "AsyncRecipientsResourceWithRawResponse", - "RecipientsResourceWithStreamingResponse", - "AsyncRecipientsResourceWithStreamingResponse", - "ResourcesResource", - "AsyncResourcesResource", - "ResourcesResourceWithRawResponse", - "AsyncResourcesResourceWithRawResponse", - "ResourcesResourceWithStreamingResponse", - "AsyncResourcesResourceWithStreamingResponse", "ResourceSharingResource", "AsyncResourceSharingResource", "ResourceSharingResourceWithRawResponse", diff --git a/src/cloudflare/resources/resource_sharing/recipients.py b/src/cloudflare/resources/resource_sharing/recipients.py deleted file mode 100644 index 097c2ef96a8..00000000000 --- a/src/cloudflare/resources/resource_sharing/recipients.py +++ /dev/null @@ -1,579 +0,0 @@ -# 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 ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._wrappers import ResultWrapper -from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ..._base_client import AsyncPaginator, make_request_options -from ...types.resource_sharing import recipient_list_params, recipient_create_params -from ...types.resource_sharing.recipient_get_response import RecipientGetResponse -from ...types.resource_sharing.recipient_list_response import RecipientListResponse -from ...types.resource_sharing.recipient_create_response import RecipientCreateResponse -from ...types.resource_sharing.recipient_delete_response import RecipientDeleteResponse - -__all__ = ["RecipientsResource", "AsyncRecipientsResource"] - - -class RecipientsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> RecipientsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return RecipientsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> RecipientsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return RecipientsResourceWithStreamingResponse(self) - - def create( - self, - share_identifier: str, - *, - path_account_id: str, - body_account_id: str | NotGiven = NOT_GIVEN, - organization_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[RecipientCreateResponse]: - """ - Create a new share recipient - - Args: - path_account_id: Account identifier. - - share_identifier: Share identifier tag. - - body_account_id: Account identifier. - - organization_id: Organization 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 path_account_id: - raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._post( - f"/accounts/{path_account_id}/shares/{share_identifier}/recipients", - body=maybe_transform( - { - "body_account_id": body_account_id, - "organization_id": organization_id, - }, - recipient_create_params.RecipientCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RecipientCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RecipientCreateResponse]], ResultWrapper[RecipientCreateResponse]), - ) - - def list( - self, - share_identifier: str, - *, - account_id: str, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[RecipientListResponse]: - """ - List share recipients by share ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - page: Page number. - - per_page: Number of objects to return per page. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._get_api_list( - f"/accounts/{account_id}/shares/{share_identifier}/recipients", - page=SyncV4PagePaginationArray[RecipientListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - }, - recipient_list_params.RecipientListParams, - ), - ), - model=RecipientListResponse, - ) - - def delete( - self, - recipient_identifier: str, - *, - account_id: str, - share_identifier: 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[RecipientDeleteResponse]: - """ - Deletion is not immediate, an updated share recipient object with a new status - will be returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - recipient_identifier: Share Recipient identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not recipient_identifier: - raise ValueError( - f"Expected a non-empty value for `recipient_identifier` but received {recipient_identifier!r}" - ) - return self._delete( - f"/accounts/{account_id}/shares/{share_identifier}/recipients/{recipient_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RecipientDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RecipientDeleteResponse]], ResultWrapper[RecipientDeleteResponse]), - ) - - def get( - self, - recipient_identifier: str, - *, - account_id: str, - share_identifier: 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[RecipientGetResponse]: - """ - Get share recipient by ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - recipient_identifier: Share Recipient identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not recipient_identifier: - raise ValueError( - f"Expected a non-empty value for `recipient_identifier` but received {recipient_identifier!r}" - ) - return self._get( - f"/accounts/{account_id}/shares/{share_identifier}/recipients/{recipient_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RecipientGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RecipientGetResponse]], ResultWrapper[RecipientGetResponse]), - ) - - -class AsyncRecipientsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncRecipientsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncRecipientsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncRecipientsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncRecipientsResourceWithStreamingResponse(self) - - async def create( - self, - share_identifier: str, - *, - path_account_id: str, - body_account_id: str | NotGiven = NOT_GIVEN, - organization_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[RecipientCreateResponse]: - """ - Create a new share recipient - - Args: - path_account_id: Account identifier. - - share_identifier: Share identifier tag. - - body_account_id: Account identifier. - - organization_id: Organization 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 path_account_id: - raise ValueError(f"Expected a non-empty value for `path_account_id` but received {path_account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return await self._post( - f"/accounts/{path_account_id}/shares/{share_identifier}/recipients", - body=await async_maybe_transform( - { - "body_account_id": body_account_id, - "organization_id": organization_id, - }, - recipient_create_params.RecipientCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RecipientCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RecipientCreateResponse]], ResultWrapper[RecipientCreateResponse]), - ) - - def list( - self, - share_identifier: str, - *, - account_id: str, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[RecipientListResponse, AsyncV4PagePaginationArray[RecipientListResponse]]: - """ - List share recipients by share ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - page: Page number. - - per_page: Number of objects to return per page. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._get_api_list( - f"/accounts/{account_id}/shares/{share_identifier}/recipients", - page=AsyncV4PagePaginationArray[RecipientListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - }, - recipient_list_params.RecipientListParams, - ), - ), - model=RecipientListResponse, - ) - - async def delete( - self, - recipient_identifier: str, - *, - account_id: str, - share_identifier: 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[RecipientDeleteResponse]: - """ - Deletion is not immediate, an updated share recipient object with a new status - will be returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - recipient_identifier: Share Recipient identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not recipient_identifier: - raise ValueError( - f"Expected a non-empty value for `recipient_identifier` but received {recipient_identifier!r}" - ) - return await self._delete( - f"/accounts/{account_id}/shares/{share_identifier}/recipients/{recipient_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RecipientDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RecipientDeleteResponse]], ResultWrapper[RecipientDeleteResponse]), - ) - - async def get( - self, - recipient_identifier: str, - *, - account_id: str, - share_identifier: 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[RecipientGetResponse]: - """ - Get share recipient by ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - recipient_identifier: Share Recipient identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not recipient_identifier: - raise ValueError( - f"Expected a non-empty value for `recipient_identifier` but received {recipient_identifier!r}" - ) - return await self._get( - f"/accounts/{account_id}/shares/{share_identifier}/recipients/{recipient_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RecipientGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RecipientGetResponse]], ResultWrapper[RecipientGetResponse]), - ) - - -class RecipientsResourceWithRawResponse: - def __init__(self, recipients: RecipientsResource) -> None: - self._recipients = recipients - - self.create = to_raw_response_wrapper( - recipients.create, - ) - self.list = to_raw_response_wrapper( - recipients.list, - ) - self.delete = to_raw_response_wrapper( - recipients.delete, - ) - self.get = to_raw_response_wrapper( - recipients.get, - ) - - -class AsyncRecipientsResourceWithRawResponse: - def __init__(self, recipients: AsyncRecipientsResource) -> None: - self._recipients = recipients - - self.create = async_to_raw_response_wrapper( - recipients.create, - ) - self.list = async_to_raw_response_wrapper( - recipients.list, - ) - self.delete = async_to_raw_response_wrapper( - recipients.delete, - ) - self.get = async_to_raw_response_wrapper( - recipients.get, - ) - - -class RecipientsResourceWithStreamingResponse: - def __init__(self, recipients: RecipientsResource) -> None: - self._recipients = recipients - - self.create = to_streamed_response_wrapper( - recipients.create, - ) - self.list = to_streamed_response_wrapper( - recipients.list, - ) - self.delete = to_streamed_response_wrapper( - recipients.delete, - ) - self.get = to_streamed_response_wrapper( - recipients.get, - ) - - -class AsyncRecipientsResourceWithStreamingResponse: - def __init__(self, recipients: AsyncRecipientsResource) -> None: - self._recipients = recipients - - self.create = async_to_streamed_response_wrapper( - recipients.create, - ) - self.list = async_to_streamed_response_wrapper( - recipients.list, - ) - self.delete = async_to_streamed_response_wrapper( - recipients.delete, - ) - self.get = async_to_streamed_response_wrapper( - recipients.get, - ) diff --git a/src/cloudflare/resources/resource_sharing/resource_sharing.py b/src/cloudflare/resources/resource_sharing/resource_sharing.py index ac039aef464..0267bb390f0 100644 --- a/src/cloudflare/resources/resource_sharing/resource_sharing.py +++ b/src/cloudflare/resources/resource_sharing/resource_sharing.py @@ -13,22 +13,6 @@ async_maybe_transform, ) from ..._compat import cached_property -from .resources import ( - ResourcesResource, - AsyncResourcesResource, - ResourcesResourceWithRawResponse, - AsyncResourcesResourceWithRawResponse, - ResourcesResourceWithStreamingResponse, - AsyncResourcesResourceWithStreamingResponse, -) -from .recipients import ( - RecipientsResource, - AsyncRecipientsResource, - RecipientsResourceWithRawResponse, - AsyncRecipientsResourceWithRawResponse, - RecipientsResourceWithStreamingResponse, - AsyncRecipientsResourceWithStreamingResponse, -) from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, @@ -39,29 +23,14 @@ from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ..._base_client import AsyncPaginator, make_request_options -from ...types.resource_sharing import ( - resource_sharing_list_params, - resource_sharing_create_params, - resource_sharing_update_params, -) -from ...types.resource_sharing.resource_sharing_get_response import ResourceSharingGetResponse +from ...types.resource_sharing import resource_sharing_list_params, resource_sharing_create_params from ...types.resource_sharing.resource_sharing_list_response import ResourceSharingListResponse from ...types.resource_sharing.resource_sharing_create_response import ResourceSharingCreateResponse -from ...types.resource_sharing.resource_sharing_delete_response import ResourceSharingDeleteResponse -from ...types.resource_sharing.resource_sharing_update_response import ResourceSharingUpdateResponse __all__ = ["ResourceSharingResource", "AsyncResourceSharingResource"] class ResourceSharingResource(SyncAPIResource): - @cached_property - def recipients(self) -> RecipientsResource: - return RecipientsResource(self._client) - - @cached_property - def resources(self) -> ResourcesResource: - return ResourcesResource(self._client) - @cached_property def with_raw_response(self) -> ResourceSharingResourceWithRawResponse: """ @@ -133,55 +102,6 @@ def create( cast_to=cast(Type[Optional[ResourceSharingCreateResponse]], ResultWrapper[ResourceSharingCreateResponse]), ) - def update( - self, - share_identifier: str, - *, - account_id: str, - name: 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[ResourceSharingUpdateResponse]: - """ - Updating is not immediate, an updated share object with a new status will be - returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - name: The name of the share. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._put( - f"/accounts/{account_id}/shares/{share_identifier}", - body=maybe_transform({"name": name}, resource_sharing_update_params.ResourceSharingUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceSharingUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceSharingUpdateResponse]], ResultWrapper[ResourceSharingUpdateResponse]), - ) - def list( self, *, @@ -254,105 +174,8 @@ def list( model=ResourceSharingListResponse, ) - def delete( - self, - share_identifier: 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[ResourceSharingDeleteResponse]: - """ - Deletion is not immediate, an updated share object with a new status will be - returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._delete( - f"/accounts/{account_id}/shares/{share_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceSharingDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceSharingDeleteResponse]], ResultWrapper[ResourceSharingDeleteResponse]), - ) - - def get( - self, - share_identifier: 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[ResourceSharingGetResponse]: - """ - Fetches share by ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._get( - f"/accounts/{account_id}/shares/{share_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceSharingGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceSharingGetResponse]], ResultWrapper[ResourceSharingGetResponse]), - ) - class AsyncResourceSharingResource(AsyncAPIResource): - @cached_property - def recipients(self) -> AsyncRecipientsResource: - return AsyncRecipientsResource(self._client) - - @cached_property - def resources(self) -> AsyncResourcesResource: - return AsyncResourcesResource(self._client) - @cached_property def with_raw_response(self) -> AsyncResourceSharingResourceWithRawResponse: """ @@ -424,57 +247,6 @@ async def create( cast_to=cast(Type[Optional[ResourceSharingCreateResponse]], ResultWrapper[ResourceSharingCreateResponse]), ) - async def update( - self, - share_identifier: str, - *, - account_id: str, - name: 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[ResourceSharingUpdateResponse]: - """ - Updating is not immediate, an updated share object with a new status will be - returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - name: The name of the share. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return await self._put( - f"/accounts/{account_id}/shares/{share_identifier}", - body=await async_maybe_transform( - {"name": name}, resource_sharing_update_params.ResourceSharingUpdateParams - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceSharingUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceSharingUpdateResponse]], ResultWrapper[ResourceSharingUpdateResponse]), - ) - def list( self, *, @@ -547,95 +319,6 @@ def list( model=ResourceSharingListResponse, ) - async def delete( - self, - share_identifier: 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[ResourceSharingDeleteResponse]: - """ - Deletion is not immediate, an updated share object with a new status will be - returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return await self._delete( - f"/accounts/{account_id}/shares/{share_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceSharingDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceSharingDeleteResponse]], ResultWrapper[ResourceSharingDeleteResponse]), - ) - - async def get( - self, - share_identifier: 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[ResourceSharingGetResponse]: - """ - Fetches share by ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return await self._get( - f"/accounts/{account_id}/shares/{share_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceSharingGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceSharingGetResponse]], ResultWrapper[ResourceSharingGetResponse]), - ) - class ResourceSharingResourceWithRawResponse: def __init__(self, resource_sharing: ResourceSharingResource) -> None: @@ -644,26 +327,9 @@ def __init__(self, resource_sharing: ResourceSharingResource) -> None: self.create = to_raw_response_wrapper( resource_sharing.create, ) - self.update = to_raw_response_wrapper( - resource_sharing.update, - ) self.list = to_raw_response_wrapper( resource_sharing.list, ) - self.delete = to_raw_response_wrapper( - resource_sharing.delete, - ) - self.get = to_raw_response_wrapper( - resource_sharing.get, - ) - - @cached_property - def recipients(self) -> RecipientsResourceWithRawResponse: - return RecipientsResourceWithRawResponse(self._resource_sharing.recipients) - - @cached_property - def resources(self) -> ResourcesResourceWithRawResponse: - return ResourcesResourceWithRawResponse(self._resource_sharing.resources) class AsyncResourceSharingResourceWithRawResponse: @@ -673,26 +339,9 @@ def __init__(self, resource_sharing: AsyncResourceSharingResource) -> None: self.create = async_to_raw_response_wrapper( resource_sharing.create, ) - self.update = async_to_raw_response_wrapper( - resource_sharing.update, - ) self.list = async_to_raw_response_wrapper( resource_sharing.list, ) - self.delete = async_to_raw_response_wrapper( - resource_sharing.delete, - ) - self.get = async_to_raw_response_wrapper( - resource_sharing.get, - ) - - @cached_property - def recipients(self) -> AsyncRecipientsResourceWithRawResponse: - return AsyncRecipientsResourceWithRawResponse(self._resource_sharing.recipients) - - @cached_property - def resources(self) -> AsyncResourcesResourceWithRawResponse: - return AsyncResourcesResourceWithRawResponse(self._resource_sharing.resources) class ResourceSharingResourceWithStreamingResponse: @@ -702,26 +351,9 @@ def __init__(self, resource_sharing: ResourceSharingResource) -> None: self.create = to_streamed_response_wrapper( resource_sharing.create, ) - self.update = to_streamed_response_wrapper( - resource_sharing.update, - ) self.list = to_streamed_response_wrapper( resource_sharing.list, ) - self.delete = to_streamed_response_wrapper( - resource_sharing.delete, - ) - self.get = to_streamed_response_wrapper( - resource_sharing.get, - ) - - @cached_property - def recipients(self) -> RecipientsResourceWithStreamingResponse: - return RecipientsResourceWithStreamingResponse(self._resource_sharing.recipients) - - @cached_property - def resources(self) -> ResourcesResourceWithStreamingResponse: - return ResourcesResourceWithStreamingResponse(self._resource_sharing.resources) class AsyncResourceSharingResourceWithStreamingResponse: @@ -731,23 +363,6 @@ def __init__(self, resource_sharing: AsyncResourceSharingResource) -> None: self.create = async_to_streamed_response_wrapper( resource_sharing.create, ) - self.update = async_to_streamed_response_wrapper( - resource_sharing.update, - ) self.list = async_to_streamed_response_wrapper( resource_sharing.list, ) - self.delete = async_to_streamed_response_wrapper( - resource_sharing.delete, - ) - self.get = async_to_streamed_response_wrapper( - resource_sharing.get, - ) - - @cached_property - def recipients(self) -> AsyncRecipientsResourceWithStreamingResponse: - return AsyncRecipientsResourceWithStreamingResponse(self._resource_sharing.recipients) - - @cached_property - def resources(self) -> AsyncResourcesResourceWithStreamingResponse: - return AsyncResourcesResourceWithStreamingResponse(self._resource_sharing.resources) diff --git a/src/cloudflare/resources/resource_sharing/resources.py b/src/cloudflare/resources/resource_sharing/resources.py deleted file mode 100644 index fbd116c8c39..00000000000 --- a/src/cloudflare/resources/resource_sharing/resources.py +++ /dev/null @@ -1,737 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, Optional, cast -from typing_extensions import Literal - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._wrappers import ResultWrapper -from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ..._base_client import AsyncPaginator, make_request_options -from ...types.resource_sharing import resource_list_params, resource_create_params, resource_update_params -from ...types.resource_sharing.resource_get_response import ResourceGetResponse -from ...types.resource_sharing.resource_list_response import ResourceListResponse -from ...types.resource_sharing.resource_create_response import ResourceCreateResponse -from ...types.resource_sharing.resource_delete_response import ResourceDeleteResponse -from ...types.resource_sharing.resource_update_response import ResourceUpdateResponse - -__all__ = ["ResourcesResource", "AsyncResourcesResource"] - - -class ResourcesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> ResourcesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return ResourcesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> ResourcesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return ResourcesResourceWithStreamingResponse(self) - - def create( - self, - share_identifier: str, - *, - account_id: str, - meta: object, - resource_account_id: str, - resource_id: str, - resource_type: Literal["custom-ruleset"], - # 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[ResourceCreateResponse]: - """ - Create a new share resource - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - meta: Resource Metadata. - - resource_account_id: Account identifier. - - resource_id: Share Resource identifier. - - resource_type: Resource Type. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._post( - f"/accounts/{account_id}/shares/{share_identifier}/resources", - body=maybe_transform( - { - "meta": meta, - "resource_account_id": resource_account_id, - "resource_id": resource_id, - "resource_type": resource_type, - }, - resource_create_params.ResourceCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceCreateResponse]], ResultWrapper[ResourceCreateResponse]), - ) - - def update( - self, - resource_identifier: str, - *, - account_id: str, - share_identifier: str, - meta: 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[ResourceUpdateResponse]: - """ - Update is not immediate, an updated share resource object with a new status will - be returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - resource_identifier: Share Resource identifier. - - meta: Resource Metadata. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not resource_identifier: - raise ValueError( - f"Expected a non-empty value for `resource_identifier` but received {resource_identifier!r}" - ) - return self._put( - f"/accounts/{account_id}/shares/{share_identifier}/resources/{resource_identifier}", - body=maybe_transform({"meta": meta}, resource_update_params.ResourceUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceUpdateResponse]], ResultWrapper[ResourceUpdateResponse]), - ) - - def list( - self, - share_identifier: str, - *, - account_id: str, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - resource_type: Literal["custom-ruleset"] | NotGiven = NOT_GIVEN, - status: Literal["active", "deleting", "deleted"] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[ResourceListResponse]: - """ - List share resources by share ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - page: Page number. - - per_page: Number of objects to return per page. - - resource_type: Filter share resources by resource_type. - - status: Filter share resources by status. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._get_api_list( - f"/accounts/{account_id}/shares/{share_identifier}/resources", - page=SyncV4PagePaginationArray[ResourceListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - "resource_type": resource_type, - "status": status, - }, - resource_list_params.ResourceListParams, - ), - ), - model=ResourceListResponse, - ) - - def delete( - self, - resource_identifier: str, - *, - account_id: str, - share_identifier: 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[ResourceDeleteResponse]: - """ - Deletion is not immediate, an updated share resource object with a new status - will be returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - resource_identifier: Share Resource 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not resource_identifier: - raise ValueError( - f"Expected a non-empty value for `resource_identifier` but received {resource_identifier!r}" - ) - return self._delete( - f"/accounts/{account_id}/shares/{share_identifier}/resources/{resource_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceDeleteResponse]], ResultWrapper[ResourceDeleteResponse]), - ) - - def get( - self, - resource_identifier: str, - *, - account_id: str, - share_identifier: 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[ResourceGetResponse]: - """ - Get share resource by ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - resource_identifier: Share Resource 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not resource_identifier: - raise ValueError( - f"Expected a non-empty value for `resource_identifier` but received {resource_identifier!r}" - ) - return self._get( - f"/accounts/{account_id}/shares/{share_identifier}/resources/{resource_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceGetResponse]], ResultWrapper[ResourceGetResponse]), - ) - - -class AsyncResourcesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncResourcesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncResourcesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncResourcesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncResourcesResourceWithStreamingResponse(self) - - async def create( - self, - share_identifier: str, - *, - account_id: str, - meta: object, - resource_account_id: str, - resource_id: str, - resource_type: Literal["custom-ruleset"], - # 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[ResourceCreateResponse]: - """ - Create a new share resource - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - meta: Resource Metadata. - - resource_account_id: Account identifier. - - resource_id: Share Resource identifier. - - resource_type: Resource Type. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return await self._post( - f"/accounts/{account_id}/shares/{share_identifier}/resources", - body=await async_maybe_transform( - { - "meta": meta, - "resource_account_id": resource_account_id, - "resource_id": resource_id, - "resource_type": resource_type, - }, - resource_create_params.ResourceCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceCreateResponse]], ResultWrapper[ResourceCreateResponse]), - ) - - async def update( - self, - resource_identifier: str, - *, - account_id: str, - share_identifier: str, - meta: 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[ResourceUpdateResponse]: - """ - Update is not immediate, an updated share resource object with a new status will - be returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - resource_identifier: Share Resource identifier. - - meta: Resource Metadata. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not resource_identifier: - raise ValueError( - f"Expected a non-empty value for `resource_identifier` but received {resource_identifier!r}" - ) - return await self._put( - f"/accounts/{account_id}/shares/{share_identifier}/resources/{resource_identifier}", - body=await async_maybe_transform({"meta": meta}, resource_update_params.ResourceUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceUpdateResponse]], ResultWrapper[ResourceUpdateResponse]), - ) - - def list( - self, - share_identifier: str, - *, - account_id: str, - page: int | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - resource_type: Literal["custom-ruleset"] | NotGiven = NOT_GIVEN, - status: Literal["active", "deleting", "deleted"] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[ResourceListResponse, AsyncV4PagePaginationArray[ResourceListResponse]]: - """ - List share resources by share ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - page: Page number. - - per_page: Number of objects to return per page. - - resource_type: Filter share resources by resource_type. - - status: Filter share resources by status. - - 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - return self._get_api_list( - f"/accounts/{account_id}/shares/{share_identifier}/resources", - page=AsyncV4PagePaginationArray[ResourceListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - "resource_type": resource_type, - "status": status, - }, - resource_list_params.ResourceListParams, - ), - ), - model=ResourceListResponse, - ) - - async def delete( - self, - resource_identifier: str, - *, - account_id: str, - share_identifier: 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[ResourceDeleteResponse]: - """ - Deletion is not immediate, an updated share resource object with a new status - will be returned. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - resource_identifier: Share Resource 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not resource_identifier: - raise ValueError( - f"Expected a non-empty value for `resource_identifier` but received {resource_identifier!r}" - ) - return await self._delete( - f"/accounts/{account_id}/shares/{share_identifier}/resources/{resource_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceDeleteResponse]], ResultWrapper[ResourceDeleteResponse]), - ) - - async def get( - self, - resource_identifier: str, - *, - account_id: str, - share_identifier: 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[ResourceGetResponse]: - """ - Get share resource by ID. - - Args: - account_id: Account identifier. - - share_identifier: Share identifier tag. - - resource_identifier: Share Resource 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 share_identifier: - raise ValueError(f"Expected a non-empty value for `share_identifier` but received {share_identifier!r}") - if not resource_identifier: - raise ValueError( - f"Expected a non-empty value for `resource_identifier` but received {resource_identifier!r}" - ) - return await self._get( - f"/accounts/{account_id}/shares/{share_identifier}/resources/{resource_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ResourceGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ResourceGetResponse]], ResultWrapper[ResourceGetResponse]), - ) - - -class ResourcesResourceWithRawResponse: - def __init__(self, resources: ResourcesResource) -> None: - self._resources = resources - - self.create = to_raw_response_wrapper( - resources.create, - ) - self.update = to_raw_response_wrapper( - resources.update, - ) - self.list = to_raw_response_wrapper( - resources.list, - ) - self.delete = to_raw_response_wrapper( - resources.delete, - ) - self.get = to_raw_response_wrapper( - resources.get, - ) - - -class AsyncResourcesResourceWithRawResponse: - def __init__(self, resources: AsyncResourcesResource) -> None: - self._resources = resources - - self.create = async_to_raw_response_wrapper( - resources.create, - ) - self.update = async_to_raw_response_wrapper( - resources.update, - ) - self.list = async_to_raw_response_wrapper( - resources.list, - ) - self.delete = async_to_raw_response_wrapper( - resources.delete, - ) - self.get = async_to_raw_response_wrapper( - resources.get, - ) - - -class ResourcesResourceWithStreamingResponse: - def __init__(self, resources: ResourcesResource) -> None: - self._resources = resources - - self.create = to_streamed_response_wrapper( - resources.create, - ) - self.update = to_streamed_response_wrapper( - resources.update, - ) - self.list = to_streamed_response_wrapper( - resources.list, - ) - self.delete = to_streamed_response_wrapper( - resources.delete, - ) - self.get = to_streamed_response_wrapper( - resources.get, - ) - - -class AsyncResourcesResourceWithStreamingResponse: - def __init__(self, resources: AsyncResourcesResource) -> None: - self._resources = resources - - self.create = async_to_streamed_response_wrapper( - resources.create, - ) - self.update = async_to_streamed_response_wrapper( - resources.update, - ) - self.list = async_to_streamed_response_wrapper( - resources.list, - ) - self.delete = async_to_streamed_response_wrapper( - resources.delete, - ) - self.get = async_to_streamed_response_wrapper( - resources.get, - ) diff --git a/src/cloudflare/types/resource_sharing/__init__.py b/src/cloudflare/types/resource_sharing/__init__.py index 7fcb1c45e77..bddc9f8c12f 100644 --- a/src/cloudflare/types/resource_sharing/__init__.py +++ b/src/cloudflare/types/resource_sharing/__init__.py @@ -2,25 +2,7 @@ from __future__ import annotations -from .resource_list_params import ResourceListParams as ResourceListParams -from .recipient_list_params import RecipientListParams as RecipientListParams -from .resource_get_response import ResourceGetResponse as ResourceGetResponse -from .recipient_get_response import RecipientGetResponse as RecipientGetResponse -from .resource_create_params import ResourceCreateParams as ResourceCreateParams -from .resource_list_response import ResourceListResponse as ResourceListResponse -from .resource_update_params import ResourceUpdateParams as ResourceUpdateParams -from .recipient_create_params import RecipientCreateParams as RecipientCreateParams -from .recipient_list_response import RecipientListResponse as RecipientListResponse -from .resource_create_response import ResourceCreateResponse as ResourceCreateResponse -from .resource_delete_response import ResourceDeleteResponse as ResourceDeleteResponse -from .resource_update_response import ResourceUpdateResponse as ResourceUpdateResponse -from .recipient_create_response import RecipientCreateResponse as RecipientCreateResponse -from .recipient_delete_response import RecipientDeleteResponse as RecipientDeleteResponse from .resource_sharing_list_params import ResourceSharingListParams as ResourceSharingListParams -from .resource_sharing_get_response import ResourceSharingGetResponse as ResourceSharingGetResponse from .resource_sharing_create_params import ResourceSharingCreateParams as ResourceSharingCreateParams from .resource_sharing_list_response import ResourceSharingListResponse as ResourceSharingListResponse -from .resource_sharing_update_params import ResourceSharingUpdateParams as ResourceSharingUpdateParams from .resource_sharing_create_response import ResourceSharingCreateResponse as ResourceSharingCreateResponse -from .resource_sharing_delete_response import ResourceSharingDeleteResponse as ResourceSharingDeleteResponse -from .resource_sharing_update_response import ResourceSharingUpdateResponse as ResourceSharingUpdateResponse diff --git a/src/cloudflare/types/resource_sharing/recipient_create_params.py b/src/cloudflare/types/resource_sharing/recipient_create_params.py deleted file mode 100644 index 58b143bcada..00000000000 --- a/src/cloudflare/types/resource_sharing/recipient_create_params.py +++ /dev/null @@ -1,20 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, Annotated, TypedDict - -from ..._utils import PropertyInfo - -__all__ = ["RecipientCreateParams"] - - -class RecipientCreateParams(TypedDict, total=False): - path_account_id: Required[Annotated[str, PropertyInfo(alias="account_id")]] - """Account identifier.""" - - body_account_id: Annotated[str, PropertyInfo(alias="account_id")] - """Account identifier.""" - - organization_id: str - """Organization identifier.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_create_response.py b/src/cloudflare/types/resource_sharing/recipient_create_response.py deleted file mode 100644 index 8bc8a37b309..00000000000 --- a/src/cloudflare/types/resource_sharing/recipient_create_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["RecipientCreateResponse"] - - -class RecipientCreateResponse(BaseModel): - id: str - """Share Recipient identifier tag.""" - - account_id: str - """Account identifier.""" - - association_status: Literal["associating", "associated", "disassociating", "disassociated"] - """Share Recipient association status.""" - - created: datetime - """When the share was created.""" - - modified: datetime - """When the share was modified.""" - - status_message: str - """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_delete_response.py b/src/cloudflare/types/resource_sharing/recipient_delete_response.py deleted file mode 100644 index cb979d49054..00000000000 --- a/src/cloudflare/types/resource_sharing/recipient_delete_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["RecipientDeleteResponse"] - - -class RecipientDeleteResponse(BaseModel): - id: str - """Share Recipient identifier tag.""" - - account_id: str - """Account identifier.""" - - association_status: Literal["associating", "associated", "disassociating", "disassociated"] - """Share Recipient association status.""" - - created: datetime - """When the share was created.""" - - modified: datetime - """When the share was modified.""" - - status_message: str - """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_get_response.py b/src/cloudflare/types/resource_sharing/recipient_get_response.py deleted file mode 100644 index 19f64200d47..00000000000 --- a/src/cloudflare/types/resource_sharing/recipient_get_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["RecipientGetResponse"] - - -class RecipientGetResponse(BaseModel): - id: str - """Share Recipient identifier tag.""" - - account_id: str - """Account identifier.""" - - association_status: Literal["associating", "associated", "disassociating", "disassociated"] - """Share Recipient association status.""" - - created: datetime - """When the share was created.""" - - modified: datetime - """When the share was modified.""" - - status_message: str - """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_list_params.py b/src/cloudflare/types/resource_sharing/recipient_list_params.py deleted file mode 100644 index baafcde07b0..00000000000 --- a/src/cloudflare/types/resource_sharing/recipient_list_params.py +++ /dev/null @@ -1,18 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["RecipientListParams"] - - -class RecipientListParams(TypedDict, total=False): - account_id: Required[str] - """Account identifier.""" - - page: int - """Page number.""" - - per_page: int - """Number of objects to return per page.""" diff --git a/src/cloudflare/types/resource_sharing/recipient_list_response.py b/src/cloudflare/types/resource_sharing/recipient_list_response.py deleted file mode 100644 index 7fe67f036d0..00000000000 --- a/src/cloudflare/types/resource_sharing/recipient_list_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["RecipientListResponse"] - - -class RecipientListResponse(BaseModel): - id: str - """Share Recipient identifier tag.""" - - account_id: str - """Account identifier.""" - - association_status: Literal["associating", "associated", "disassociating", "disassociated"] - """Share Recipient association status.""" - - created: datetime - """When the share was created.""" - - modified: datetime - """When the share was modified.""" - - status_message: str - """Share Recipient status message.""" diff --git a/src/cloudflare/types/resource_sharing/resource_create_params.py b/src/cloudflare/types/resource_sharing/resource_create_params.py deleted file mode 100644 index adb7ca72280..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_create_params.py +++ /dev/null @@ -1,24 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["ResourceCreateParams"] - - -class ResourceCreateParams(TypedDict, total=False): - account_id: Required[str] - """Account identifier.""" - - meta: Required[object] - """Resource Metadata.""" - - resource_account_id: Required[str] - """Account identifier.""" - - resource_id: Required[str] - """Share Resource identifier.""" - - resource_type: Required[Literal["custom-ruleset"]] - """Resource Type.""" diff --git a/src/cloudflare/types/resource_sharing/resource_create_response.py b/src/cloudflare/types/resource_sharing/resource_create_response.py deleted file mode 100644 index 4e89c91fc7b..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_create_response.py +++ /dev/null @@ -1,37 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceCreateResponse"] - - -class ResourceCreateResponse(BaseModel): - id: str - """Share Resource identifier.""" - - created: datetime - """When the share was created.""" - - meta: object - """Resource Metadata.""" - - modified: datetime - """When the share was modified.""" - - resource_account_id: str - """Account identifier.""" - - resource_id: str - """Share Resource identifier.""" - - resource_type: Literal["custom-ruleset"] - """Resource Type.""" - - resource_version: int - """Resource Version.""" - - status: Literal["active", "deleting", "deleted"] - """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_delete_response.py b/src/cloudflare/types/resource_sharing/resource_delete_response.py deleted file mode 100644 index 3fa457918f4..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_delete_response.py +++ /dev/null @@ -1,37 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceDeleteResponse"] - - -class ResourceDeleteResponse(BaseModel): - id: str - """Share Resource identifier.""" - - created: datetime - """When the share was created.""" - - meta: object - """Resource Metadata.""" - - modified: datetime - """When the share was modified.""" - - resource_account_id: str - """Account identifier.""" - - resource_id: str - """Share Resource identifier.""" - - resource_type: Literal["custom-ruleset"] - """Resource Type.""" - - resource_version: int - """Resource Version.""" - - status: Literal["active", "deleting", "deleted"] - """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_get_response.py b/src/cloudflare/types/resource_sharing/resource_get_response.py deleted file mode 100644 index 17bfc4fd628..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_get_response.py +++ /dev/null @@ -1,37 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceGetResponse"] - - -class ResourceGetResponse(BaseModel): - id: str - """Share Resource identifier.""" - - created: datetime - """When the share was created.""" - - meta: object - """Resource Metadata.""" - - modified: datetime - """When the share was modified.""" - - resource_account_id: str - """Account identifier.""" - - resource_id: str - """Share Resource identifier.""" - - resource_type: Literal["custom-ruleset"] - """Resource Type.""" - - resource_version: int - """Resource Version.""" - - status: Literal["active", "deleting", "deleted"] - """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_list_params.py b/src/cloudflare/types/resource_sharing/resource_list_params.py deleted file mode 100644 index e70c3d7cc42..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_list_params.py +++ /dev/null @@ -1,24 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["ResourceListParams"] - - -class ResourceListParams(TypedDict, total=False): - account_id: Required[str] - """Account identifier.""" - - page: int - """Page number.""" - - per_page: int - """Number of objects to return per page.""" - - resource_type: Literal["custom-ruleset"] - """Filter share resources by resource_type.""" - - status: Literal["active", "deleting", "deleted"] - """Filter share resources by status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_list_response.py b/src/cloudflare/types/resource_sharing/resource_list_response.py deleted file mode 100644 index 55ea6e0d7a0..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_list_response.py +++ /dev/null @@ -1,37 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceListResponse"] - - -class ResourceListResponse(BaseModel): - id: str - """Share Resource identifier.""" - - created: datetime - """When the share was created.""" - - meta: object - """Resource Metadata.""" - - modified: datetime - """When the share was modified.""" - - resource_account_id: str - """Account identifier.""" - - resource_id: str - """Share Resource identifier.""" - - resource_type: Literal["custom-ruleset"] - """Resource Type.""" - - resource_version: int - """Resource Version.""" - - status: Literal["active", "deleting", "deleted"] - """Resource Status.""" diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py b/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py index 12ac5d50b6c..748a704d567 100644 --- a/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py +++ b/src/cloudflare/types/resource_sharing/resource_sharing_create_params.py @@ -38,5 +38,5 @@ class Resource(TypedDict, total=False): resource_id: Required[str] """Share Resource identifier.""" - resource_type: Required[Literal["custom-ruleset"]] + resource_type: Required[Literal["custom-ruleset", "widget"]] """Resource Type.""" diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_delete_response.py b/src/cloudflare/types/resource_sharing/resource_sharing_delete_response.py deleted file mode 100644 index 655a9a6e364..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_sharing_delete_response.py +++ /dev/null @@ -1,38 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceSharingDeleteResponse"] - - -class ResourceSharingDeleteResponse(BaseModel): - id: str - """Share identifier tag.""" - - account_id: str - """Account identifier.""" - - account_name: str - """The display name of an account.""" - - created: datetime - """When the share was created.""" - - modified: datetime - """When the share was modified.""" - - name: str - """The name of the share.""" - - organization_id: str - """Organization identifier.""" - - status: Literal["active", "deleting", "deleted"] - - target_type: Literal["account", "organization"] - - kind: Optional[Literal["sent", "received"]] = None diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_get_response.py b/src/cloudflare/types/resource_sharing/resource_sharing_get_response.py deleted file mode 100644 index b7bc736b975..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_sharing_get_response.py +++ /dev/null @@ -1,38 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceSharingGetResponse"] - - -class ResourceSharingGetResponse(BaseModel): - id: str - """Share identifier tag.""" - - account_id: str - """Account identifier.""" - - account_name: str - """The display name of an account.""" - - created: datetime - """When the share was created.""" - - modified: datetime - """When the share was modified.""" - - name: str - """The name of the share.""" - - organization_id: str - """Organization identifier.""" - - status: Literal["active", "deleting", "deleted"] - - target_type: Literal["account", "organization"] - - kind: Optional[Literal["sent", "received"]] = None diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py b/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py deleted file mode 100644 index 6d796532f5a..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_sharing_update_params.py +++ /dev/null @@ -1,15 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["ResourceSharingUpdateParams"] - - -class ResourceSharingUpdateParams(TypedDict, total=False): - account_id: Required[str] - """Account identifier.""" - - name: Required[str] - """The name of the share.""" diff --git a/src/cloudflare/types/resource_sharing/resource_sharing_update_response.py b/src/cloudflare/types/resource_sharing/resource_sharing_update_response.py deleted file mode 100644 index f4d087b6fc1..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_sharing_update_response.py +++ /dev/null @@ -1,38 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceSharingUpdateResponse"] - - -class ResourceSharingUpdateResponse(BaseModel): - id: str - """Share identifier tag.""" - - account_id: str - """Account identifier.""" - - account_name: str - """The display name of an account.""" - - created: datetime - """When the share was created.""" - - modified: datetime - """When the share was modified.""" - - name: str - """The name of the share.""" - - organization_id: str - """Organization identifier.""" - - status: Literal["active", "deleting", "deleted"] - - target_type: Literal["account", "organization"] - - kind: Optional[Literal["sent", "received"]] = None diff --git a/src/cloudflare/types/resource_sharing/resource_update_params.py b/src/cloudflare/types/resource_sharing/resource_update_params.py deleted file mode 100644 index ea1227b0e06..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_update_params.py +++ /dev/null @@ -1,18 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["ResourceUpdateParams"] - - -class ResourceUpdateParams(TypedDict, total=False): - account_id: Required[str] - """Account identifier.""" - - share_identifier: Required[str] - """Share identifier tag.""" - - meta: Required[object] - """Resource Metadata.""" diff --git a/src/cloudflare/types/resource_sharing/resource_update_response.py b/src/cloudflare/types/resource_sharing/resource_update_response.py deleted file mode 100644 index 3c04b69c4a1..00000000000 --- a/src/cloudflare/types/resource_sharing/resource_update_response.py +++ /dev/null @@ -1,37 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from datetime import datetime -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ResourceUpdateResponse"] - - -class ResourceUpdateResponse(BaseModel): - id: str - """Share Resource identifier.""" - - created: datetime - """When the share was created.""" - - meta: object - """Resource Metadata.""" - - modified: datetime - """When the share was modified.""" - - resource_account_id: str - """Account identifier.""" - - resource_id: str - """Share Resource identifier.""" - - resource_type: Literal["custom-ruleset"] - """Resource Type.""" - - resource_version: int - """Resource Version.""" - - status: Literal["active", "deleting", "deleted"] - """Resource Status.""" diff --git a/tests/api_resources/resource_sharing/test_recipients.py b/tests/api_resources/resource_sharing/test_recipients.py deleted file mode 100644 index 3d929e6d396..00000000000 --- a/tests/api_resources/resource_sharing/test_recipients.py +++ /dev/null @@ -1,502 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.resource_sharing import ( - RecipientGetResponse, - RecipientListResponse, - RecipientCreateResponse, - RecipientDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestRecipients: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - recipient = client.resource_sharing.recipients.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - recipient = client.resource_sharing.recipients.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - body_account_id="023e105f4ecef8ad9ca31a8372d0c353", - organization_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.resource_sharing.recipients.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = response.parse() - assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.resource_sharing.recipients.with_streaming_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = response.parse() - assert_matches_type(Optional[RecipientCreateResponse], recipient, 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 `path_account_id` but received ''"): - client.resource_sharing.recipients.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="", - body_account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.recipients.with_raw_response.create( - share_identifier="", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - recipient = client.resource_sharing.recipients.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - recipient = client.resource_sharing.recipients.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - page=2, - per_page=20, - ) - assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.resource_sharing.recipients.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = response.parse() - assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.resource_sharing.recipients.with_streaming_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = response.parse() - assert_matches_type(SyncV4PagePaginationArray[RecipientListResponse], recipient, 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.resource_sharing.recipients.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.recipients.with_raw_response.list( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - recipient = client.resource_sharing.recipients.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = response.parse() - assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.resource_sharing.recipients.with_streaming_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = response.parse() - assert_matches_type(Optional[RecipientDeleteResponse], recipient, 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.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_identifier` but received ''"): - client.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - recipient = client.resource_sharing.recipients.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = response.parse() - assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.resource_sharing.recipients.with_streaming_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = response.parse() - assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_identifier` but received ''"): - client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - -class TestAsyncRecipients: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - recipient = await async_client.resource_sharing.recipients.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - recipient = await async_client.resource_sharing.recipients.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - body_account_id="023e105f4ecef8ad9ca31a8372d0c353", - organization_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.recipients.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = await response.parse() - assert_matches_type(Optional[RecipientCreateResponse], recipient, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.recipients.with_streaming_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = await response.parse() - assert_matches_type(Optional[RecipientCreateResponse], recipient, 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 `path_account_id` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - path_account_id="", - body_account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.create( - share_identifier="", - path_account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - recipient = await async_client.resource_sharing.recipients.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - recipient = await async_client.resource_sharing.recipients.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - page=2, - per_page=20, - ) - assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.recipients.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.recipients.with_streaming_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[RecipientListResponse], recipient, 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.resource_sharing.recipients.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.list( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - recipient = await async_client.resource_sharing.recipients.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = await response.parse() - assert_matches_type(Optional[RecipientDeleteResponse], recipient, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.recipients.with_streaming_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = await response.parse() - assert_matches_type(Optional[RecipientDeleteResponse], recipient, 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.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_identifier` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.delete( - recipient_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - recipient = await async_client.resource_sharing.recipients.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - recipient = await response.parse() - assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.recipients.with_streaming_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - recipient = await response.parse() - assert_matches_type(Optional[RecipientGetResponse], recipient, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `recipient_identifier` but received ''"): - await async_client.resource_sharing.recipients.with_raw_response.get( - recipient_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) diff --git a/tests/api_resources/resource_sharing/test_resources.py b/tests/api_resources/resource_sharing/test_resources.py deleted file mode 100644 index 342f0563798..00000000000 --- a/tests/api_resources/resource_sharing/test_resources.py +++ /dev/null @@ -1,657 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.resource_sharing import ( - ResourceGetResponse, - ResourceListResponse, - ResourceCreateResponse, - ResourceDeleteResponse, - ResourceUpdateResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestResources: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - resource = client.resource_sharing.resources.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.resource_sharing.resources.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.resource_sharing.resources.with_streaming_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = response.parse() - assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.resource_sharing.resources.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.create( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - resource = client.resource_sharing.resources.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) - - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.resource_sharing.resources.with_raw_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) - - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.resource_sharing.resources.with_streaming_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = response.parse() - assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.resource_sharing.resources.with_raw_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - meta={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.update( - resource_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - resource = client.resource_sharing.resources.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - resource = client.resource_sharing.resources.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - page=2, - per_page=20, - resource_type="custom-ruleset", - status="active", - ) - assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.resource_sharing.resources.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.resource_sharing.resources.with_streaming_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = response.parse() - assert_matches_type(SyncV4PagePaginationArray[ResourceListResponse], resource, 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.resource_sharing.resources.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.list( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - resource = client.resource_sharing.resources.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.resource_sharing.resources.with_raw_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.resource_sharing.resources.with_streaming_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = response.parse() - assert_matches_type(Optional[ResourceDeleteResponse], resource, 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.resource_sharing.resources.with_raw_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.delete( - resource_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - resource = client.resource_sharing.resources.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.resource_sharing.resources.with_raw_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = response.parse() - assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.resource_sharing.resources.with_streaming_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = response.parse() - assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.resource_sharing.resources.with_raw_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_identifier` but received ''"): - client.resource_sharing.resources.with_raw_response.get( - resource_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - -class TestAsyncResources: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - resource = await async_client.resource_sharing.resources.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.resources.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.resources.with_streaming_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = await response.parse() - assert_matches_type(Optional[ResourceCreateResponse], resource, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.create( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.create( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - meta={}, - resource_account_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_id="023e105f4ecef8ad9ca31a8372d0c353", - resource_type="custom-ruleset", - ) - - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - resource = await async_client.resource_sharing.resources.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) - - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.resources.with_raw_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) - - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.resources.with_streaming_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = await response.parse() - assert_matches_type(Optional[ResourceUpdateResponse], resource, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.update( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - meta={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.update( - resource_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - meta={}, - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - resource = await async_client.resource_sharing.resources.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - resource = await async_client.resource_sharing.resources.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - page=2, - per_page=20, - resource_type="custom-ruleset", - status="active", - ) - assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.resources.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.resources.with_streaming_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[ResourceListResponse], resource, 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.resource_sharing.resources.with_raw_response.list( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.list( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - resource = await async_client.resource_sharing.resources.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.resources.with_raw_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(Optional[ResourceDeleteResponse], resource, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.resources.with_streaming_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = await response.parse() - assert_matches_type(Optional[ResourceDeleteResponse], resource, 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.resource_sharing.resources.with_raw_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.delete( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.delete( - resource_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - resource = await async_client.resource_sharing.resources.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.resources.with_raw_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource = await response.parse() - assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.resources.with_streaming_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource = await response.parse() - assert_matches_type(Optional[ResourceGetResponse], resource, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.get( - resource_identifier="023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_identifier` but received ''"): - await async_client.resource_sharing.resources.with_raw_response.get( - resource_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - share_identifier="3fd85f74b32742f1bff64a85009dda07", - ) diff --git a/tests/api_resources/test_resource_sharing.py b/tests/api_resources/test_resource_sharing.py index e8dad77fece..0f6acec60bc 100644 --- a/tests/api_resources/test_resource_sharing.py +++ b/tests/api_resources/test_resource_sharing.py @@ -11,11 +11,8 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from cloudflare.types.resource_sharing import ( - ResourceSharingGetResponse, ResourceSharingListResponse, ResourceSharingCreateResponse, - ResourceSharingDeleteResponse, - ResourceSharingUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -102,59 +99,6 @@ def test_path_params_create(self, client: Cloudflare) -> None: ], ) - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - resource_sharing = client.resource_sharing.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) - assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) - - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.resource_sharing.with_raw_response.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource_sharing = response.parse() - assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) - - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.resource_sharing.with_streaming_response.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource_sharing = response.parse() - assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.resource_sharing.with_raw_response.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - name="My Shared WAF Managed Rule", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.with_raw_response.update( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) - @parametrize def test_method_list(self, client: Cloudflare) -> None: resource_sharing = client.resource_sharing.list( @@ -209,102 +153,6 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - resource_sharing = client.resource_sharing.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.resource_sharing.with_raw_response.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource_sharing = response.parse() - assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.resource_sharing.with_streaming_response.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource_sharing = response.parse() - assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, 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.resource_sharing.with_raw_response.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.with_raw_response.delete( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - resource_sharing = client.resource_sharing.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.resource_sharing.with_raw_response.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource_sharing = response.parse() - assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.resource_sharing.with_streaming_response.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource_sharing = response.parse() - assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.resource_sharing.with_raw_response.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - client.resource_sharing.with_raw_response.get( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - class TestAsyncResourceSharing: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -387,59 +235,6 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: ], ) - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - resource_sharing = await async_client.resource_sharing.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) - assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) - - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.with_raw_response.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource_sharing = await response.parse() - assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) - - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.with_streaming_response.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource_sharing = await response.parse() - assert_matches_type(Optional[ResourceSharingUpdateResponse], resource_sharing, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.resource_sharing.with_raw_response.update( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - name="My Shared WAF Managed Rule", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.with_raw_response.update( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="My Shared WAF Managed Rule", - ) - @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: resource_sharing = await async_client.resource_sharing.list( @@ -499,99 +294,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.resource_sharing.with_raw_response.list( account_id="", ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - resource_sharing = await async_client.resource_sharing.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.with_raw_response.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource_sharing = await response.parse() - assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.with_streaming_response.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource_sharing = await response.parse() - assert_matches_type(Optional[ResourceSharingDeleteResponse], resource_sharing, 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.resource_sharing.with_raw_response.delete( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.with_raw_response.delete( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - resource_sharing = await async_client.resource_sharing.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.resource_sharing.with_raw_response.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - resource_sharing = await response.parse() - assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.resource_sharing.with_streaming_response.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - resource_sharing = await response.parse() - assert_matches_type(Optional[ResourceSharingGetResponse], resource_sharing, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.resource_sharing.with_raw_response.get( - share_identifier="3fd85f74b32742f1bff64a85009dda07", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `share_identifier` but received ''"): - await async_client.resource_sharing.with_raw_response.get( - share_identifier="", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - )