-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Millicast APIs, use dataclasses to parse objects
- Loading branch information
1 parent
69427b6
commit 77583b8
Showing
18 changed files
with
576 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
aiohttp>=3.7.4 | ||
aiofiles>=0.7.0 | ||
aiohttp-retry>=2.4.6 | ||
certifi>=2022.12.7 | ||
certifi>=2024.7.4 | ||
dataclasses-json>=0.6.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
dolbyio_rest_apis.streaming.account | ||
~~~~~~~~~~~~~~~ | ||
This module contains the functions to work with the Account APIs. | ||
""" | ||
|
||
from dolbyio_rest_apis.core.helpers import add_if_not_none | ||
from dolbyio_rest_apis.core.urls import get_rts_url | ||
from dolbyio_rest_apis.streaming.internal.http_context import StreamingHttpContext | ||
from dolbyio_rest_apis.streaming.models.account import AccountGeoCascade, AccountGeoRestrictions | ||
|
||
async def read_geo_cascade( | ||
api_secret: str, | ||
) -> AccountGeoCascade: | ||
async with StreamingHttpContext() as http_context: | ||
dict_data = await http_context.requests_get( | ||
api_secret=api_secret, | ||
url=f'{get_rts_url()}/api/account/geo_cascade', | ||
) | ||
|
||
return AccountGeoCascade.from_dict(dict_data) | ||
|
||
async def update_geo_cascade( | ||
api_secret: str, | ||
geo_cascade: AccountGeoCascade, | ||
) -> AccountGeoCascade: | ||
payload = { | ||
'isEnabled': geo_cascade.is_enabled, | ||
} | ||
add_if_not_none(payload, 'clusters', geo_cascade.clusters) | ||
|
||
async with StreamingHttpContext() as http_context: | ||
dict_data = await http_context.requests_put( | ||
api_secret=api_secret, | ||
url=f'{get_rts_url()}/api/account/geo_cascade', | ||
payload=payload, | ||
) | ||
|
||
return AccountGeoCascade.from_dict(dict_data) | ||
|
||
async def read_geo_restrictions( | ||
api_secret: str, | ||
) -> AccountGeoRestrictions: | ||
async with StreamingHttpContext() as http_context: | ||
dict_data = await http_context.requests_get( | ||
api_secret=api_secret, | ||
url=f'{get_rts_url()}/api/geo/account', | ||
) | ||
|
||
return AccountGeoRestrictions.from_dict(dict_data) | ||
|
||
async def update_geo_restrictions( | ||
api_secret: str, | ||
geo_restrictions: AccountGeoRestrictions, | ||
) -> AccountGeoRestrictions: | ||
payload = {} | ||
add_if_not_none(payload, 'allowedCountries', geo_restrictions.allowed_countries) | ||
add_if_not_none(payload, 'deniedCountries', geo_restrictions.denied_countries) | ||
|
||
async with StreamingHttpContext() as http_context: | ||
dict_data = await http_context.requests_post( | ||
api_secret=api_secret, | ||
url=f'{get_rts_url()}/api/geo/account', | ||
payload=payload, | ||
) | ||
|
||
return AccountGeoRestrictions.from_dict(dict_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
dolbyio_rest_apis.streaming.models.account | ||
~~~~~~~~~~~~~~~ | ||
This module contains the models used by the Account module. | ||
""" | ||
|
||
from dataclasses import dataclass, field | ||
from dataclasses_json import LetterCase, dataclass_json | ||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass | ||
class AccountGeoCascade: | ||
"""The :class:`AccountGeoCascade` object, the definition of the geo cascading rules for the account.""" | ||
|
||
is_enabled: bool = False | ||
clusters: list[str] = field(default_factory=lambda: []) | ||
|
||
@dataclass_json(letter_case=LetterCase.CAMEL) | ||
@dataclass | ||
class AccountGeoRestrictions: | ||
"""The :class:`AccountGeoRestrictions` object, the definition of the geo restrictions rules for the account.""" | ||
|
||
allowed_countries: list[str] = field(default_factory=lambda: []) | ||
denied_countries: list[str] = field(default_factory=lambda: []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.