Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jun 19, 2024
1 parent 7950ddd commit a3f0a62
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1348
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cc907ac853f9f492d6e9168c4a32fd2c7ccacbabbcb716280dbaa42a0d9c14f2.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f2b480625b4e667e5ed9a238c9b5314522dc9be0bf8f514bed4e03a88d09455c.yml
35 changes: 35 additions & 0 deletions src/cloudflare/resources/stream/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
maybe_transform,
strip_not_given,
async_maybe_transform,
)
from ..._compat import cached_property
Expand Down Expand Up @@ -52,6 +53,8 @@ def create(
scheduled_deletion: Union[str, datetime] | NotGiven = NOT_GIVEN,
thumbnail_timestamp_pct: float | NotGiven = NOT_GIVEN,
watermark: copy_create_params.Watermark | NotGiven = NOT_GIVEN,
upload_creator: str | NotGiven = NOT_GIVEN,
upload_metadata: str | 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 Down Expand Up @@ -90,6 +93,12 @@ def create(
divide the desired timestamp by the total duration of the video. If this value
is not set, the default thumbnail image is taken from 0s of the video.
upload_creator: A user-defined identifier for the media creator.
upload_metadata: Comma-separated key-value pairs following the TUS protocol specification. Values
are Base-64 encoded. Supported keys: `name`, `requiresignedurls`,
`allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -100,6 +109,15 @@ def create(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {
**strip_not_given(
{
"Upload-Creator": upload_creator,
"Upload-Metadata": upload_metadata,
}
),
**(extra_headers or {}),
}
return self._post(
f"/accounts/{account_id}/stream/copy",
body=maybe_transform(
Expand Down Expand Up @@ -147,6 +165,8 @@ async def create(
scheduled_deletion: Union[str, datetime] | NotGiven = NOT_GIVEN,
thumbnail_timestamp_pct: float | NotGiven = NOT_GIVEN,
watermark: copy_create_params.Watermark | NotGiven = NOT_GIVEN,
upload_creator: str | NotGiven = NOT_GIVEN,
upload_metadata: str | 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 Down Expand Up @@ -185,6 +205,12 @@ async def create(
divide the desired timestamp by the total duration of the video. If this value
is not set, the default thumbnail image is taken from 0s of the video.
upload_creator: A user-defined identifier for the media creator.
upload_metadata: Comma-separated key-value pairs following the TUS protocol specification. Values
are Base-64 encoded. Supported keys: `name`, `requiresignedurls`,
`allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -195,6 +221,15 @@ async def create(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {
**strip_not_given(
{
"Upload-Creator": upload_creator,
"Upload-Metadata": upload_metadata,
}
),
**(extra_headers or {}),
}
return await self._post(
f"/accounts/{account_id}/stream/copy",
body=await async_maybe_transform(
Expand Down
9 changes: 9 additions & 0 deletions src/cloudflare/resources/stream/direct_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
maybe_transform,
strip_not_given,
async_maybe_transform,
)
from ..._compat import cached_property
Expand Down Expand Up @@ -53,6 +54,7 @@ def create(
scheduled_deletion: Union[str, datetime] | NotGiven = NOT_GIVEN,
thumbnail_timestamp_pct: float | NotGiven = NOT_GIVEN,
watermark: direct_upload_create_params.Watermark | NotGiven = NOT_GIVEN,
upload_creator: str | 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 Down Expand Up @@ -94,6 +96,8 @@ def create(
divide the desired timestamp by the total duration of the video. If this value
is not set, the default thumbnail image is taken from 0s of the video.
upload_creator: A user-defined identifier for the media creator.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -104,6 +108,7 @@ def create(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {**strip_not_given({"Upload-Creator": upload_creator}), **(extra_headers or {})}
return self._post(
f"/accounts/{account_id}/stream/direct_upload",
body=maybe_transform(
Expand Down Expand Up @@ -153,6 +158,7 @@ async def create(
scheduled_deletion: Union[str, datetime] | NotGiven = NOT_GIVEN,
thumbnail_timestamp_pct: float | NotGiven = NOT_GIVEN,
watermark: direct_upload_create_params.Watermark | NotGiven = NOT_GIVEN,
upload_creator: str | 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 Down Expand Up @@ -194,6 +200,8 @@ async def create(
divide the desired timestamp by the total duration of the video. If this value
is not set, the default thumbnail image is taken from 0s of the video.
upload_creator: A user-defined identifier for the media creator.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -204,6 +212,7 @@ async def create(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {**strip_not_given({"Upload-Creator": upload_creator}), **(extra_headers or {})}
return await self._post(
f"/accounts/{account_id}/stream/direct_upload",
body=await async_maybe_transform(
Expand Down
55 changes: 55 additions & 0 deletions src/cloudflare/resources/stream/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
from ..._utils import (
maybe_transform,
strip_not_given,
async_maybe_transform,
)
from .captions import (
Expand Down Expand Up @@ -205,6 +206,10 @@ def create(
*,
account_id: str,
body: object,
tus_resumable: Literal["1.0.0"],
upload_length: int,
upload_creator: str | NotGiven = NOT_GIVEN,
upload_metadata: str | 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 @@ -222,6 +227,18 @@ def create(
Args:
account_id: The account identifier tag.
tus_resumable: Specifies the TUS protocol version. This value must be included in every upload
request. Notes: The only supported version of TUS protocol is 1.0.0.
upload_length: Indicates the size of the entire upload in bytes. The value must be a
non-negative integer.
upload_creator: A user-defined identifier for the media creator.
upload_metadata: Comma-separated key-value pairs following the TUS protocol specification. Values
are Base-64 encoded. Supported keys: `name`, `requiresignedurls`,
`allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -233,6 +250,17 @@ def create(
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
extra_headers = {
**strip_not_given(
{
"Tus-Resumable": str(tus_resumable),
"Upload-Length": str(upload_length),
"Upload-Creator": upload_creator,
"Upload-Metadata": upload_metadata,
}
),
**(extra_headers or {}),
}
return self._post(
f"/accounts/{account_id}/stream",
body=maybe_transform(body, stream_create_params.StreamCreateParams),
Expand Down Expand Up @@ -475,6 +503,10 @@ async def create(
*,
account_id: str,
body: object,
tus_resumable: Literal["1.0.0"],
upload_length: int,
upload_creator: str | NotGiven = NOT_GIVEN,
upload_metadata: str | 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 @@ -492,6 +524,18 @@ async def create(
Args:
account_id: The account identifier tag.
tus_resumable: Specifies the TUS protocol version. This value must be included in every upload
request. Notes: The only supported version of TUS protocol is 1.0.0.
upload_length: Indicates the size of the entire upload in bytes. The value must be a
non-negative integer.
upload_creator: A user-defined identifier for the media creator.
upload_metadata: Comma-separated key-value pairs following the TUS protocol specification. Values
are Base-64 encoded. Supported keys: `name`, `requiresignedurls`,
`allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -503,6 +547,17 @@ async def create(
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
extra_headers = {
**strip_not_given(
{
"Tus-Resumable": str(tus_resumable),
"Upload-Length": str(upload_length),
"Upload-Creator": upload_creator,
"Upload-Metadata": upload_metadata,
}
),
**(extra_headers or {}),
}
return await self._post(
f"/accounts/{account_id}/stream",
body=await async_maybe_transform(body, stream_create_params.StreamCreateParams),
Expand Down
23 changes: 23 additions & 0 deletions src/cloudflare/resources/workers/scripts/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ...._utils import (
extract_files,
maybe_transform,
strip_not_given,
deepcopy_minimal,
async_maybe_transform,
)
Expand Down Expand Up @@ -56,6 +57,8 @@ def update(
account_id: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
cf_worker_main_module_part: str | 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 Down Expand Up @@ -92,6 +95,15 @@ def update(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not script_name:
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
extra_headers = {
**strip_not_given(
{
"CF-WORKER-BODY-PART": cf_worker_body_part,
"CF-WORKER-MAIN-MODULE-PART": cf_worker_main_module_part,
}
),
**(extra_headers or {}),
}
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
Expand Down Expand Up @@ -176,6 +188,8 @@ async def update(
account_id: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
cf_worker_main_module_part: str | 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 Down Expand Up @@ -212,6 +226,15 @@ async def update(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not script_name:
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
extra_headers = {
**strip_not_given(
{
"CF-WORKER-BODY-PART": cf_worker_body_part,
"CF-WORKER-MAIN-MODULE-PART": cf_worker_main_module_part,
}
),
**(extra_headers or {}),
}
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ......_utils import (
extract_files,
maybe_transform,
strip_not_given,
deepcopy_minimal,
async_maybe_transform,
)
Expand Down Expand Up @@ -57,6 +58,8 @@ def update(
dispatch_namespace: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
cf_worker_main_module_part: str | 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 Down Expand Up @@ -97,6 +100,15 @@ def update(
raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}")
if not script_name:
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
extra_headers = {
**strip_not_given(
{
"CF-WORKER-BODY-PART": cf_worker_body_part,
"CF-WORKER-MAIN-MODULE-PART": cf_worker_main_module_part,
}
),
**(extra_headers or {}),
}
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
Expand Down Expand Up @@ -188,6 +200,8 @@ async def update(
dispatch_namespace: str,
any_part_name: List[FileTypes] | NotGiven = NOT_GIVEN,
metadata: WorkerMetadataParam | NotGiven = NOT_GIVEN,
cf_worker_body_part: str | NotGiven = NOT_GIVEN,
cf_worker_main_module_part: str | 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 Down Expand Up @@ -228,6 +242,15 @@ async def update(
raise ValueError(f"Expected a non-empty value for `dispatch_namespace` but received {dispatch_namespace!r}")
if not script_name:
raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}")
extra_headers = {
**strip_not_given(
{
"CF-WORKER-BODY-PART": cf_worker_body_part,
"CF-WORKER-MAIN-MODULE-PART": cf_worker_main_module_part,
}
),
**(extra_headers or {}),
}
body = deepcopy_minimal(
{
"any_part_name": any_part_name,
Expand Down
10 changes: 10 additions & 0 deletions src/cloudflare/types/stream/copy_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ class CopyCreateParams(TypedDict, total=False):

watermark: Watermark

upload_creator: Annotated[str, PropertyInfo(alias="Upload-Creator")]
"""A user-defined identifier for the media creator."""

upload_metadata: Annotated[str, PropertyInfo(alias="Upload-Metadata")]
"""Comma-separated key-value pairs following the TUS protocol specification.
Values are Base-64 encoded. Supported keys: `name`, `requiresignedurls`,
`allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`.
"""


class Watermark(TypedDict, total=False):
uid: str
Expand Down
3 changes: 3 additions & 0 deletions src/cloudflare/types/stream/direct_upload_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class DirectUploadCreateParams(TypedDict, total=False):

watermark: Watermark

upload_creator: Annotated[str, PropertyInfo(alias="Upload-Creator")]
"""A user-defined identifier for the media creator."""


class Watermark(TypedDict, total=False):
uid: str
Expand Down
Loading

0 comments on commit a3f0a62

Please sign in to comment.