-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsdkconfiguration.py
60 lines (50 loc) · 1.91 KB
/
sdkconfiguration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from ._hooks import SDKHooks
from ._version import (
__gen_version__,
__openapi_doc_version__,
__user_agent__,
__version__,
)
from .httpclient import AsyncHttpClient, HttpClient
from .utils import Logger, RetryConfig, remove_suffix
from dataclasses import dataclass
from pydantic import Field
from typing import Callable, Dict, Optional, Tuple, Union
from unstructured_client.models import shared
from unstructured_client.types import OptionalNullable, UNSET
SERVER_PLATFORM_API = "platform-api"
r"""Unstructured Platform API"""
SERVERS = {
SERVER_PLATFORM_API: "https://platform.unstructuredapp.io/",
}
"""Contains the list of servers available to the SDK"""
@dataclass
class SDKConfiguration:
client: Union[HttpClient, None]
client_supplied: bool
async_client: Union[AsyncHttpClient, None]
async_client_supplied: bool
debug_logger: Logger
security: Optional[Union[shared.Security, Callable[[], shared.Security]]] = None
server_url: Optional[str] = ""
server: Optional[str] = ""
language: str = "python"
openapi_doc_version: str = __openapi_doc_version__
sdk_version: str = __version__
gen_version: str = __gen_version__
user_agent: str = __user_agent__
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
timeout_ms: Optional[int] = None
def __post_init__(self):
self._hooks = SDKHooks()
def get_server_details(self) -> Tuple[str, Dict[str, str]]:
if self.server_url is not None and self.server_url:
return remove_suffix(self.server_url, "/"), {}
if not self.server:
self.server = SERVER_PLATFORM_API
if self.server not in SERVERS:
raise ValueError(f'Invalid server "{self.server}"')
return SERVERS[self.server], {}
def get_hooks(self) -> SDKHooks:
return self._hooks