feat(api): OpenAPI spec update via Stainless API (#1191)

This commit is contained in:
stainless-app[bot] 2024-07-16 11:07:11 +00:00 committed by stainless-bot
parent 28c06a7fd3
commit d3e0648ee1
29 changed files with 747 additions and 261 deletions

View file

@ -1,2 +1,2 @@
configured_endpoints: 1256
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-74d68374448e03b29a39bb6cdf6c39cdeaaaa691dd9c38f46a26a1d562c8ee37.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b116e60da4a69a05bc8823c2397e4a33d111c82a6b458ea4f480d0ba52ea8de0.yml

22
api.md
View file

@ -2392,7 +2392,7 @@ from cloudflare.types.api_gateway.discovery import OperationEditResponse
Methods:
- <code title="get /zones/{zone_id}/api_gateway/discovery/operations">client.api_gateway.discovery.operations.<a href="./src/cloudflare/resources/api_gateway/discovery/operations.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/discovery/operation_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/discovery_operation.py">SyncSinglePage[DiscoveryOperation]</a></code>
- <code title="get /zones/{zone_id}/api_gateway/discovery/operations">client.api_gateway.discovery.operations.<a href="./src/cloudflare/resources/api_gateway/discovery/operations.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/discovery/operation_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/discovery_operation.py">SyncV4PagePaginationArray[DiscoveryOperation]</a></code>
- <code title="patch /zones/{zone_id}/api_gateway/discovery/operations/{operation_id}">client.api_gateway.discovery.operations.<a href="./src/cloudflare/resources/api_gateway/discovery/operations.py">edit</a>(operation_id, \*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/discovery/operation_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/discovery/operation_edit_response.py">OperationEditResponse</a></code>
## Operations
@ -2400,15 +2400,21 @@ Methods:
Types:
```python
from cloudflare.types.api_gateway import APIShield, OperationCreateResponse, OperationDeleteResponse
from cloudflare.types.api_gateway import (
APIShield,
OperationCreateResponse,
OperationListResponse,
OperationDeleteResponse,
OperationGetResponse,
)
```
Methods:
- <code title="post /zones/{zone_id}/api_gateway/operations">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_create_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/operation_create_response.py">Optional</a></code>
- <code title="get /zones/{zone_id}/api_gateway/operations">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/api_shield.py">SyncSinglePage[APIShield]</a></code>
- <code title="post /zones/{zone_id}/api_gateway/operations">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_create_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/operation_create_response.py">OperationCreateResponse</a></code>
- <code title="get /zones/{zone_id}/api_gateway/operations">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/operation_list_response.py">SyncV4PagePaginationArray[OperationListResponse]</a></code>
- <code title="delete /zones/{zone_id}/api_gateway/operations/{operation_id}">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">delete</a>(operation_id, \*, zone_id) -> <a href="./src/cloudflare/types/api_gateway/operation_delete_response.py">OperationDeleteResponse</a></code>
- <code title="get /zones/{zone_id}/api_gateway/operations/{operation_id}">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">get</a>(operation_id, \*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_get_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/api_shield.py">APIShield</a></code>
- <code title="get /zones/{zone_id}/api_gateway/operations/{operation_id}">client.api_gateway.operations.<a href="./src/cloudflare/resources/api_gateway/operations/operations.py">get</a>(operation_id, \*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/operation_get_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/operation_get_response.py">OperationGetResponse</a></code>
### SchemaValidation
@ -2472,8 +2478,8 @@ from cloudflare.types.api_gateway import (
Methods:
- <code title="post /zones/{zone_id}/api_gateway/user_schemas">client.api_gateway.user_schemas.<a href="./src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/user_schema_create_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/schema_upload.py">SchemaUpload</a></code>
- <code title="get /zones/{zone_id}/api_gateway/user_schemas">client.api_gateway.user_schemas.<a href="./src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/user_schema_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/public_schema.py">SyncSinglePage[PublicSchema]</a></code>
- <code title="delete /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.api_gateway.user_schemas.<a href="./src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py">delete</a>(schema_id, \*, zone_id) -> <a href="./src/cloudflare/types/api_gateway/user_schema_delete_response.py">UserSchemaDeleteResponse</a></code>
- <code title="get /zones/{zone_id}/api_gateway/user_schemas">client.api_gateway.user_schemas.<a href="./src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/user_schema_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/public_schema.py">SyncV4PagePaginationArray[PublicSchema]</a></code>
- <code title="delete /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.api_gateway.user_schemas.<a href="./src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py">delete</a>(schema_id, \*, zone_id) -> <a href="./src/cloudflare/types/api_gateway/user_schema_delete_response.py">Optional</a></code>
- <code title="patch /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.api_gateway.user_schemas.<a href="./src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py">edit</a>(schema_id, \*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/user_schema_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/public_schema.py">PublicSchema</a></code>
- <code title="get /zones/{zone_id}/api_gateway/user_schemas/{schema_id}">client.api_gateway.user_schemas.<a href="./src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py">get</a>(schema_id, \*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/user_schema_get_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/public_schema.py">PublicSchema</a></code>
@ -2487,7 +2493,7 @@ from cloudflare.types.api_gateway.user_schemas import OperationListResponse
Methods:
- <code title="get /zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations">client.api_gateway.user_schemas.operations.<a href="./src/cloudflare/resources/api_gateway/user_schemas/operations.py">list</a>(schema_id, \*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py">SyncSinglePage[OperationListResponse]</a></code>
- <code title="get /zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations">client.api_gateway.user_schemas.operations.<a href="./src/cloudflare/resources/api_gateway/user_schemas/operations.py">list</a>(schema_id, \*, zone_id, \*\*<a href="src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py">params</a>) -> <a href="./src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py">SyncV4PagePaginationArray[OperationListResponse]</a></code>
# ManagedHeaders

View file

@ -2,7 +2,7 @@
from __future__ import annotations
from typing import Any, List, Type, Iterable, cast
from typing import List, Type, Iterable, cast
from typing_extensions import Literal
import httpx
@ -42,7 +42,7 @@ class ConfigurationsResource(SyncAPIResource):
self,
*,
zone_id: str,
auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic] | NotGiven = NOT_GIVEN,
auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic],
# 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,
@ -66,25 +66,16 @@ class ConfigurationsResource(SyncAPIResource):
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return cast(
ConfigurationUpdateResponse,
self._put(
f"/zones/{zone_id}/api_gateway/configuration",
body=maybe_transform(
{"auth_id_characteristics": auth_id_characteristics},
configuration_update_params.ConfigurationUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[ConfigurationUpdateResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[ConfigurationUpdateResponse]
), # Union types cannot be passed in as arguments in the type system
return self._put(
f"/zones/{zone_id}/api_gateway/configuration",
body=maybe_transform(
{"auth_id_characteristics": auth_id_characteristics},
configuration_update_params.ConfigurationUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=ConfigurationUpdateResponse,
)
def get(
@ -144,7 +135,7 @@ class AsyncConfigurationsResource(AsyncAPIResource):
self,
*,
zone_id: str,
auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic] | NotGiven = NOT_GIVEN,
auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic],
# 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,
@ -168,25 +159,16 @@ class AsyncConfigurationsResource(AsyncAPIResource):
"""
if not zone_id:
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return cast(
ConfigurationUpdateResponse,
await self._put(
f"/zones/{zone_id}/api_gateway/configuration",
body=await async_maybe_transform(
{"auth_id_characteristics": auth_id_characteristics},
configuration_update_params.ConfigurationUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[ConfigurationUpdateResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[ConfigurationUpdateResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._put(
f"/zones/{zone_id}/api_gateway/configuration",
body=await async_maybe_transform(
{"auth_id_characteristics": auth_id_characteristics},
configuration_update_params.ConfigurationUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=ConfigurationUpdateResponse,
)
async def get(

View file

@ -21,7 +21,7 @@ from ...._response import (
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ....pagination import SyncSinglePage, AsyncSinglePage
from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ...._base_client import AsyncPaginator, make_request_options
from ....types.api_gateway.discovery import operation_edit_params, operation_list_params
from ....types.api_gateway.discovery_operation import DiscoveryOperation
@ -51,8 +51,8 @@ class OperationsResource(SyncAPIResource):
order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"]
| NotGiven = NOT_GIVEN,
origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: object | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
per_page: int | NotGiven = NOT_GIVEN,
state: Literal["review", "saved", "ignored"] | 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.
@ -60,7 +60,7 @@ class OperationsResource(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncSinglePage[DiscoveryOperation]:
) -> SyncV4PagePaginationArray[DiscoveryOperation]:
"""
Retrieve the most up to date view of discovered operations
@ -112,7 +112,7 @@ class OperationsResource(SyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/discovery/operations",
page=SyncSinglePage[DiscoveryOperation],
page=SyncV4PagePaginationArray[DiscoveryOperation],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -156,7 +156,7 @@ class OperationsResource(SyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID identifier
operation_id: UUID
state: Mark state of operation in API Discovery
@ -210,8 +210,8 @@ class AsyncOperationsResource(AsyncAPIResource):
order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"]
| NotGiven = NOT_GIVEN,
origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: object | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
per_page: int | NotGiven = NOT_GIVEN,
state: Literal["review", "saved", "ignored"] | 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.
@ -219,7 +219,7 @@ class AsyncOperationsResource(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[DiscoveryOperation, AsyncSinglePage[DiscoveryOperation]]:
) -> AsyncPaginator[DiscoveryOperation, AsyncV4PagePaginationArray[DiscoveryOperation]]:
"""
Retrieve the most up to date view of discovered operations
@ -271,7 +271,7 @@ class AsyncOperationsResource(AsyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/discovery/operations",
page=AsyncSinglePage[DiscoveryOperation],
page=AsyncV4PagePaginationArray[DiscoveryOperation],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -315,7 +315,7 @@ class AsyncOperationsResource(AsyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID identifier
operation_id: UUID
state: Mark state of operation in API Discovery

View file

@ -2,7 +2,7 @@
from __future__ import annotations
from typing import Any, List, Type, Iterable, Optional, cast
from typing import List, Type, Iterable, cast
from typing_extensions import Literal
import httpx
@ -21,7 +21,7 @@ from ...._response import (
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ....pagination import SyncSinglePage, AsyncSinglePage
from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ...._base_client import AsyncPaginator, make_request_options
from .schema_validation import (
SchemaValidationResource,
@ -32,7 +32,8 @@ from .schema_validation import (
AsyncSchemaValidationResourceWithStreamingResponse,
)
from ....types.api_gateway import operation_get_params, operation_list_params, operation_create_params
from ....types.api_gateway.api_shield import APIShield
from ....types.api_gateway.operation_get_response import OperationGetResponse
from ....types.api_gateway.operation_list_response import OperationListResponse
from ....types.api_gateway.operation_create_response import OperationCreateResponse
from ....types.api_gateway.operation_delete_response import OperationDeleteResponse
@ -63,7 +64,7 @@ class OperationsResource(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[OperationCreateResponse]:
) -> OperationCreateResponse:
"""Add one or more operations to a zone.
Endpoints can contain path variables.
@ -93,9 +94,9 @@ class OperationsResource(SyncAPIResource):
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[OperationCreateResponse]]._unwrapper,
post_parser=ResultWrapper[OperationCreateResponse]._unwrapper,
),
cast_to=cast(Type[Optional[OperationCreateResponse]], ResultWrapper[OperationCreateResponse]),
cast_to=cast(Type[OperationCreateResponse], ResultWrapper[OperationCreateResponse]),
)
def list(
@ -108,15 +109,15 @@ class OperationsResource(SyncAPIResource):
host: List[str] | NotGiven = NOT_GIVEN,
method: List[str] | NotGiven = NOT_GIVEN,
order: Literal["method", "host", "endpoint", "thresholds.$key"] | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
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,
) -> SyncSinglePage[APIShield]:
) -> SyncV4PagePaginationArray[OperationListResponse]:
"""
Retrieve information about all operations on a zone
@ -140,7 +141,7 @@ class OperationsResource(SyncAPIResource):
page: Page number of paginated results.
per_page: Number of results to return per page
per_page: Maximum number of results per page.
extra_headers: Send extra headers
@ -154,7 +155,7 @@ class OperationsResource(SyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/operations",
page=SyncSinglePage[APIShield],
page=SyncV4PagePaginationArray[OperationListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -174,7 +175,7 @@ class OperationsResource(SyncAPIResource):
operation_list_params.OperationListParams,
),
),
model=APIShield,
model=OperationListResponse,
)
def delete(
@ -195,6 +196,8 @@ class OperationsResource(SyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@ -207,21 +210,12 @@ class OperationsResource(SyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
if not operation_id:
raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}")
return cast(
OperationDeleteResponse,
self._delete(
f"/zones/{zone_id}/api_gateway/operations/{operation_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[OperationDeleteResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[OperationDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return self._delete(
f"/zones/{zone_id}/api_gateway/operations/{operation_id}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=OperationDeleteResponse,
)
def get(
@ -236,13 +230,15 @@ class OperationsResource(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> APIShield:
) -> OperationGetResponse:
"""
Retrieve information about an operation
Args:
zone_id: Identifier
operation_id: UUID
feature: Add feature(s) to the results. The feature name that is given here corresponds
to the resulting feature object. Have a look at the top-level object description
for more details on the specific meaning.
@ -267,9 +263,9 @@ class OperationsResource(SyncAPIResource):
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"feature": feature}, operation_get_params.OperationGetParams),
post_parser=ResultWrapper[APIShield]._unwrapper,
post_parser=ResultWrapper[OperationGetResponse]._unwrapper,
),
cast_to=cast(Type[APIShield], ResultWrapper[APIShield]),
cast_to=cast(Type[OperationGetResponse], ResultWrapper[OperationGetResponse]),
)
@ -297,7 +293,7 @@ class AsyncOperationsResource(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[OperationCreateResponse]:
) -> OperationCreateResponse:
"""Add one or more operations to a zone.
Endpoints can contain path variables.
@ -327,9 +323,9 @@ class AsyncOperationsResource(AsyncAPIResource):
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[OperationCreateResponse]]._unwrapper,
post_parser=ResultWrapper[OperationCreateResponse]._unwrapper,
),
cast_to=cast(Type[Optional[OperationCreateResponse]], ResultWrapper[OperationCreateResponse]),
cast_to=cast(Type[OperationCreateResponse], ResultWrapper[OperationCreateResponse]),
)
def list(
@ -342,15 +338,15 @@ class AsyncOperationsResource(AsyncAPIResource):
host: List[str] | NotGiven = NOT_GIVEN,
method: List[str] | NotGiven = NOT_GIVEN,
order: Literal["method", "host", "endpoint", "thresholds.$key"] | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
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[APIShield, AsyncSinglePage[APIShield]]:
) -> AsyncPaginator[OperationListResponse, AsyncV4PagePaginationArray[OperationListResponse]]:
"""
Retrieve information about all operations on a zone
@ -374,7 +370,7 @@ class AsyncOperationsResource(AsyncAPIResource):
page: Page number of paginated results.
per_page: Number of results to return per page
per_page: Maximum number of results per page.
extra_headers: Send extra headers
@ -388,7 +384,7 @@ class AsyncOperationsResource(AsyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/operations",
page=AsyncSinglePage[APIShield],
page=AsyncV4PagePaginationArray[OperationListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -408,7 +404,7 @@ class AsyncOperationsResource(AsyncAPIResource):
operation_list_params.OperationListParams,
),
),
model=APIShield,
model=OperationListResponse,
)
async def delete(
@ -429,6 +425,8 @@ class AsyncOperationsResource(AsyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@ -441,21 +439,12 @@ class AsyncOperationsResource(AsyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
if not operation_id:
raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}")
return cast(
OperationDeleteResponse,
await self._delete(
f"/zones/{zone_id}/api_gateway/operations/{operation_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[OperationDeleteResponse]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[OperationDeleteResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._delete(
f"/zones/{zone_id}/api_gateway/operations/{operation_id}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=OperationDeleteResponse,
)
async def get(
@ -470,13 +459,15 @@ class AsyncOperationsResource(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> APIShield:
) -> OperationGetResponse:
"""
Retrieve information about an operation
Args:
zone_id: Identifier
operation_id: UUID
feature: Add feature(s) to the results. The feature name that is given here corresponds
to the resulting feature object. Have a look at the top-level object description
for more details on the specific meaning.
@ -501,9 +492,9 @@ class AsyncOperationsResource(AsyncAPIResource):
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform({"feature": feature}, operation_get_params.OperationGetParams),
post_parser=ResultWrapper[APIShield]._unwrapper,
post_parser=ResultWrapper[OperationGetResponse]._unwrapper,
),
cast_to=cast(Type[APIShield], ResultWrapper[APIShield]),
cast_to=cast(Type[OperationGetResponse], ResultWrapper[OperationGetResponse]),
)

View file

@ -63,6 +63,8 @@ class SchemaValidationResource(SyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID
mitigation_action: When set, this applies a mitigation action to this operation
- `log` log request when request does not conform to schema for this operation
@ -154,6 +156,8 @@ class SchemaValidationResource(SyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@ -203,6 +207,8 @@ class AsyncSchemaValidationResource(AsyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID
mitigation_action: When set, this applies a mitigation action to this operation
- `log` log request when request does not conform to schema for this operation
@ -296,6 +302,8 @@ class AsyncSchemaValidationResource(AsyncAPIResource):
Args:
zone_id: Identifier
operation_id: UUID
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request

View file

@ -17,7 +17,7 @@ from ...._response import (
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ....pagination import SyncSinglePage, AsyncSinglePage
from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ...._base_client import AsyncPaginator, make_request_options
from ....types.api_gateway.user_schemas import operation_list_params
from ....types.api_gateway.user_schemas.operation_list_response import OperationListResponse
@ -44,15 +44,15 @@ class OperationsResource(SyncAPIResource):
host: List[str] | NotGiven = NOT_GIVEN,
method: List[str] | NotGiven = NOT_GIVEN,
operation_status: Literal["new", "existing"] | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: object | NotGiven = NOT_GIVEN,
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,
) -> SyncSinglePage[OperationListResponse]:
) -> SyncV4PagePaginationArray[OperationListResponse]:
"""Retrieves all operations from the schema.
Operations that already exist in API
@ -94,7 +94,7 @@ class OperationsResource(SyncAPIResource):
raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations",
page=SyncSinglePage[OperationListResponse],
page=SyncV4PagePaginationArray[OperationListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -136,15 +136,15 @@ class AsyncOperationsResource(AsyncAPIResource):
host: List[str] | NotGiven = NOT_GIVEN,
method: List[str] | NotGiven = NOT_GIVEN,
operation_status: Literal["new", "existing"] | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: object | NotGiven = NOT_GIVEN,
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[OperationListResponse, AsyncSinglePage[OperationListResponse]]:
) -> AsyncPaginator[OperationListResponse, AsyncV4PagePaginationArray[OperationListResponse]]:
"""Retrieves all operations from the schema.
Operations that already exist in API
@ -186,7 +186,7 @@ class AsyncOperationsResource(AsyncAPIResource):
raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations",
page=AsyncSinglePage[OperationListResponse],
page=AsyncV4PagePaginationArray[OperationListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,

View file

@ -2,7 +2,7 @@
from __future__ import annotations
from typing import Any, Type, Mapping, cast
from typing import Any, Type, Mapping, Optional, cast
from typing_extensions import Literal
import httpx
@ -31,7 +31,7 @@ from ...._response import (
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ....pagination import SyncSinglePage, AsyncSinglePage
from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ...._base_client import AsyncPaginator, make_request_options
from ....types.api_gateway import (
user_schema_get_params,
@ -130,8 +130,8 @@ class UserSchemasResource(SyncAPIResource):
*,
zone_id: str,
omit_source: bool | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: object | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
per_page: int | NotGiven = NOT_GIVEN,
validation_enabled: bool | 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.
@ -139,7 +139,7 @@ class UserSchemasResource(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncSinglePage[PublicSchema]:
) -> SyncV4PagePaginationArray[PublicSchema]:
"""
Retrieve information about all schemas on a zone
@ -166,7 +166,7 @@ class UserSchemasResource(SyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/user_schemas",
page=SyncSinglePage[PublicSchema],
page=SyncV4PagePaginationArray[PublicSchema],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -196,7 +196,7 @@ class UserSchemasResource(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> UserSchemaDeleteResponse:
) -> Optional[UserSchemaDeleteResponse]:
"""
Delete a schema
@ -216,7 +216,7 @@ class UserSchemasResource(SyncAPIResource):
if not schema_id:
raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}")
return cast(
UserSchemaDeleteResponse,
Optional[UserSchemaDeleteResponse],
self._delete(
f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}",
options=make_request_options(
@ -224,7 +224,7 @@ class UserSchemasResource(SyncAPIResource):
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[UserSchemaDeleteResponse]._unwrapper,
post_parser=ResultWrapper[Optional[UserSchemaDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[UserSchemaDeleteResponse]
@ -411,8 +411,8 @@ class AsyncUserSchemasResource(AsyncAPIResource):
*,
zone_id: str,
omit_source: bool | NotGiven = NOT_GIVEN,
page: object | NotGiven = NOT_GIVEN,
per_page: object | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
per_page: int | NotGiven = NOT_GIVEN,
validation_enabled: bool | 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.
@ -420,7 +420,7 @@ class AsyncUserSchemasResource(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[PublicSchema, AsyncSinglePage[PublicSchema]]:
) -> AsyncPaginator[PublicSchema, AsyncV4PagePaginationArray[PublicSchema]]:
"""
Retrieve information about all schemas on a zone
@ -447,7 +447,7 @@ class AsyncUserSchemasResource(AsyncAPIResource):
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
return self._get_api_list(
f"/zones/{zone_id}/api_gateway/user_schemas",
page=AsyncSinglePage[PublicSchema],
page=AsyncV4PagePaginationArray[PublicSchema],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -477,7 +477,7 @@ class AsyncUserSchemasResource(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> UserSchemaDeleteResponse:
) -> Optional[UserSchemaDeleteResponse]:
"""
Delete a schema
@ -497,7 +497,7 @@ class AsyncUserSchemasResource(AsyncAPIResource):
if not schema_id:
raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}")
return cast(
UserSchemaDeleteResponse,
Optional[UserSchemaDeleteResponse],
await self._delete(
f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}",
options=make_request_options(
@ -505,7 +505,7 @@ class AsyncUserSchemasResource(AsyncAPIResource):
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[UserSchemaDeleteResponse]._unwrapper,
post_parser=ResultWrapper[Optional[UserSchemaDeleteResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[UserSchemaDeleteResponse]

View file

@ -14,8 +14,10 @@ from .operation_get_params import OperationGetParams as OperationGetParams
from .schema_list_response import SchemaListResponse as SchemaListResponse
from .operation_list_params import OperationListParams as OperationListParams
from .discovery_get_response import DiscoveryGetResponse as DiscoveryGetResponse
from .operation_get_response import OperationGetResponse as OperationGetResponse
from .user_schema_get_params import UserSchemaGetParams as UserSchemaGetParams
from .operation_create_params import OperationCreateParams as OperationCreateParams
from .operation_list_response import OperationListResponse as OperationListResponse
from .user_schema_edit_params import UserSchemaEditParams as UserSchemaEditParams
from .user_schema_list_params import UserSchemaListParams as UserSchemaListParams
from .configuration_get_params import ConfigurationGetParams as ConfigurationGetParams

View file

@ -169,7 +169,7 @@ class FeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel):
class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(BaseModel):
id: Optional[str] = None
"""UUID identifier"""
"""UUID"""
created_at: Optional[datetime] = None
@ -222,6 +222,6 @@ class APIShield(BaseModel):
"""The HTTP method used to access the endpoint."""
operation_id: str
"""UUID identifier"""
"""UUID"""
features: Optional[Features] = None

View file

@ -1,6 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
from typing import List, Union
from typing_extensions import Literal
from ..._models import BaseModel
@ -43,4 +43,4 @@ AuthIDCharacteristic = Union[
class Configuration(BaseModel):
auth_id_characteristics: Optional[List[AuthIDCharacteristic]] = None
auth_id_characteristics: List[AuthIDCharacteristic]

View file

@ -17,7 +17,7 @@ class ConfigurationUpdateParams(TypedDict, total=False):
zone_id: Required[str]
"""Identifier"""
auth_id_characteristics: Iterable[AuthIDCharacteristic]
auth_id_characteristics: Required[Iterable[AuthIDCharacteristic]]
class AuthIDCharacteristicAPIShieldAuthIDCharacteristic(TypedDict, total=False):

View file

@ -1,7 +1,17 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import Union, Optional
from typing_extensions import Literal
from .message import Message
from ..._models import BaseModel
__all__ = ["ConfigurationUpdateResponse"]
ConfigurationUpdateResponse = Union[Optional[str], Optional[object]]
class ConfigurationUpdateResponse(BaseModel):
errors: Message
messages: Message
success: Literal[True]
"""Whether the API call was successful"""

View file

@ -43,10 +43,10 @@ class OperationListParams(TypedDict, total=False):
Identifier API Discovery
"""
page: object
page: int
"""Page number of paginated results."""
per_page: object
per_page: int
"""Maximum number of results per page."""
state: Literal["review", "saved", "ignored"]

View file

@ -1,6 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Optional
from typing import List
from datetime import datetime
from ..._models import BaseModel
@ -9,6 +9,6 @@ __all__ = ["DiscoveryGetResponse"]
class DiscoveryGetResponse(BaseModel):
schemas: Optional[List[object]] = None
schemas: List[object]
timestamp: Optional[datetime] = None
timestamp: datetime

View file

@ -25,7 +25,7 @@ class Features(BaseModel):
class DiscoveryOperation(BaseModel):
id: str
"""UUID identifier"""
"""UUID"""
endpoint: str
"""

View file

@ -1,7 +1,17 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import Union, Optional
from typing_extensions import Literal
from .message import Message
from ..._models import BaseModel
__all__ = ["OperationDeleteResponse"]
OperationDeleteResponse = Union[Optional[str], Optional[object]]
class OperationDeleteResponse(BaseModel):
errors: Message
messages: Message
success: Literal[True]
"""Whether the API call was successful"""

View file

@ -0,0 +1,227 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
from datetime import datetime
from typing_extensions import Literal
from ..._models import BaseModel
__all__ = [
"OperationGetResponse",
"Features",
"FeaturesAPIShieldOperationFeatureThresholds",
"FeaturesAPIShieldOperationFeatureThresholdsThresholds",
"FeaturesAPIShieldOperationFeatureParameterSchemas",
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas",
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas",
"FeaturesAPIShieldOperationFeatureAPIRouting",
"FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting",
"FeaturesAPIShieldOperationFeatureConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99",
"FeaturesAPIShieldOperationFeatureSchemaInfo",
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo",
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema",
]
class FeaturesAPIShieldOperationFeatureThresholdsThresholds(BaseModel):
auth_id_tokens: Optional[int] = None
"""The total number of auth-ids seen across this calculation."""
data_points: Optional[int] = None
"""The number of data points used for the threshold suggestion calculation."""
last_updated: Optional[datetime] = None
p50: Optional[int] = None
"""The p50 quantile of requests (in period_seconds)."""
p90: Optional[int] = None
"""The p90 quantile of requests (in period_seconds)."""
p99: Optional[int] = None
"""The p99 quantile of requests (in period_seconds)."""
period_seconds: Optional[int] = None
"""The period over which this threshold is suggested."""
requests: Optional[int] = None
"""The estimated number of requests covered by these calculations."""
suggested_threshold: Optional[int] = None
"""The suggested threshold in requests done by the same auth_id or period_seconds."""
class FeaturesAPIShieldOperationFeatureThresholds(BaseModel):
thresholds: Optional[FeaturesAPIShieldOperationFeatureThresholdsThresholds] = None
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas(BaseModel):
parameters: Optional[List[object]] = None
"""An array containing the learned parameter schemas."""
responses: Optional[object] = None
"""An empty response object.
This field is required to yield a valid operation schema.
"""
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel):
last_updated: Optional[datetime] = None
parameter_schemas: Optional[
FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas
] = None
"""An operation schema object containing a response."""
class FeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel):
parameter_schemas: FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas
class FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting(BaseModel):
last_updated: Optional[datetime] = None
route: Optional[str] = None
"""Target route."""
class FeaturesAPIShieldOperationFeatureAPIRouting(BaseModel):
api_routing: Optional[FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting] = None
"""API Routing settings on endpoint."""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""
upper: Optional[float] = None
"""Upper bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""
upper: Optional[float] = None
"""Upper bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""
upper: Optional[float] = None
"""Upper bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals(
BaseModel
):
p90: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90
] = None
"""Upper and lower bound for percentile estimate"""
p95: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95
] = None
"""Upper and lower bound for percentile estimate"""
p99: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99
] = None
"""Upper and lower bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold(BaseModel):
confidence_intervals: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals
] = None
mean: Optional[float] = None
"""Suggested threshold."""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals(BaseModel):
last_updated: Optional[datetime] = None
suggested_threshold: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold
] = None
class FeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel):
confidence_intervals: Optional[FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals] = None
class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(BaseModel):
id: Optional[str] = None
"""UUID"""
created_at: Optional[datetime] = None
is_learned: Optional[bool] = None
"""True if schema is Cloudflare-provided."""
name: Optional[str] = None
"""Schema file name."""
class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo(BaseModel):
active_schema: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema] = None
"""Schema active on endpoint."""
learned_available: Optional[bool] = None
"""True if a Cloudflare-provided learned schema is available for this endpoint."""
mitigation_action: Optional[Literal["none", "log", "block"]] = None
"""Action taken on requests failing validation."""
class FeaturesAPIShieldOperationFeatureSchemaInfo(BaseModel):
schema_info: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo] = None
Features = Union[
FeaturesAPIShieldOperationFeatureThresholds,
FeaturesAPIShieldOperationFeatureParameterSchemas,
FeaturesAPIShieldOperationFeatureAPIRouting,
FeaturesAPIShieldOperationFeatureConfidenceIntervals,
FeaturesAPIShieldOperationFeatureSchemaInfo,
]
class OperationGetResponse(BaseModel):
endpoint: str
"""
The endpoint which can contain path parameter templates in curly braces, each
will be replaced from left to right with {varN}, starting with {var1}, during
insertion. This will further be Cloudflare-normalized upon insertion. See:
https://developers.cloudflare.com/rules/normalization/how-it-works/.
"""
host: str
"""RFC3986-compliant host."""
last_updated: datetime
method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]
"""The HTTP method used to access the endpoint."""
operation_id: str
"""UUID"""
features: Optional[Features] = None

View file

@ -39,8 +39,8 @@ class OperationListParams(TypedDict, total=False):
e.g., `thresholds.suggested_threshold`.
"""
page: object
page: int
"""Page number of paginated results."""
per_page: float
"""Number of results to return per page"""
per_page: int
"""Maximum number of results per page."""

View file

@ -0,0 +1,227 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Union, Optional
from datetime import datetime
from typing_extensions import Literal
from ..._models import BaseModel
__all__ = [
"OperationListResponse",
"Features",
"FeaturesAPIShieldOperationFeatureThresholds",
"FeaturesAPIShieldOperationFeatureThresholdsThresholds",
"FeaturesAPIShieldOperationFeatureParameterSchemas",
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas",
"FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas",
"FeaturesAPIShieldOperationFeatureAPIRouting",
"FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting",
"FeaturesAPIShieldOperationFeatureConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95",
"FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99",
"FeaturesAPIShieldOperationFeatureSchemaInfo",
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo",
"FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema",
]
class FeaturesAPIShieldOperationFeatureThresholdsThresholds(BaseModel):
auth_id_tokens: Optional[int] = None
"""The total number of auth-ids seen across this calculation."""
data_points: Optional[int] = None
"""The number of data points used for the threshold suggestion calculation."""
last_updated: Optional[datetime] = None
p50: Optional[int] = None
"""The p50 quantile of requests (in period_seconds)."""
p90: Optional[int] = None
"""The p90 quantile of requests (in period_seconds)."""
p99: Optional[int] = None
"""The p99 quantile of requests (in period_seconds)."""
period_seconds: Optional[int] = None
"""The period over which this threshold is suggested."""
requests: Optional[int] = None
"""The estimated number of requests covered by these calculations."""
suggested_threshold: Optional[int] = None
"""The suggested threshold in requests done by the same auth_id or period_seconds."""
class FeaturesAPIShieldOperationFeatureThresholds(BaseModel):
thresholds: Optional[FeaturesAPIShieldOperationFeatureThresholdsThresholds] = None
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas(BaseModel):
parameters: Optional[List[object]] = None
"""An array containing the learned parameter schemas."""
responses: Optional[object] = None
"""An empty response object.
This field is required to yield a valid operation schema.
"""
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel):
last_updated: Optional[datetime] = None
parameter_schemas: Optional[
FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas
] = None
"""An operation schema object containing a response."""
class FeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel):
parameter_schemas: FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas
class FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting(BaseModel):
last_updated: Optional[datetime] = None
route: Optional[str] = None
"""Target route."""
class FeaturesAPIShieldOperationFeatureAPIRouting(BaseModel):
api_routing: Optional[FeaturesAPIShieldOperationFeatureAPIRoutingAPIRouting] = None
"""API Routing settings on endpoint."""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""
upper: Optional[float] = None
"""Upper bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""
upper: Optional[float] = None
"""Upper bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99(
BaseModel
):
lower: Optional[float] = None
"""Lower bound for percentile estimate"""
upper: Optional[float] = None
"""Upper bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals(
BaseModel
):
p90: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP90
] = None
"""Upper and lower bound for percentile estimate"""
p95: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP95
] = None
"""Upper and lower bound for percentile estimate"""
p99: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervalsP99
] = None
"""Upper and lower bound for percentile estimate"""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold(BaseModel):
confidence_intervals: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThresholdConfidenceIntervals
] = None
mean: Optional[float] = None
"""Suggested threshold."""
class FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals(BaseModel):
last_updated: Optional[datetime] = None
suggested_threshold: Optional[
FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervalsSuggestedThreshold
] = None
class FeaturesAPIShieldOperationFeatureConfidenceIntervals(BaseModel):
confidence_intervals: Optional[FeaturesAPIShieldOperationFeatureConfidenceIntervalsConfidenceIntervals] = None
class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema(BaseModel):
id: Optional[str] = None
"""UUID"""
created_at: Optional[datetime] = None
is_learned: Optional[bool] = None
"""True if schema is Cloudflare-provided."""
name: Optional[str] = None
"""Schema file name."""
class FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo(BaseModel):
active_schema: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfoActiveSchema] = None
"""Schema active on endpoint."""
learned_available: Optional[bool] = None
"""True if a Cloudflare-provided learned schema is available for this endpoint."""
mitigation_action: Optional[Literal["none", "log", "block"]] = None
"""Action taken on requests failing validation."""
class FeaturesAPIShieldOperationFeatureSchemaInfo(BaseModel):
schema_info: Optional[FeaturesAPIShieldOperationFeatureSchemaInfoSchemaInfo] = None
Features = Union[
FeaturesAPIShieldOperationFeatureThresholds,
FeaturesAPIShieldOperationFeatureParameterSchemas,
FeaturesAPIShieldOperationFeatureAPIRouting,
FeaturesAPIShieldOperationFeatureConfidenceIntervals,
FeaturesAPIShieldOperationFeatureSchemaInfo,
]
class OperationListResponse(BaseModel):
endpoint: str
"""
The endpoint which can contain path parameter templates in curly braces, each
will be replaced from left to right with {varN}, starting with {var1}, during
insertion. This will further be Cloudflare-normalized upon insertion. See:
https://developers.cloudflare.com/rules/normalization/how-it-works/.
"""
host: str
"""RFC3986-compliant host."""
last_updated: datetime
method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]
"""The HTTP method used to access the endpoint."""
operation_id: str
"""UUID"""
features: Optional[Features] = None

View file

@ -19,7 +19,7 @@ class PublicSchema(BaseModel):
"""Name of the schema"""
schema_id: str
"""UUID identifier"""
"""UUID"""
source: Optional[str] = None
"""Source of the schema"""

View file

@ -1,7 +1,7 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import Union, Optional
from typing import Union
__all__ = ["UserSchemaDeleteResponse"]
UserSchemaDeleteResponse = Union[Optional[str], Optional[object]]
UserSchemaDeleteResponse = Union[str, object]

View file

@ -14,10 +14,10 @@ class UserSchemaListParams(TypedDict, total=False):
omit_source: bool
"""Omit the source-files of schemas and only retrieve their meta-data."""
page: object
page: int
"""Page number of paginated results."""
per_page: object
per_page: int
"""Maximum number of results per page."""
validation_enabled: bool

View file

@ -37,8 +37,8 @@ class OperationListParams(TypedDict, total=False):
schema that already exist in API Shield Endpoint Management.
"""
page: object
page: int
"""Page number of paginated results."""
per_page: object
per_page: int
"""Maximum number of results per page."""

View file

@ -9,7 +9,7 @@ import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.api_gateway import DiscoveryOperation
from cloudflare.types.api_gateway.discovery import OperationEditResponse
@ -24,7 +24,7 @@ class TestOperations:
operation = client.api_gateway.discovery.operations.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
@ -37,11 +37,11 @@ class TestOperations:
method=["GET"],
order="method",
origin="ML",
page={},
per_page={},
page=1,
per_page=5,
state="review",
)
assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
@ -52,7 +52,7 @@ class TestOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
@ -63,7 +63,7 @@ class TestOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -77,7 +77,7 @@ class TestOperations:
@parametrize
def test_method_edit(self, client: Cloudflare) -> None:
operation = client.api_gateway.discovery.operations.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(OperationEditResponse, operation, path=["response"])
@ -85,7 +85,7 @@ class TestOperations:
@parametrize
def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
operation = client.api_gateway.discovery.operations.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
state="review",
)
@ -94,7 +94,7 @@ class TestOperations:
@parametrize
def test_raw_response_edit(self, client: Cloudflare) -> None:
response = client.api_gateway.discovery.operations.with_raw_response.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@ -106,7 +106,7 @@ class TestOperations:
@parametrize
def test_streaming_response_edit(self, client: Cloudflare) -> None:
with client.api_gateway.discovery.operations.with_streaming_response.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
@ -121,7 +121,7 @@ class TestOperations:
def test_path_params_edit(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
client.api_gateway.discovery.operations.with_raw_response.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="",
)
@ -140,7 +140,7 @@ class TestAsyncOperations:
operation = await async_client.api_gateway.discovery.operations.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
@ -153,11 +153,11 @@ class TestAsyncOperations:
method=["GET"],
order="method",
origin="ML",
page={},
per_page={},
page=1,
per_page=5,
state="review",
)
assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
@ -168,7 +168,7 @@ class TestAsyncOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
@ -179,7 +179,7 @@ class TestAsyncOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[DiscoveryOperation], operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -193,7 +193,7 @@ class TestAsyncOperations:
@parametrize
async def test_method_edit(self, async_client: AsyncCloudflare) -> None:
operation = await async_client.api_gateway.discovery.operations.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(OperationEditResponse, operation, path=["response"])
@ -201,7 +201,7 @@ class TestAsyncOperations:
@parametrize
async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None:
operation = await async_client.api_gateway.discovery.operations.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
state="review",
)
@ -210,7 +210,7 @@ class TestAsyncOperations:
@parametrize
async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None:
response = await async_client.api_gateway.discovery.operations.with_raw_response.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@ -222,7 +222,7 @@ class TestAsyncOperations:
@parametrize
async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None:
async with async_client.api_gateway.discovery.operations.with_streaming_response.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
@ -237,7 +237,7 @@ class TestAsyncOperations:
async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
await async_client.api_gateway.discovery.operations.with_raw_response.edit(
operation_id="0d9bf70c-92e1-4bb3-9411-34a3bcc59003",
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="",
)

