|
| 1 | +# This file was auto-generated by Fern from our API Definition. |
| 2 | + |
| 3 | +import os |
| 4 | +import typing |
| 5 | + |
| 6 | +import httpx |
| 7 | + |
| 8 | +from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 9 | +from .environment import SSOReadyEnvironment |
| 10 | +from .saml.client import AsyncSamlClient, SamlClient |
| 11 | + |
| 12 | + |
| 13 | +class SSOReady: |
| 14 | + """ |
| 15 | + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. |
| 16 | +
|
| 17 | + Parameters |
| 18 | + ---------- |
| 19 | + base_url : typing.Optional[str] |
| 20 | + The base url to use for requests from the client. |
| 21 | +
|
| 22 | + environment : SSOReadyEnvironment |
| 23 | + The environment to use for requests from the client. from .environment import SSOReadyEnvironment |
| 24 | +
|
| 25 | +
|
| 26 | +
|
| 27 | + Defaults to SSOReadyEnvironment.DEFAULT |
| 28 | +
|
| 29 | +
|
| 30 | +
|
| 31 | + api_key : typing.Optional[typing.Union[str, typing.Callable[[], str]]] |
| 32 | + timeout : typing.Optional[float] |
| 33 | + The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set. |
| 34 | +
|
| 35 | + follow_redirects : typing.Optional[bool] |
| 36 | + Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in. |
| 37 | +
|
| 38 | + httpx_client : typing.Optional[httpx.Client] |
| 39 | + The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. |
| 40 | +
|
| 41 | + Examples |
| 42 | + -------- |
| 43 | + from ssoready.client import SSOReady |
| 44 | +
|
| 45 | + client = SSOReady( |
| 46 | + api_key="YOUR_API_KEY", |
| 47 | + ) |
| 48 | + """ |
| 49 | + |
| 50 | + def __init__( |
| 51 | + self, |
| 52 | + *, |
| 53 | + base_url: typing.Optional[str] = None, |
| 54 | + environment: SSOReadyEnvironment = SSOReadyEnvironment.DEFAULT, |
| 55 | + api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("SSOREADY_API_KEY"), |
| 56 | + timeout: typing.Optional[float] = None, |
| 57 | + follow_redirects: typing.Optional[bool] = True, |
| 58 | + httpx_client: typing.Optional[httpx.Client] = None |
| 59 | + ): |
| 60 | + _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None |
| 61 | + self._client_wrapper = SyncClientWrapper( |
| 62 | + base_url=_get_base_url(base_url=base_url, environment=environment), |
| 63 | + api_key=api_key, |
| 64 | + httpx_client=httpx_client |
| 65 | + if httpx_client is not None |
| 66 | + else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects) |
| 67 | + if follow_redirects is not None |
| 68 | + else httpx.Client(timeout=_defaulted_timeout), |
| 69 | + timeout=_defaulted_timeout, |
| 70 | + ) |
| 71 | + self.saml = SamlClient(client_wrapper=self._client_wrapper) |
| 72 | + |
| 73 | + |
| 74 | +class AsyncSSOReady: |
| 75 | + """ |
| 76 | + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. |
| 77 | +
|
| 78 | + Parameters |
| 79 | + ---------- |
| 80 | + base_url : typing.Optional[str] |
| 81 | + The base url to use for requests from the client. |
| 82 | +
|
| 83 | + environment : SSOReadyEnvironment |
| 84 | + The environment to use for requests from the client. from .environment import SSOReadyEnvironment |
| 85 | +
|
| 86 | +
|
| 87 | +
|
| 88 | + Defaults to SSOReadyEnvironment.DEFAULT |
| 89 | +
|
| 90 | +
|
| 91 | +
|
| 92 | + api_key : typing.Optional[typing.Union[str, typing.Callable[[], str]]] |
| 93 | + timeout : typing.Optional[float] |
| 94 | + The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set. |
| 95 | +
|
| 96 | + follow_redirects : typing.Optional[bool] |
| 97 | + Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in. |
| 98 | +
|
| 99 | + httpx_client : typing.Optional[httpx.AsyncClient] |
| 100 | + The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. |
| 101 | +
|
| 102 | + Examples |
| 103 | + -------- |
| 104 | + from ssoready.client import AsyncSSOReady |
| 105 | +
|
| 106 | + client = AsyncSSOReady( |
| 107 | + api_key="YOUR_API_KEY", |
| 108 | + ) |
| 109 | + """ |
| 110 | + |
| 111 | + def __init__( |
| 112 | + self, |
| 113 | + *, |
| 114 | + base_url: typing.Optional[str] = None, |
| 115 | + environment: SSOReadyEnvironment = SSOReadyEnvironment.DEFAULT, |
| 116 | + api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("SSOREADY_API_KEY"), |
| 117 | + timeout: typing.Optional[float] = None, |
| 118 | + follow_redirects: typing.Optional[bool] = True, |
| 119 | + httpx_client: typing.Optional[httpx.AsyncClient] = None |
| 120 | + ): |
| 121 | + _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None |
| 122 | + self._client_wrapper = AsyncClientWrapper( |
| 123 | + base_url=_get_base_url(base_url=base_url, environment=environment), |
| 124 | + api_key=api_key, |
| 125 | + httpx_client=httpx_client |
| 126 | + if httpx_client is not None |
| 127 | + else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects) |
| 128 | + if follow_redirects is not None |
| 129 | + else httpx.AsyncClient(timeout=_defaulted_timeout), |
| 130 | + timeout=_defaulted_timeout, |
| 131 | + ) |
| 132 | + self.saml = AsyncSamlClient(client_wrapper=self._client_wrapper) |
| 133 | + |
| 134 | + |
| 135 | +def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SSOReadyEnvironment) -> str: |
| 136 | + if base_url is not None: |
| 137 | + return base_url |
| 138 | + elif environment is not None: |
| 139 | + return environment.value |
| 140 | + else: |
| 141 | + raise Exception("Please pass in either base_url or environment to construct the client") |
0 commit comments