diff --git a/.stats.yml b/.stats.yml index 1635b8c85ae..9e4464c0c57 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a077023d5a748c646073f33bc20264fc7235f7fe9ce157d1f50f9914a3927e1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bc197b361ec3d5030fd853cb37172adbed55aa014ca7a5ac89fb498a88a8e5cb.yml diff --git a/api.md b/api.md index c514a7f3a0a..81d0684fe74 100644 --- a/api.md +++ b/api.md @@ -5545,7 +5545,7 @@ from cloudflare.types.zero_trust.access.logs import AccessRequests, AccessReques Methods: -- client.zero_trust.access.logs.access_requests.list(\*, account_id) -> Optional +- client.zero_trust.access.logs.access_requests.list(\*, account_id, \*\*params) -> Optional ### Users diff --git a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py index 9b90990d9cc..64cd98c6c50 100644 --- a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py +++ b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py @@ -2,11 +2,17 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, Union, Optional, cast +from datetime import datetime +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 ( @@ -19,6 +25,7 @@ from ....._base_client import ( make_request_options, ) +from .....types.zero_trust.access.logs import access_request_list_params from .....types.zero_trust.access.logs.access_request_list_response import AccessRequestListResponse __all__ = ["AccessRequestsResource", "AsyncAccessRequestsResource"] @@ -37,6 +44,10 @@ def list( self, *, account_id: str, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, @@ -50,6 +61,14 @@ def list( Args: account_id: Identifier + direction: The chronological sorting order for the logs. + + limit: The maximum number of log entries to retrieve. + + since: The earliest event timestamp to query. + + until: The latest event timestamp to query. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -67,6 +86,15 @@ def list( extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "limit": limit, + "since": since, + "until": until, + }, + access_request_list_params.AccessRequestListParams, + ), post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, ), cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), @@ -86,6 +114,10 @@ async def list( self, *, account_id: str, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, @@ -99,6 +131,14 @@ async def list( Args: account_id: Identifier + direction: The chronological sorting order for the logs. + + limit: The maximum number of log entries to retrieve. + + since: The earliest event timestamp to query. + + until: The latest event timestamp to query. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -116,6 +156,15 @@ async def list( extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=await async_maybe_transform( + { + "direction": direction, + "limit": limit, + "since": since, + "until": until, + }, + access_request_list_params.AccessRequestListParams, + ), post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, ), cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), diff --git a/src/cloudflare/types/zero_trust/access/logs/__init__.py b/src/cloudflare/types/zero_trust/access/logs/__init__.py index 8044ec713b3..6054daa920f 100644 --- a/src/cloudflare/types/zero_trust/access/logs/__init__.py +++ b/src/cloudflare/types/zero_trust/access/logs/__init__.py @@ -3,4 +3,5 @@ from __future__ import annotations from .access_requests import AccessRequests as AccessRequests +from .access_request_list_params import AccessRequestListParams as AccessRequestListParams from .access_request_list_response import AccessRequestListResponse as AccessRequestListResponse diff --git a/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py b/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py new file mode 100644 index 00000000000..13be0a7d46b --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["AccessRequestListParams"] + + +class AccessRequestListParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + direction: Literal["desc", "asc"] + """The chronological sorting order for the logs.""" + + limit: int + """The maximum number of log entries to retrieve.""" + + since: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """The earliest event timestamp to query.""" + + until: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """The latest event timestamp to query.""" diff --git a/tests/api_resources/zero_trust/access/logs/test_access_requests.py b/tests/api_resources/zero_trust/access/logs/test_access_requests.py index 88f7703f1a6..3eafad4f1a6 100644 --- a/tests/api_resources/zero_trust/access/logs/test_access_requests.py +++ b/tests/api_resources/zero_trust/access/logs/test_access_requests.py @@ -9,6 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime from cloudflare.types.zero_trust.access.logs import AccessRequestListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -24,6 +25,17 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + access_request = client.zero_trust.access.logs.access_requests.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + limit=0, + since=parse_datetime("2020-07-01T05:20:00Z"), + until=parse_datetime("2020-10-01T05:20:00Z"), + ) + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.access.logs.access_requests.with_raw_response.list( @@ -66,6 +78,17 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + access_request = await async_client.zero_trust.access.logs.access_requests.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + limit=0, + since=parse_datetime("2020-07-01T05:20:00Z"), + until=parse_datetime("2020-10-01T05:20:00Z"), + ) + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.access.logs.access_requests.with_raw_response.list(