Skip to content
Snippets Groups Projects
Verified Commit ac4168ad authored by Georg Krause's avatar Georg Krause
Browse files

Fix all subscriptions

parent 5b1eef05
No related branches found
No related tags found
1 merge request!1Add basic model tests
Pipeline #23764 failed
...@@ -3,7 +3,7 @@ from typing import Any, Dict, Optional ...@@ -3,7 +3,7 @@ from typing import Any, Dict, Optional
import httpx import httpx
from ...client import AuthenticatedClient from ...client import AuthenticatedClient
from ...models.subscription import Subscription from ...models.all_subscriptions import AllSubscriptions
from ...types import Response from ...types import Response
...@@ -25,15 +25,15 @@ def _get_kwargs( ...@@ -25,15 +25,15 @@ def _get_kwargs(
} }
def _parse_response(*, response: httpx.Response) -> Optional[Subscription]: def _parse_response(*, response: httpx.Response) -> Optional[AllSubscriptions]:
if response.status_code == 200: if response.status_code == 200:
response_200 = Subscription.from_dict(response.json()) response_200 = AllSubscriptions.from_dict(response.json())
return response_200 return response_200
return None return None
def _build_response(*, response: httpx.Response) -> Response[Subscription]: def _build_response(*, response: httpx.Response) -> Response[AllSubscriptions]:
return Response( return Response(
status_code=response.status_code, status_code=response.status_code,
content=response.content, content=response.content,
...@@ -45,13 +45,13 @@ def _build_response(*, response: httpx.Response) -> Response[Subscription]: ...@@ -45,13 +45,13 @@ def _build_response(*, response: httpx.Response) -> Response[Subscription]:
def sync_detailed( def sync_detailed(
*, *,
client: AuthenticatedClient, client: AuthenticatedClient,
) -> Response[Subscription]: ) -> Response[AllSubscriptions]:
"""Return all the subscriptions of the current user, with only limited data """Return all the subscriptions of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display to have a performant endpoint and avoid lots of queries just to display
subscription status in the UI subscription status in the UI
Returns: Returns:
Response[Subscription] Response[AllSubscriptions]
""" """
kwargs = _get_kwargs( kwargs = _get_kwargs(
...@@ -69,13 +69,13 @@ def sync_detailed( ...@@ -69,13 +69,13 @@ def sync_detailed(
def sync( def sync(
*, *,
client: AuthenticatedClient, client: AuthenticatedClient,
) -> Optional[Subscription]: ) -> Optional[AllSubscriptions]:
"""Return all the subscriptions of the current user, with only limited data """Return all the subscriptions of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display to have a performant endpoint and avoid lots of queries just to display
subscription status in the UI subscription status in the UI
Returns: Returns:
Response[Subscription] Response[AllSubscriptions]
""" """
return sync_detailed( return sync_detailed(
...@@ -86,13 +86,13 @@ def sync( ...@@ -86,13 +86,13 @@ def sync(
async def asyncio_detailed( async def asyncio_detailed(
*, *,
client: AuthenticatedClient, client: AuthenticatedClient,
) -> Response[Subscription]: ) -> Response[AllSubscriptions]:
"""Return all the subscriptions of the current user, with only limited data """Return all the subscriptions of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display to have a performant endpoint and avoid lots of queries just to display
subscription status in the UI subscription status in the UI
Returns: Returns:
Response[Subscription] Response[AllSubscriptions]
""" """
kwargs = _get_kwargs( kwargs = _get_kwargs(
...@@ -108,13 +108,13 @@ async def asyncio_detailed( ...@@ -108,13 +108,13 @@ async def asyncio_detailed(
async def asyncio( async def asyncio(
*, *,
client: AuthenticatedClient, client: AuthenticatedClient,
) -> Optional[Subscription]: ) -> Optional[AllSubscriptions]:
"""Return all the subscriptions of the current user, with only limited data """Return all the subscriptions of the current user, with only limited data
to have a performant endpoint and avoid lots of queries just to display to have a performant endpoint and avoid lots of queries just to display
subscription status in the UI subscription status in the UI
Returns: Returns:
Response[Subscription] Response[AllSubscriptions]
""" """
return ( return (
......
...@@ -13,6 +13,7 @@ from .album_create_request import AlbumCreateRequest ...@@ -13,6 +13,7 @@ from .album_create_request import AlbumCreateRequest
from .album_request import AlbumRequest from .album_request import AlbumRequest
from .albums_list_ordering_item import AlbumsListOrderingItem from .albums_list_ordering_item import AlbumsListOrderingItem
from .all_favorite import AllFavorite from .all_favorite import AllFavorite
from .all_subscriptions import AllSubscriptions
from .allow_list_stat import AllowListStat from .allow_list_stat import AllowListStat
from .api_actor import APIActor from .api_actor import APIActor
from .api_actor_request import APIActorRequest from .api_actor_request import APIActorRequest
...@@ -65,6 +66,7 @@ from .inbox_item_request import InboxItemRequest ...@@ -65,6 +66,7 @@ from .inbox_item_request import InboxItemRequest
from .inbox_item_type_enum import InboxItemTypeEnum from .inbox_item_type_enum import InboxItemTypeEnum
from .inline_actor import InlineActor from .inline_actor import InlineActor
from .inline_actor_request import InlineActorRequest from .inline_actor_request import InlineActorRequest
from .inline_subscription import InlineSubscription
from .libraries_list_privacy_level import LibrariesListPrivacyLevel from .libraries_list_privacy_level import LibrariesListPrivacyLevel
from .library import Library from .library import Library
from .library_follow import LibraryFollow from .library_follow import LibraryFollow
......
from typing import Any, Dict, List, Type, TypeVar
import attr
from ..models.inline_subscription import InlineSubscription
T = TypeVar("T", bound="AllSubscriptions")
@attr.s(auto_attribs=True)
class AllSubscriptions:
"""
Attributes:
results (List[InlineSubscription]):
count (int):
"""
results: List[InlineSubscription]
count: int
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
results = []
for results_item_data in self.results:
results_item = results_item_data.to_dict()
results.append(results_item)
count = self.count
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"results": results,
"count": count,
}
)
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
results = []
_results = d.pop("results")
for results_item_data in _results:
results_item = InlineSubscription.from_dict(results_item_data)
results.append(results_item)
count = d.pop("count")
all_subscriptions = cls(
results=results,
count=count,
)
all_subscriptions.additional_properties = d
return all_subscriptions
@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties
from typing import Any, Dict, List, Type, TypeVar
import attr
T = TypeVar("T", bound="InlineSubscription")
@attr.s(auto_attribs=True)
class InlineSubscription:
"""
Attributes:
uuid (str):
channel (str):
"""
uuid: str
channel: str
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
uuid = self.uuid
channel = self.channel
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"uuid": uuid,
"channel": channel,
}
)
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
uuid = d.pop("uuid")
channel = d.pop("channel")
inline_subscription = cls(
uuid=uuid,
channel=channel,
)
inline_subscription.additional_properties = d
return inline_subscription
@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties
from funkwhale_api_client.models.subscription import Subscription from funkwhale_api_client.models.subscription import Subscription
from funkwhale_api_client.models.all_subscriptions import AllSubscriptions
def test_Subscription(load_data): def test_Subscription(load_data):
...@@ -10,6 +11,6 @@ def test_Subscription(load_data): ...@@ -10,6 +11,6 @@ def test_Subscription(load_data):
def test_SubscriptionAll(load_data): def test_SubscriptionAll(load_data):
response = load_data("subscription_all") response = load_data("subscription_all")
subscription_all: Subscription = Subscription.from_dict(response) subscription_all: AllSubscriptions = AllSubscriptions.from_dict(response)
assert isinstance(subscription_all, Subscription) assert isinstance(subscription_all, AllSubscriptions)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment