-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
125 changed files
with
7,197 additions
and
5,752 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
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 +1 @@ | ||
b71c951f2eb600cc2a1f073151c9a0c003bd48f1210262ab7df58c9d06e05aba | ||
1543c5968e0e568095cb5eeb44a3c7ab3179d6491f270932e268ab579c8d5948 |
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,154 @@ | ||
from http import HTTPStatus | ||
from typing import Any, Dict, Optional, Union | ||
|
||
import httpx | ||
|
||
from ... import errors | ||
from ...client import Client | ||
from ...models.error import Error | ||
from ...models.settings import Settings | ||
from ...types import Response | ||
|
||
|
||
def _get_kwargs( | ||
*, | ||
client: Client, | ||
) -> Dict[str, Any]: | ||
url = "{}/settings".format(client.base_url) | ||
|
||
headers: Dict[str, str] = client.get_headers() | ||
cookies: Dict[str, Any] = client.get_cookies() | ||
|
||
return { | ||
"method": "get", | ||
"url": url, | ||
"headers": headers, | ||
"cookies": cookies, | ||
"timeout": client.get_timeout(), | ||
} | ||
|
||
|
||
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Error, Settings]]: | ||
if response.status_code == HTTPStatus.OK: | ||
response_200 = Settings.from_dict(response.json()) | ||
|
||
return response_200 | ||
if response.status_code == HTTPStatus.BAD_REQUEST: | ||
response_400 = Error.from_dict(response.json()) | ||
|
||
return response_400 | ||
if response.status_code == HTTPStatus.UNAUTHORIZED: | ||
response_401 = Error.from_dict(response.json()) | ||
|
||
return response_401 | ||
if response.status_code == HTTPStatus.FORBIDDEN: | ||
response_403 = Error.from_dict(response.json()) | ||
|
||
return response_403 | ||
if response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR: | ||
response_500 = Error.from_dict(response.json()) | ||
|
||
return response_500 | ||
if client.raise_on_unexpected_status: | ||
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") | ||
else: | ||
return None | ||
|
||
|
||
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Error, Settings]]: | ||
return Response( | ||
status_code=HTTPStatus(response.status_code), | ||
content=response.content, | ||
headers=response.headers, | ||
parsed=_parse_response(client=client, response=response), | ||
) | ||
|
||
|
||
def sync_detailed( | ||
*, | ||
client: Client, | ||
) -> Response[Union[Error, Settings]]: | ||
"""retrieve the instance settings | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
kwargs = _get_kwargs( | ||
client=client, | ||
) | ||
|
||
response = httpx.request( | ||
verify=client.verify_ssl, | ||
**kwargs, | ||
) | ||
|
||
return _build_response(client=client, response=response) | ||
|
||
|
||
def sync( | ||
*, | ||
client: Client, | ||
) -> Optional[Union[Error, Settings]]: | ||
"""retrieve the instance settings | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
return sync_detailed( | ||
client=client, | ||
).parsed | ||
|
||
|
||
async def asyncio_detailed( | ||
*, | ||
client: Client, | ||
) -> Response[Union[Error, Settings]]: | ||
"""retrieve the instance settings | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
kwargs = _get_kwargs( | ||
client=client, | ||
) | ||
|
||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client: | ||
response = await _client.request(**kwargs) | ||
|
||
return _build_response(client=client, response=response) | ||
|
||
|
||
async def asyncio( | ||
*, | ||
client: Client, | ||
) -> Optional[Union[Error, Settings]]: | ||
"""retrieve the instance settings | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
return ( | ||
await asyncio_detailed( | ||
client=client, | ||
) | ||
).parsed |
182 changes: 182 additions & 0 deletions
182
src/tuneinsight/api/sdk/api/api_admin/patch_settings.py
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,182 @@ | ||
from http import HTTPStatus | ||
from typing import Any, Dict, Optional, Union | ||
|
||
import httpx | ||
|
||
from ... import errors | ||
from ...client import Client | ||
from ...models.error import Error | ||
from ...models.settings import Settings | ||
from ...types import Response | ||
|
||
|
||
def _get_kwargs( | ||
*, | ||
client: Client, | ||
json_body: Settings, | ||
) -> Dict[str, Any]: | ||
url = "{}/settings".format(client.base_url) | ||
|
||
headers: Dict[str, str] = client.get_headers() | ||
cookies: Dict[str, Any] = client.get_cookies() | ||
|
||
json_json_body = json_body.to_dict() | ||
|
||
return { | ||
"method": "patch", | ||
"url": url, | ||
"headers": headers, | ||
"cookies": cookies, | ||
"timeout": client.get_timeout(), | ||
"json": json_json_body, | ||
} | ||
|
||
|
||
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Error, Settings]]: | ||
if response.status_code == HTTPStatus.OK: | ||
response_200 = Settings.from_dict(response.json()) | ||
|
||
return response_200 | ||
if response.status_code == HTTPStatus.BAD_REQUEST: | ||
response_400 = Error.from_dict(response.json()) | ||
|
||
return response_400 | ||
if response.status_code == HTTPStatus.UNAUTHORIZED: | ||
response_401 = Error.from_dict(response.json()) | ||
|
||
return response_401 | ||
if response.status_code == HTTPStatus.FORBIDDEN: | ||
response_403 = Error.from_dict(response.json()) | ||
|
||
return response_403 | ||
if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: | ||
response_422 = Error.from_dict(response.json()) | ||
|
||
return response_422 | ||
if response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR: | ||
response_500 = Error.from_dict(response.json()) | ||
|
||
return response_500 | ||
if client.raise_on_unexpected_status: | ||
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}") | ||
else: | ||
return None | ||
|
||
|
||
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[Error, Settings]]: | ||
return Response( | ||
status_code=HTTPStatus(response.status_code), | ||
content=response.content, | ||
headers=response.headers, | ||
parsed=_parse_response(client=client, response=response), | ||
) | ||
|
||
|
||
def sync_detailed( | ||
*, | ||
client: Client, | ||
json_body: Settings, | ||
) -> Response[Union[Error, Settings]]: | ||
"""modify the settings | ||
Args: | ||
json_body (Settings): instance settings that is configurable by the administrator. | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
kwargs = _get_kwargs( | ||
client=client, | ||
json_body=json_body, | ||
) | ||
|
||
response = httpx.request( | ||
verify=client.verify_ssl, | ||
**kwargs, | ||
) | ||
|
||
return _build_response(client=client, response=response) | ||
|
||
|
||
def sync( | ||
*, | ||
client: Client, | ||
json_body: Settings, | ||
) -> Optional[Union[Error, Settings]]: | ||
"""modify the settings | ||
Args: | ||
json_body (Settings): instance settings that is configurable by the administrator. | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
return sync_detailed( | ||
client=client, | ||
json_body=json_body, | ||
).parsed | ||
|
||
|
||
async def asyncio_detailed( | ||
*, | ||
client: Client, | ||
json_body: Settings, | ||
) -> Response[Union[Error, Settings]]: | ||
"""modify the settings | ||
Args: | ||
json_body (Settings): instance settings that is configurable by the administrator. | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
kwargs = _get_kwargs( | ||
client=client, | ||
json_body=json_body, | ||
) | ||
|
||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client: | ||
response = await _client.request(**kwargs) | ||
|
||
return _build_response(client=client, response=response) | ||
|
||
|
||
async def asyncio( | ||
*, | ||
client: Client, | ||
json_body: Settings, | ||
) -> Optional[Union[Error, Settings]]: | ||
"""modify the settings | ||
Args: | ||
json_body (Settings): instance settings that is configurable by the administrator. | ||
Raises: | ||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. | ||
httpx.TimeoutException: If the request takes longer than Client.timeout. | ||
Returns: | ||
Response[Union[Error, Settings]] | ||
""" | ||
|
||
return ( | ||
await asyncio_detailed( | ||
client=client, | ||
json_body=json_body, | ||
) | ||
).parsed |
Oops, something went wrong.