Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#341)
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 9f6893c commit 3d2205f
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 191 deletions.
20 changes: 5 additions & 15 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4360,20 +4360,15 @@ Methods:
Types:

```python
from cloudflare.types.stream import (
Watermaks,
WatermarkCreateResponse,
WatermarkDeleteResponse,
WatermarkGetResponse,
)
from cloudflare.types.stream import Watermaks, WatermarkDeleteResponse
```

Methods:

- <code title="post /accounts/{account_id}/stream/watermarks">client.stream.watermarks.<a href="./src/cloudflare/resources/stream/watermarks.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/stream/watermark_create_params.py">params</a>) -> <a href="./src/cloudflare/types/stream/watermark_create_response.py">Optional</a></code>
- <code title="post /accounts/{account_id}/stream/watermarks">client.stream.watermarks.<a href="./src/cloudflare/resources/stream/watermarks.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/stream/watermark_create_params.py">params</a>) -> <a href="./src/cloudflare/types/stream/watermaks.py">Optional</a></code>
- <code title="get /accounts/{account_id}/stream/watermarks">client.stream.watermarks.<a href="./src/cloudflare/resources/stream/watermarks.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/stream/watermaks.py">SyncSinglePage[Watermaks]</a></code>
- <code title="delete /accounts/{account_id}/stream/watermarks/{identifier}">client.stream.watermarks.<a href="./src/cloudflare/resources/stream/watermarks.py">delete</a>(identifier, \*, account_id, \*\*<a href="src/cloudflare/types/stream/watermark_delete_params.py">params</a>) -> <a href="./src/cloudflare/types/stream/watermark_delete_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/stream/watermarks/{identifier}">client.stream.watermarks.<a href="./src/cloudflare/resources/stream/watermarks.py">get</a>(identifier, \*, account_id) -> <a href="./src/cloudflare/types/stream/watermark_get_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/stream/watermarks/{identifier}">client.stream.watermarks.<a href="./src/cloudflare/resources/stream/watermarks.py">get</a>(identifier, \*, account_id) -> <a href="./src/cloudflare/types/stream/watermaks.py">Optional</a></code>

## Webhooks

Expand All @@ -4394,17 +4389,12 @@ Methods:
Types:

```python
from cloudflare.types.stream import (
Caption,
CaptionUpdateResponse,
CaptionDeleteResponse,
CaptionGetResponse,
)
from cloudflare.types.stream import Caption, CaptionDeleteResponse, CaptionGetResponse
```

Methods:

- <code title="put /accounts/{account_id}/stream/{identifier}/captions/{language}">client.stream.captions.<a href="./src/cloudflare/resources/stream/captions.py">update</a>(language, \*, account_id, identifier, \*\*<a href="src/cloudflare/types/stream/caption_update_params.py">params</a>) -> <a href="./src/cloudflare/types/stream/caption_update_response.py">Optional</a></code>
- <code title="put /accounts/{account_id}/stream/{identifier}/captions/{language}">client.stream.captions.<a href="./src/cloudflare/resources/stream/captions.py">update</a>(language, \*, account_id, identifier, \*\*<a href="src/cloudflare/types/stream/caption_update_params.py">params</a>) -> <a href="./src/cloudflare/types/stream/caption.py">Optional</a></code>
- <code title="delete /accounts/{account_id}/stream/{identifier}/captions/{language}">client.stream.captions.<a href="./src/cloudflare/resources/stream/captions.py">delete</a>(language, \*, account_id, identifier, \*\*<a href="src/cloudflare/types/stream/caption_delete_params.py">params</a>) -> <a href="./src/cloudflare/types/stream/caption_delete_response.py">str</a></code>
- <code title="get /accounts/{account_id}/stream/{identifier}/captions">client.stream.captions.<a href="./src/cloudflare/resources/stream/captions.py">get</a>(identifier, \*, account_id) -> <a href="./src/cloudflare/types/stream/caption_get_response.py">Optional</a></code>

Expand Down
58 changes: 24 additions & 34 deletions src/cloudflare/resources/stream/captions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, Type, Optional, cast
from typing import Type, Optional, cast

import httpx

