Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 22, 2024
1 parent dff460b commit 0c0db5b
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 58 deletions.
6 changes: 3 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,7 @@ from cloudflare.types.logpush.datasets import JobGetResponse

Methods:

- <code title="get /{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/jobs">client.logpush.datasets.jobs.<a href="./src/cloudflare/resources/logpush/datasets/jobs.py">get</a>(dataset_id, \*, account_id, zone_id) -> <a href="./src/cloudflare/types/logpush/datasets/job_get_response.py">Optional</a></code>
- <code title="get /{account_or_zone}/{account_or_zone_id}/logpush/datasets/{dataset_id}/jobs">client.logpush.datasets.jobs.<a href="./src/cloudflare/resources/logpush/datasets/jobs.py">get</a>(dataset_id, \*, account_id, zone_id) -> <a href="./src/cloudflare/types/logpush/datasets/job_get_response.py">JobGetResponse</a></code>

## Edge

Expand All @@ -2063,7 +2063,7 @@ from cloudflare.types.logpush import InstantLogpushJob, EdgeGetResponse
Methods:

- <code title="post /zones/{zone_id}/logpush/edge">client.logpush.edge.<a href="./src/cloudflare/resources/logpush/edge.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/logpush/edge_create_params.py">params</a>) -> <a href="./src/cloudflare/types/logpush/instant_logpush_job.py">Optional</a></code>
- <code title="get /zones/{zone_id}/logpush/edge">client.logpush.edge.<a href="./src/cloudflare/resources/logpush/edge.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/logpush/edge_get_response.py">Optional</a></code>
- <code title="get /zones/{zone_id}/logpush/edge">client.logpush.edge.<a href="./src/cloudflare/resources/logpush/edge.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/logpush/edge_get_response.py">EdgeGetResponse</a></code>

## Jobs

Expand All @@ -2078,7 +2078,7 @@ Methods:
- <code title="post /{account_or_zone}/{account_or_zone_id}/logpush/jobs">client.logpush.jobs.<a href="./src/cloudflare/resources/logpush/jobs.py">create</a>(\*, account_id, zone_id, \*\*<a href="src/cloudflare/types/logpush/job_create_params.py">params</a>) -> <a href="./src/cloudflare/types/logpush/logpush_job.py">Optional</a></code>
- <code title="put /{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}">client.logpush.jobs.<a href="./src/cloudflare/resources/logpush/jobs.py">update</a>(job_id, \*, account_id, zone_id, \*\*<a href="src/cloudflare/types/logpush/job_update_params.py">params</a>) -> <a href="./src/cloudflare/types/logpush/logpush_job.py">Optional</a></code>
- <code title="get /{account_or_zone}/{account_or_zone_id}/logpush/jobs">client.logpush.jobs.<a href="./src/cloudflare/resources/logpush/jobs.py">list</a>(\*, account_id, zone_id) -> <a href="./src/cloudflare/types/logpush/logpush_job.py">SyncSinglePage[Optional]</a></code>
- <code title="delete /{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}">client.logpush.jobs.<a href="./src/cloudflare/resources/logpush/jobs.py">delete</a>(job_id, \*, account_id, zone_id, \*\*<a href="src/cloudflare/types/logpush/job_delete_params.py">params</a>) -> <a href="./src/cloudflare/types/logpush/job_delete_response.py">object</a></code>
- <code title="delete /{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}">client.logpush.jobs.<a href="./src/cloudflare/resources/logpush/jobs.py">delete</a>(job_id, \*, account_id, zone_id, \*\*<a href="src/cloudflare/types/logpush/job_delete_params.py">params</a>) -> <a href="./src/cloudflare/types/logpush/job_delete_response.py">Optional</a></code>
- <code title="get /{account_or_zone}/{account_or_zone_id}/logpush/jobs/{job_id}">client.logpush.jobs.<a href="./src/cloudflare/resources/logpush/jobs.py">get</a>(job_id, \*, account_id, zone_id) -> <a href="./src/cloudflare/types/logpush/logpush_job.py">Optional</a></code>

## Ownership
Expand Down
8 changes: 4 additions & 4 deletions src/cloudflare/resources/logpush/datasets/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]),
)


Expand All @@ -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.
Expand Down Expand Up @@ -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]),
)


Expand Down
8 changes: 4 additions & 4 deletions src/cloudflare/resources/logpush/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]),
)


Expand Down Expand Up @@ -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.
Expand All @@ -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]),
)


Expand Down
57 changes: 34 additions & 23 deletions src/cloudflare/resources/logpush/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,6 +28,7 @@
)
from ...types.logpush import (
LogpushJob,
JobDeleteResponse,
OutputOptionsParam,
job_create_params,
job_delete_params,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/cloudflare/types/logpush/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/cloudflare/types/logpush/job_delete_response.py
Original file line number Diff line number Diff line change
@@ -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]
18 changes: 9 additions & 9 deletions tests/api_resources/logpush/datasets/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

import os
from typing import Any, Optional, cast
from typing import Any, cast

import pytest

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
12 changes: 6 additions & 6 deletions tests/api_resources/logpush/test_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
Loading

0 comments on commit 0c0db5b

Please sign in to comment.