-
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
215 changed files
with
8,296 additions
and
5,581 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 @@ | ||
1543c5968e0e568095cb5eeb44a3c7ab3179d6491f270932e268ab579c8d5948 | ||
dcb50c2cb9eac6743b41006a2e73a209bea8c9697c526f31a608a0aa602ec4de |
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,162 @@ | ||
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.instance_configuration import InstanceConfiguration | ||
from ...types import Response | ||
|
||
|
||
def _get_kwargs( | ||
*, | ||
client: Client, | ||
) -> Dict[str, Any]: | ||
url = "{}/config".format(client.base_url) | ||
|
||
headers: Dict[str, str] = client.get_headers() | ||
cookies: Dict[str, Any] = client.get_cookies() | ||
|
||
# Set the proxies if the client has proxies set. | ||
proxies = None | ||
if hasattr(client, "proxies") and client.proxies is not None: | ||
https_proxy = client.proxies.get("https") | ||
if https_proxy: | ||
proxies = https_proxy | ||
else: | ||
http_proxy = client.proxies.get("http") | ||
if http_proxy: | ||
proxies = http_proxy | ||
|
||
return { | ||
"method": "get", | ||
"url": url, | ||
"headers": headers, | ||
"cookies": cookies, | ||
"timeout": client.get_timeout(), | ||
"proxies": proxies, | ||
} | ||
|
||
|
||
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[Error, InstanceConfiguration]]: | ||
if response.status_code == HTTPStatus.OK: | ||
response_200 = InstanceConfiguration.from_dict(response.json()) | ||
|
||
return response_200 | ||
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, InstanceConfiguration]]: | ||
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, InstanceConfiguration]]: | ||
"""get information about the instance's configuration (requires administrative privileges) | ||
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, InstanceConfiguration]] | ||
""" | ||
|
||
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, InstanceConfiguration]]: | ||
"""get information about the instance's configuration (requires administrative privileges) | ||
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, InstanceConfiguration]] | ||
""" | ||
|
||
return sync_detailed( | ||
client=client, | ||
).parsed | ||
|
||
|
||
async def asyncio_detailed( | ||
*, | ||
client: Client, | ||
) -> Response[Union[Error, InstanceConfiguration]]: | ||
"""get information about the instance's configuration (requires administrative privileges) | ||
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, InstanceConfiguration]] | ||
""" | ||
|
||
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, InstanceConfiguration]]: | ||
"""get information about the instance's configuration (requires administrative privileges) | ||
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, InstanceConfiguration]] | ||
""" | ||
|
||
return ( | ||
await asyncio_detailed( | ||
client=client, | ||
) | ||
).parsed |
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
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
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.