Expand All @@ -24,9 +24,9 @@
make_request_options,
)
from ...types.stream import (
Caption,
CaptionGetResponse,
CaptionDeleteResponse,
CaptionUpdateResponse,
caption_delete_params,
caption_update_params,
)
Expand Down Expand Up @@ -56,7 +56,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[CaptionUpdateResponse]:
) -> Optional[Caption]:
"""
Uploads the caption or subtitle file to the endpoint for a specific BCP47
language. One caption or subtitle file per language is allowed.
Expand Down Expand Up @@ -84,22 +84,17 @@ def update(
raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}")
if not language:
raise ValueError(f"Expected a non-empty value for `language` but received {language!r}")
return cast(
Optional[CaptionUpdateResponse],
self._put(
f"/accounts/{account_id}/stream/{identifier}/captions/{language}",
body=maybe_transform({"file": file}, caption_update_params.CaptionUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CaptionUpdateResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[CaptionUpdateResponse]
), # Union types cannot be passed in as arguments in the type system
return self._put(
f"/accounts/{account_id}/stream/{identifier}/captions/{language}",
body=maybe_transform({"file": file}, caption_update_params.CaptionUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[Caption]]._unwrapper,
),
cast_to=cast(Type[Optional[Caption]], ResultWrapper[Caption]),
)

def delete(
Expand Down Expand Up @@ -220,7 +215,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[CaptionUpdateResponse]:
) -> Optional[Caption]:
"""
Uploads the caption or subtitle file to the endpoint for a specific BCP47
language. One caption or subtitle file per language is allowed.
Expand Down Expand Up @@ -248,22 +243,17 @@ async def update(
raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}")
if not language:
raise ValueError(f"Expected a non-empty value for `language` but received {language!r}")
return cast(
Optional[CaptionUpdateResponse],
await self._put(
f"/accounts/{account_id}/stream/{identifier}/captions/{language}",
body=await async_maybe_transform({"file": file}, caption_update_params.CaptionUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[CaptionUpdateResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[CaptionUpdateResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._put(
f"/accounts/{account_id}/stream/{identifier}/captions/{language}",
body=await async_maybe_transform({"file": file}, caption_update_params.CaptionUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[Caption]]._unwrapper,
),
cast_to=cast(Type[Optional[Caption]], ResultWrapper[Caption]),
)

async def delete(
Expand Down
155 changes: 64 additions & 91 deletions src/cloudflare/resources/stream/watermarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, Optional, cast
from typing import Any, Type, Optional, cast

import httpx

Expand All @@ -25,14 +25,7 @@
AsyncPaginator,
make_request_options,
)
from ...types.stream import (
Watermaks,
WatermarkGetResponse,
WatermarkCreateResponse,
WatermarkDeleteResponse,
watermark_create_params,
watermark_delete_params,
)
from ...types.stream import Watermaks, WatermarkDeleteResponse, watermark_create_params, watermark_delete_params

__all__ = ["Watermarks", "AsyncWatermarks"]

Expand Down Expand Up @@ -62,7 +55,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[WatermarkCreateResponse]:
) -> Optional[Watermaks]:
"""
Creates watermark profiles using a single `HTTP POST multipart/form-data`
request.
Expand Down Expand Up @@ -101,32 +94,27 @@ def create(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return cast(
Optional[WatermarkCreateResponse],
self._post(
f"/accounts/{account_id}/stream/watermarks",
body=maybe_transform(
{
"file": file,
"name": name,
"opacity": opacity,
"padding": padding,
"position": position,
"scale": scale,
},
watermark_create_params.WatermarkCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[WatermarkCreateResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[WatermarkCreateResponse]
), # Union types cannot be passed in as arguments in the type system
return self._post(
f"/accounts/{account_id}/stream/watermarks",
body=maybe_transform(
{
"file": file,
"name": name,
"opacity": opacity,
"padding": padding,
"position": position,
"scale": scale,
},
watermark_create_params.WatermarkCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[Watermaks]]._unwrapper,
),
cast_to=cast(Type[Optional[Watermaks]], ResultWrapper[Watermaks]),
)

def list(
Expand Down Expand Up @@ -227,7 +215,7 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[WatermarkGetResponse]:
) -> Optional[Watermaks]:
"""
Retrieves details for a single watermark profile.
Expand All @@ -248,21 +236,16 @@ def get(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not identifier:
raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}")
return cast(
Optional[WatermarkGetResponse],
self._get(
f"/accounts/{account_id}/stream/watermarks/{identifier}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[WatermarkGetResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[WatermarkGetResponse]
), # Union types cannot be passed in as arguments in the type system
return self._get(
f"/accounts/{account_id}/stream/watermarks/{identifier}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[Watermaks]]._unwrapper,
),
cast_to=cast(Type[Optional[Watermaks]], ResultWrapper[Watermaks]),
)


Expand Down Expand Up @@ -291,7 +274,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[WatermarkCreateResponse]:
) -> Optional[Watermaks]:
"""
Creates watermark profiles using a single `HTTP POST multipart/form-data`
request.
Expand Down Expand Up @@ -330,32 +313,27 @@ async def create(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return cast(
Optional[WatermarkCreateResponse],
await self._post(
f"/accounts/{account_id}/stream/watermarks",
body=await async_maybe_transform(
{
"file": file,
"name": name,
"opacity": opacity,
"padding": padding,
"position": position,
"scale": scale,
},
watermark_create_params.WatermarkCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[WatermarkCreateResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[WatermarkCreateResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._post(
f"/accounts/{account_id}/stream/watermarks",
body=await async_maybe_transform(
{
"file": file,
"name": name,
"opacity": opacity,
"padding": padding,
"position": position,
"scale": scale,
},
watermark_create_params.WatermarkCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[Watermaks]]._unwrapper,
),
cast_to=cast(Type[Optional[Watermaks]], ResultWrapper[Watermaks]),
)

def list(
Expand Down Expand Up @@ -456,7 +434,7 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[WatermarkGetResponse]:
) -> Optional[Watermaks]:
"""
Retrieves details for a single watermark profile.
Expand All @@ -477,21 +455,16 @@ async def get(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not identifier:
raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}")
return cast(
Optional[WatermarkGetResponse],
await self._get(
f"/accounts/{account_id}/stream/watermarks/{identifier}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[WatermarkGetResponse]]._unwrapper,
),
cast_to=cast(
Any, ResultWrapper[WatermarkGetResponse]
), # Union types cannot be passed in as arguments in the type system
return await self._get(
f"/accounts/{account_id}/stream/watermarks/{identifier}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[Watermaks]]._unwrapper,
),
cast_to=cast(Type[Optional[Watermaks]], ResultWrapper[Watermaks]),
)


Expand Down
3 changes: 0 additions & 3 deletions src/cloudflare/types/stream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
from .webhook_update_params import WebhookUpdateParams as WebhookUpdateParams
from .download_create_params import DownloadCreateParams as DownloadCreateParams
from .live_input_list_params import LiveInputListParams as LiveInputListParams
from .watermark_get_response import WatermarkGetResponse as WatermarkGetResponse
from .audio_track_copy_params import AudioTrackCopyParams as AudioTrackCopyParams
from .audio_track_edit_params import AudioTrackEditParams as AudioTrackEditParams
from .caption_delete_response import CaptionDeleteResponse as CaptionDeleteResponse
from .caption_update_response import CaptionUpdateResponse as CaptionUpdateResponse
from .watermark_create_params import WatermarkCreateParams as WatermarkCreateParams
from .watermark_delete_params import WatermarkDeleteParams as WatermarkDeleteParams
from .webhook_delete_response import WebhookDeleteResponse as WebhookDeleteResponse
Expand All @@ -47,7 +45,6 @@
from .live_input_delete_params import LiveInputDeleteParams as LiveInputDeleteParams
from .live_input_list_response import LiveInputListResponse as LiveInputListResponse
from .live_input_update_params import LiveInputUpdateParams as LiveInputUpdateParams
from .watermark_create_response import WatermarkCreateResponse as WatermarkCreateResponse
from .watermark_delete_response import WatermarkDeleteResponse as WatermarkDeleteResponse
from .video_storage_usage_params import VideoStorageUsageParams as VideoStorageUsageParams
from .audio_track_delete_response import AudioTrackDeleteResponse as AudioTrackDeleteResponse
Expand Down
Loading

0 comments on commit 3d2205f

Please sign in to comment.