From 0c0db5b10da5f1092c337b21f71acf2a284bb63d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 19:04:53 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#329) --- api.md | 6 +- .../resources/logpush/datasets/jobs.py | 8 +-- src/cloudflare/resources/logpush/edge.py | 8 +-- src/cloudflare/resources/logpush/jobs.py | 57 +++++++++++-------- src/cloudflare/types/logpush/__init__.py | 1 + .../types/logpush/job_delete_response.py | 7 +++ .../logpush/datasets/test_jobs.py | 18 +++--- tests/api_resources/logpush/test_edge.py | 12 ++-- tests/api_resources/logpush/test_jobs.py | 21 ++++--- 9 files changed, 80 insertions(+), 58 deletions(-) create mode 100644 src/cloudflare/types/logpush/job_delete_response.py diff --git a/api.md b/api.md index c92fa2a6d89..2fd9d1c23e8 100644 --- a/api.md +++ b/api.md @@ -2050,7 +2050,7 @@ from cloudflare.types.logpush.datasets import JobGetResponse Methods: -- client.logpush.datasets.jobs.get(dataset_id, \*, account_id, zone_id) -> Optional +- client.logpush.datasets.jobs.get(dataset_id, \*, account_id, zone_id) -> JobGetResponse ## Edge @@ -2063,7 +2063,7 @@ from cloudflare.types.logpush import InstantLogpushJob, EdgeGetResponse Methods: - client.logpush.edge.create(\*, zone_id, \*\*params) -> Optional -- client.logpush.edge.get(\*, zone_id) -> Optional +- client.logpush.edge.get(\*, zone_id) -> EdgeGetResponse ## Jobs @@ -2078,7 +2078,7 @@ Methods: - client.logpush.jobs.create(\*, account_id, zone_id, \*\*params) -> Optional - client.logpush.jobs.update(job_id, \*, account_id, zone_id, \*\*params) -> Optional - client.logpush.jobs.list(\*, account_id, zone_id) -> SyncSinglePage[Optional] -- client.logpush.jobs.delete(job_id, \*, account_id, zone_id, \*\*params) -> object +- client.logpush.jobs.delete(job_id, \*, account_id, zone_id, \*\*params) -> Optional - client.logpush.jobs.get(job_id, \*, account_id, zone_id) -> Optional ## Ownership diff --git a/src/cloudflare/resources/logpush/datasets/jobs.py b/src/cloudflare/resources/logpush/datasets/jobs.py index 0f2629ce335..b6ce88278f4 100644 --- a/src/cloudflare/resources/logpush/datasets/jobs.py +++ b/src/cloudflare/resources/logpush/datasets/jobs.py @@ -45,7 +45,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[JobGetResponse]: + ) -> JobGetResponse: """ Lists Logpush jobs for an account or zone for a dataset. @@ -87,7 +87,7 @@ def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[JobGetResponse]], ResultWrapper[JobGetResponse]), + cast_to=cast(Type[JobGetResponse], ResultWrapper[JobGetResponse]), ) @@ -112,7 +112,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[JobGetResponse]: + ) -> JobGetResponse: """ Lists Logpush jobs for an account or zone for a dataset. @@ -154,7 +154,7 @@ async def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[JobGetResponse]], ResultWrapper[JobGetResponse]), + cast_to=cast(Type[JobGetResponse], ResultWrapper[JobGetResponse]), ) diff --git a/src/cloudflare/resources/logpush/edge.py b/src/cloudflare/resources/logpush/edge.py index 0f6f8459d42..6d7d106f081 100644 --- a/src/cloudflare/resources/logpush/edge.py +++ b/src/cloudflare/resources/logpush/edge.py @@ -105,7 +105,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[EdgeGetResponse]: + ) -> EdgeGetResponse: """ Lists Instant Logs jobs for a zone. @@ -131,7 +131,7 @@ def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[EdgeGetResponse]], ResultWrapper[EdgeGetResponse]), + cast_to=cast(Type[EdgeGetResponse], ResultWrapper[EdgeGetResponse]), ) @@ -212,7 +212,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[EdgeGetResponse]: + ) -> EdgeGetResponse: """ Lists Instant Logs jobs for a zone. @@ -238,7 +238,7 @@ async def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[EdgeGetResponse]], ResultWrapper[EdgeGetResponse]), + cast_to=cast(Type[EdgeGetResponse], ResultWrapper[EdgeGetResponse]), ) diff --git a/src/cloudflare/resources/logpush/jobs.py b/src/cloudflare/resources/logpush/jobs.py index ebb078e3439..575b0beee35 100644 --- a/src/cloudflare/resources/logpush/jobs.py +++ b/src/cloudflare/resources/logpush/jobs.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Any, Type, Optional, cast from typing_extensions import Literal import httpx @@ -28,6 +28,7 @@ ) from ...types.logpush import ( LogpushJob, + JobDeleteResponse, OutputOptionsParam, job_create_params, job_delete_params, @@ -301,7 +302,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> Optional[JobDeleteResponse]: """ Deletes a Logpush job. @@ -332,17 +333,22 @@ def delete( account_or_zone = "zones" account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", - body=maybe_transform(body, job_delete_params.JobDeleteParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper._unwrapper, + return cast( + Optional[JobDeleteResponse], + self._delete( + f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + body=maybe_transform(body, job_delete_params.JobDeleteParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[JobDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[object], ResultWrapper[object]), ) def get( @@ -665,7 +671,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> Optional[JobDeleteResponse]: """ Deletes a Logpush job. @@ -696,17 +702,22 @@ async def delete( account_or_zone = "zones" account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", - body=await async_maybe_transform(body, job_delete_params.JobDeleteParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper._unwrapper, + return cast( + Optional[JobDeleteResponse], + await self._delete( + f"/{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}", + body=await async_maybe_transform(body, job_delete_params.JobDeleteParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[JobDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[object], ResultWrapper[object]), ) async def get( diff --git a/src/cloudflare/types/logpush/__init__.py b/src/cloudflare/types/logpush/__init__.py index e3eaa13d9d2..3cb4874d683 100644 --- a/src/cloudflare/types/logpush/__init__.py +++ b/src/cloudflare/types/logpush/__init__.py @@ -10,6 +10,7 @@ from .job_update_params import JobUpdateParams as JobUpdateParams from .edge_create_params import EdgeCreateParams as EdgeCreateParams from .instant_logpush_job import InstantLogpushJob as InstantLogpushJob +from .job_delete_response import JobDeleteResponse as JobDeleteResponse from .output_options_param import OutputOptionsParam as OutputOptionsParam from .ownership_validation import OwnershipValidation as OwnershipValidation from .validate_origin_params import ValidateOriginParams as ValidateOriginParams diff --git a/src/cloudflare/types/logpush/job_delete_response.py b/src/cloudflare/types/logpush/job_delete_response.py new file mode 100644 index 00000000000..fef20041b3f --- /dev/null +++ b/src/cloudflare/types/logpush/job_delete_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union + +__all__ = ["JobDeleteResponse"] + +JobDeleteResponse = Union[List[object], str, object, None] diff --git a/tests/api_resources/logpush/datasets/test_jobs.py b/tests/api_resources/logpush/datasets/test_jobs.py index d15c3873dd5..39c7401990e 100644 --- a/tests/api_resources/logpush/datasets/test_jobs.py +++ b/tests/api_resources/logpush/datasets/test_jobs.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -25,7 +25,7 @@ def test_method_get(self, client: Cloudflare) -> None: account_id="string", zone_id="string", ) - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip() @parametrize @@ -35,7 +35,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="string", zone_id="string", ) - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip() @parametrize @@ -49,7 +49,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = response.parse() - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip() @parametrize @@ -63,7 +63,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = response.parse() - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True @@ -103,7 +103,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: account_id="string", zone_id="string", ) - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip() @parametrize @@ -113,7 +113,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="string", zone_id="string", ) - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip() @parametrize @@ -127,7 +127,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = await response.parse() - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) @pytest.mark.skip() @parametrize @@ -141,7 +141,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = await response.parse() - assert_matches_type(Optional[JobGetResponse], job, path=["response"]) + assert_matches_type(JobGetResponse, job, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/logpush/test_edge.py b/tests/api_resources/logpush/test_edge.py index b1bdf576c70..3c0826f48f8 100644 --- a/tests/api_resources/logpush/test_edge.py +++ b/tests/api_resources/logpush/test_edge.py @@ -76,7 +76,7 @@ def test_method_get(self, client: Cloudflare) -> None: edge = client.logpush.edge.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[EdgeGetResponse], edge, path=["response"]) + assert_matches_type(EdgeGetResponse, edge, path=["response"]) @pytest.mark.skip() @parametrize @@ -88,7 +88,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" edge = response.parse() - assert_matches_type(Optional[EdgeGetResponse], edge, path=["response"]) + assert_matches_type(EdgeGetResponse, edge, path=["response"]) @pytest.mark.skip() @parametrize @@ -100,7 +100,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" edge = response.parse() - assert_matches_type(Optional[EdgeGetResponse], edge, path=["response"]) + assert_matches_type(EdgeGetResponse, edge, path=["response"]) assert cast(Any, response.is_closed) is True @@ -175,7 +175,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: edge = await async_client.logpush.edge.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[EdgeGetResponse], edge, path=["response"]) + assert_matches_type(EdgeGetResponse, edge, path=["response"]) @pytest.mark.skip() @parametrize @@ -187,7 +187,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" edge = await response.parse() - assert_matches_type(Optional[EdgeGetResponse], edge, path=["response"]) + assert_matches_type(EdgeGetResponse, edge, path=["response"]) @pytest.mark.skip() @parametrize @@ -199,7 +199,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" edge = await response.parse() - assert_matches_type(Optional[EdgeGetResponse], edge, path=["response"]) + assert_matches_type(EdgeGetResponse, edge, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/logpush/test_jobs.py b/tests/api_resources/logpush/test_jobs.py index 00c5ac7f89a..ced0fa8530c 100644 --- a/tests/api_resources/logpush/test_jobs.py +++ b/tests/api_resources/logpush/test_jobs.py @@ -10,7 +10,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.logpush import LogpushJob +from cloudflare.types.logpush import ( + LogpushJob, + JobDeleteResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -261,7 +264,7 @@ def test_method_delete(self, client: Cloudflare) -> None: account_id="string", zone_id="string", ) - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) @pytest.mark.skip() @parametrize @@ -272,7 +275,7 @@ def test_method_delete_with_all_params(self, client: Cloudflare) -> None: account_id="string", zone_id="string", ) - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) @pytest.mark.skip() @parametrize @@ -287,7 +290,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = response.parse() - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) @pytest.mark.skip() @parametrize @@ -302,7 +305,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = response.parse() - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) assert cast(Any, response.is_closed) is True @@ -639,7 +642,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: account_id="string", zone_id="string", ) - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) @pytest.mark.skip() @parametrize @@ -650,7 +653,7 @@ async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare account_id="string", zone_id="string", ) - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) @pytest.mark.skip() @parametrize @@ -665,7 +668,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = await response.parse() - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) @pytest.mark.skip() @parametrize @@ -680,7 +683,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" job = await response.parse() - assert_matches_type(object, job, path=["response"]) + assert_matches_type(Optional[JobDeleteResponse], job, path=["response"]) assert cast(Any, response.is_closed) is True