View file

@ -22,13 +22,6 @@ class TestConfigurations:
@parametrize
def test_method_update(self, client: Cloudflare) -> None:
configuration = client.api_gateway.configurations.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"])
@parametrize
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
configuration = client.api_gateway.configurations.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
auth_id_characteristics=[
@ -44,6 +37,12 @@ class TestConfigurations:
def test_raw_response_update(self, client: Cloudflare) -> None:
response = client.api_gateway.configurations.with_raw_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
auth_id_characteristics=[
{
"name": "authorization",
"type": "header",
}
],
)
assert response.is_closed is True
@ -55,6 +54,12 @@ class TestConfigurations:
def test_streaming_response_update(self, client: Cloudflare) -> None:
with client.api_gateway.configurations.with_streaming_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
auth_id_characteristics=[
{
"name": "authorization",
"type": "header",
}
],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@ -69,6 +74,12 @@ class TestConfigurations:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
client.api_gateway.configurations.with_raw_response.update(
zone_id="",
auth_id_characteristics=[
{
"name": "authorization",
"type": "header",
}
],
)
@parametrize
@ -123,13 +134,6 @@ class TestAsyncConfigurations:
@parametrize
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
configuration = await async_client.api_gateway.configurations.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"])
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
configuration = await async_client.api_gateway.configurations.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
auth_id_characteristics=[
@ -145,6 +149,12 @@ class TestAsyncConfigurations:
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
response = await async_client.api_gateway.configurations.with_raw_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
auth_id_characteristics=[
{
"name": "authorization",
"type": "header",
}
],
)
assert response.is_closed is True
@ -156,6 +166,12 @@ class TestAsyncConfigurations:
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
async with async_client.api_gateway.configurations.with_streaming_response.update(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
auth_id_characteristics=[
{
"name": "authorization",
"type": "header",
}
],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@ -170,6 +186,12 @@ class TestAsyncConfigurations:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
await async_client.api_gateway.configurations.with_raw_response.update(
zone_id="",
auth_id_characteristics=[
{
"name": "authorization",
"type": "header",
}
],
)
@parametrize

View file

@ -3,15 +3,16 @@
from __future__ import annotations
import os
from typing import Any, Optional, cast
from typing import Any, cast
import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.api_gateway import (
APIShield,
OperationGetResponse,
OperationListResponse,
OperationCreateResponse,
OperationDeleteResponse,
)
@ -44,7 +45,7 @@ class TestOperations:
},
],
)
assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"])
assert_matches_type(OperationCreateResponse, operation, path=["response"])
@parametrize
def test_raw_response_create(self, client: Cloudflare) -> None:
@ -72,7 +73,7 @@ class TestOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"])
assert_matches_type(OperationCreateResponse, operation, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Cloudflare) -> None:
@ -100,7 +101,7 @@ class TestOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"])
assert_matches_type(OperationCreateResponse, operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -133,7 +134,7 @@ class TestOperations:
operation = client.api_gateway.operations.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
@ -145,10 +146,10 @@ class TestOperations:
host=["api.cloudflare.com"],
method=["GET"],
order="method",
page={},
page=1,
per_page=5,
)
assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
@ -159,7 +160,7 @@ class TestOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
@ -170,7 +171,7 @@ class TestOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -235,7 +236,7 @@ class TestOperations:
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
@parametrize
def test_method_get_with_all_params(self, client: Cloudflare) -> None:
@ -244,7 +245,7 @@ class TestOperations:
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
feature=["thresholds"],
)
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
@parametrize
def test_raw_response_get(self, client: Cloudflare) -> None:
@ -256,7 +257,7 @@ class TestOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
@parametrize
def test_streaming_response_get(self, client: Cloudflare) -> None:
@ -268,7 +269,7 @@ class TestOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -312,7 +313,7 @@ class TestAsyncOperations:
},
],
)
assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"])
assert_matches_type(OperationCreateResponse, operation, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
@ -340,7 +341,7 @@ class TestAsyncOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"])
assert_matches_type(OperationCreateResponse, operation, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
@ -368,7 +369,7 @@ class TestAsyncOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"])
assert_matches_type(OperationCreateResponse, operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -401,7 +402,7 @@ class TestAsyncOperations:
operation = await async_client.api_gateway.operations.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
@ -413,10 +414,10 @@ class TestAsyncOperations:
host=["api.cloudflare.com"],
method=["GET"],
order="method",
page={},
page=1,
per_page=5,
)
assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
@ -427,7 +428,7 @@ class TestAsyncOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
@ -438,7 +439,7 @@ class TestAsyncOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -503,7 +504,7 @@ class TestAsyncOperations:
operation_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
@parametrize
async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None:
@ -512,7 +513,7 @@ class TestAsyncOperations:
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
feature=["thresholds"],
)
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
@parametrize
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
@ -524,7 +525,7 @@ class TestAsyncOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
@parametrize
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
@ -536,7 +537,7 @@ class TestAsyncOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(APIShield, operation, path=["response"])
assert_matches_type(OperationGetResponse, operation, path=["response"])
assert cast(Any, response.is_closed) is True

View file

@ -3,13 +3,13 @@
from __future__ import annotations
import os
from typing import Any, cast
from typing import Any, Optional, cast
import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.api_gateway import (
PublicSchema,
SchemaUpload,
@ -84,18 +84,18 @@ class TestUserSchemas:
user_schema = client.api_gateway.user_schemas.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
user_schema = client.api_gateway.user_schemas.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
omit_source=True,
page={},
per_page={},
page=1,
per_page=5,
validation_enabled=True,
)
assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
@ -106,7 +106,7 @@ class TestUserSchemas:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = response.parse()
assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
@ -117,7 +117,7 @@ class TestUserSchemas:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = response.parse()
assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
assert cast(Any, response.is_closed) is True
@ -134,7 +134,7 @@ class TestUserSchemas:
schema_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"])
assert_matches_type(Optional[UserSchemaDeleteResponse], user_schema, path=["response"])
@parametrize
def test_raw_response_delete(self, client: Cloudflare) -> None:
@ -146,7 +146,7 @@ class TestUserSchemas:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = response.parse()
assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"])
assert_matches_type(Optional[UserSchemaDeleteResponse], user_schema, path=["response"])
@parametrize
def test_streaming_response_delete(self, client: Cloudflare) -> None:
@ -158,7 +158,7 @@ class TestUserSchemas:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = response.parse()
assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"])
assert_matches_type(Optional[UserSchemaDeleteResponse], user_schema, path=["response"])
assert cast(Any, response.is_closed) is True
@ -356,18 +356,18 @@ class TestAsyncUserSchemas:
user_schema = await async_client.api_gateway.user_schemas.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
user_schema = await async_client.api_gateway.user_schemas.list(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
omit_source=True,
page={},
per_page={},
page=1,
per_page=5,
validation_enabled=True,
)
assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
@ -378,7 +378,7 @@ class TestAsyncUserSchemas:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = await response.parse()
assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
@ -389,7 +389,7 @@ class TestAsyncUserSchemas:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = await response.parse()
assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[PublicSchema], user_schema, path=["response"])
assert cast(Any, response.is_closed) is True
@ -406,7 +406,7 @@ class TestAsyncUserSchemas:
schema_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"])
assert_matches_type(Optional[UserSchemaDeleteResponse], user_schema, path=["response"])
@parametrize
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
@ -418,7 +418,7 @@ class TestAsyncUserSchemas:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = await response.parse()
assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"])
assert_matches_type(Optional[UserSchemaDeleteResponse], user_schema, path=["response"])
@parametrize
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
@ -430,7 +430,7 @@ class TestAsyncUserSchemas:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
user_schema = await response.parse()
assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"])
assert_matches_type(Optional[UserSchemaDeleteResponse], user_schema, path=["response"])
assert cast(Any, response.is_closed) is True

View file

@ -9,7 +9,7 @@ import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.api_gateway.user_schemas import OperationListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@ -24,7 +24,7 @@ class TestOperations:
schema_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
@ -36,10 +36,10 @@ class TestOperations:
host=["api.cloudflare.com"],
method=["GET"],
operation_status="new",
page={},
per_page={},
page=1,
per_page=5,
)
assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
@ -51,7 +51,7 @@ class TestOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
@ -63,7 +63,7 @@ class TestOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = response.parse()
assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
assert cast(Any, response.is_closed) is True
@ -91,7 +91,7 @@ class TestAsyncOperations:
schema_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
@ -103,10 +103,10 @@ class TestAsyncOperations:
host=["api.cloudflare.com"],
method=["GET"],
operation_status="new",
page={},
per_page={},
page=1,
per_page=5,
)
assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
@ -118,7 +118,7 @@ class TestAsyncOperations:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
@ -130,7 +130,7 @@ class TestAsyncOperations:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
operation = await response.parse()
assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[OperationListResponse], operation, path=["response"])
assert cast(Any, response.is_closed) is True