Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5545,7 +5545,7 @@ from cloudflare.types.zero_trust.access.logs import AccessRequests, AccessReques

Methods:

- <code title="get /accounts/{account_id}/access/logs/access_requests">client.zero_trust.access.logs.access_requests.<a href="./src/cloudflare/resources/zero_trust/access/logs/access_requests.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/access/logs/access_requests">client.zero_trust.access.logs.access_requests.<a href="./src/cloudflare/resources/zero_trust/access/logs/access_requests.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py">Optional</a></code>

### Users

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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"]
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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]),
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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]),
Expand Down
1 change: 1 addition & 0 deletions src/cloudflare/types/zero_trust/access/logs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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."""
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down