Skip to content
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
5 changes: 1 addition & 4 deletions src/peertube/api/plugins/add_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ def _get_kwargs(
"method": "post",
"url": "/api/v1/plugins/install",
}
if isinstance(body, AddPluginBodyType0):
_kwargs["json"] = body.to_dict()
else:
_kwargs["json"] = body.to_dict()
_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

Expand Down
5 changes: 1 addition & 4 deletions src/peertube/api/plugins/update_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ def _get_kwargs(
"method": "post",
"url": "/api/v1/plugins/update",
}
if isinstance(body, UpdatePluginBodyType0):
_kwargs["json"] = body.to_dict()
else:
_kwargs["json"] = body.to_dict()
_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

Expand Down
13 changes: 10 additions & 3 deletions src/peertube/api/shared_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ def parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Any | None:
"""Parse response, raising error if configured."""
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
if response.status_code >= 400:
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None
else:
return None
# For successful responses, try to parse JSON
try:
return response.json()
except ValueError:
return None
5 changes: 5 additions & 0 deletions src/peertube/api/video_feeds/get_syndicated_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, cast

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.client import AuthenticatedClient, Client
Expand Down Expand Up @@ -84,6 +85,7 @@ def _build_response(
)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down Expand Up @@ -127,6 +129,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down Expand Up @@ -167,6 +170,7 @@ def sync(
).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down Expand Up @@ -210,6 +214,7 @@ async def asyncio_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, cast

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.client import AuthenticatedClient, Client
Expand Down Expand Up @@ -106,6 +107,7 @@ def _build_response(
)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down Expand Up @@ -162,6 +164,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down Expand Up @@ -215,6 +218,7 @@ def sync(
).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down Expand Up @@ -271,6 +275,7 @@ async def asyncio_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down
5 changes: 5 additions & 0 deletions src/peertube/api/video_feeds/get_syndicated_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, cast

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.client import AuthenticatedClient, Client
Expand Down Expand Up @@ -109,6 +110,7 @@ def _build_response(
)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
format_: GetSyndicatedVideosFormat,
*,
Expand Down Expand Up @@ -171,6 +173,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(
format_: GetSyndicatedVideosFormat,
*,
Expand Down Expand Up @@ -230,6 +233,7 @@ def sync(
).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
format_: GetSyndicatedVideosFormat,
*,
Expand Down Expand Up @@ -292,6 +296,7 @@ async def asyncio_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio(
format_: GetSyndicatedVideosFormat,
*,
Expand Down
4 changes: 4 additions & 0 deletions src/peertube/api/video_feeds/get_videos_podcast_feed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.api.shared_utils import build_response
Expand Down Expand Up @@ -43,6 +44,7 @@ def _build_response(
return build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
*, client: AuthenticatedClient | Client, video_channel_id: str
) -> Response[Any]:
Expand All @@ -67,6 +69,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(*, client: AuthenticatedClient | Client, video_channel_id: str) -> Any | None:
"""Videos podcast feed

Expand All @@ -82,6 +85,7 @@ def sync(*, client: AuthenticatedClient | Client, video_channel_id: str) -> Any
return sync_detailed(client=client, video_channel_id=video_channel_id).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
*, client: AuthenticatedClient | Client, video_channel_id: str
) -> Response[Any]:
Expand Down
5 changes: 5 additions & 0 deletions src/peertube/api/video_feeds/syndicated_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, cast

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.client import AuthenticatedClient, Client
Expand Down Expand Up @@ -84,6 +85,7 @@ def _build_response(
)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down Expand Up @@ -127,6 +129,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down Expand Up @@ -167,6 +170,7 @@ def sync(
).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down Expand Up @@ -210,6 +214,7 @@ async def asyncio_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio(
format_: GetSyndicatedCommentsFormat,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, cast

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.client import AuthenticatedClient, Client
Expand Down Expand Up @@ -106,6 +107,7 @@ def _build_response(
)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down Expand Up @@ -162,6 +164,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down Expand Up @@ -215,6 +218,7 @@ def sync(
).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down Expand Up @@ -271,6 +275,7 @@ async def asyncio_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio(
format_: GetSyndicatedSubscriptionVideosFormat,
*,
Expand Down
5 changes: 5 additions & 0 deletions src/peertube/api/video_feeds/syndicated_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, cast

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.client import AuthenticatedClient, Client
Expand Down Expand Up @@ -109,6 +110,7 @@ def _build_response(
)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
format_: GetSyndicatedVideosFormat,
*,
Expand Down Expand Up @@ -171,6 +173,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(
format_: GetSyndicatedVideosFormat,
*,
Expand Down Expand Up @@ -230,6 +233,7 @@ def sync(
).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
format_: GetSyndicatedVideosFormat,
*,
Expand Down Expand Up @@ -292,6 +296,7 @@ async def asyncio_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio(
format_: GetSyndicatedVideosFormat,
*,
Expand Down
4 changes: 4 additions & 0 deletions src/peertube/api/video_feeds/videos_podcast_feed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.api.shared_utils import build_response
Expand Down Expand Up @@ -43,6 +44,7 @@ def _build_response(
return build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(
*, client: AuthenticatedClient | Client, video_channel_id: str
) -> Response[Any]:
Expand All @@ -67,6 +69,7 @@ def sync_detailed(
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(*, client: AuthenticatedClient | Client, video_channel_id: str) -> Any | None:
"""Videos podcast feed

Expand All @@ -82,6 +85,7 @@ def sync(*, client: AuthenticatedClient | Client, video_channel_id: str) -> Any
return sync_detailed(client=client, video_channel_id=video_channel_id).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
*, client: AuthenticatedClient | Client, video_channel_id: str
) -> Response[Any]:
Expand Down
4 changes: 4 additions & 0 deletions src/peertube/api/video_mirroring/del_mirrored_video.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any

import httpx
from pydantic import ConfigDict, validate_call

from peertube import errors
from peertube.api.shared_utils import build_response
Expand Down Expand Up @@ -37,6 +38,7 @@ def _build_response(
return build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync_detailed(redundancy_id: str, *, client: AuthenticatedClient) -> Response[Any]:
"""Delete a mirror done on a video

Expand All @@ -59,6 +61,7 @@ def sync_detailed(redundancy_id: str, *, client: AuthenticatedClient) -> Respons
return _build_response(client=client, response=response)


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sync(redundancy_id: str, *, client: AuthenticatedClient) -> Any | None:
"""Delete a mirror done on a video

Expand All @@ -74,6 +77,7 @@ def sync(redundancy_id: str, *, client: AuthenticatedClient) -> Any | None:
return sync_detailed(redundancy_id=redundancy_id, client=client).parsed


@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def asyncio_detailed(
redundancy_id: str, *, client: AuthenticatedClient
) -> Response[Any]:
Expand Down
Loading
Loading