adaline-api 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. adaline_api/__init__.py +193 -0
  2. adaline_api/api/__init__.py +5 -0
  3. adaline_api/api/default_api.py +1221 -0
  4. adaline_api/api_client.py +804 -0
  5. adaline_api/api_response.py +21 -0
  6. adaline_api/configuration.py +582 -0
  7. adaline_api/exceptions.py +216 -0
  8. adaline_api/models/__init__.py +89 -0
  9. adaline_api/models/api_message_content.py +113 -0
  10. adaline_api/models/api_message_content_type.py +113 -0
  11. adaline_api/models/base64_hosted_image_content_value.py +99 -0
  12. adaline_api/models/base64_hosted_image_content_value_type.py +99 -0
  13. adaline_api/models/base64_hosted_pdf_content_value.py +99 -0
  14. adaline_api/models/base64_hosted_pdf_content_value_type.py +99 -0
  15. adaline_api/models/base64_image_content_value.py +105 -0
  16. adaline_api/models/base64_image_content_value_type.py +105 -0
  17. adaline_api/models/base64_media.py +118 -0
  18. adaline_api/models/base64_media_type.py +118 -0
  19. adaline_api/models/base64_pdf_content_value.py +96 -0
  20. adaline_api/models/base64_pdf_content_value_type.py +96 -0
  21. adaline_api/models/base_entity.py +96 -0
  22. adaline_api/models/config_type.py +94 -0
  23. adaline_api/models/content.py +196 -0
  24. adaline_api/models/content_type.py +196 -0
  25. adaline_api/models/create_log_span_request.py +94 -0
  26. adaline_api/models/create_log_span_request_span.py +150 -0
  27. adaline_api/models/create_log_span_request_type.py +94 -0
  28. adaline_api/models/create_log_span_response.py +88 -0
  29. adaline_api/models/create_log_span_response_type.py +88 -0
  30. adaline_api/models/create_log_trace_request.py +104 -0
  31. adaline_api/models/create_log_trace_request_span.py +146 -0
  32. adaline_api/models/create_log_trace_request_trace.py +122 -0
  33. adaline_api/models/create_log_trace_request_type.py +104 -0
  34. adaline_api/models/create_log_trace_response.py +90 -0
  35. adaline_api/models/create_log_trace_response_type.py +90 -0
  36. adaline_api/models/deployment.py +107 -0
  37. adaline_api/models/deployment_prompt.py +121 -0
  38. adaline_api/models/deployment_prompt_config.py +94 -0
  39. adaline_api/models/deployment_prompt_config_type.py +94 -0
  40. adaline_api/models/deployment_prompt_type.py +121 -0
  41. adaline_api/models/deployment_prompt_variables.py +96 -0
  42. adaline_api/models/deployment_prompt_variables_type.py +96 -0
  43. adaline_api/models/deployment_type.py +107 -0
  44. adaline_api/models/deployment_type_prompt.py +121 -0
  45. adaline_api/models/enum_value.py +166 -0
  46. adaline_api/models/enum_value_type.py +166 -0
  47. adaline_api/models/error_response.py +91 -0
  48. adaline_api/models/error_response_type.py +91 -0
  49. adaline_api/models/function.py +101 -0
  50. adaline_api/models/function_parameter.py +139 -0
  51. adaline_api/models/function_parameter_type.py +139 -0
  52. adaline_api/models/function_parameters.py +115 -0
  53. adaline_api/models/function_parameters_type.py +115 -0
  54. adaline_api/models/function_request_http.py +121 -0
  55. adaline_api/models/function_request_http_type.py +121 -0
  56. adaline_api/models/function_request_retry.py +92 -0
  57. adaline_api/models/function_request_retry_type.py +92 -0
  58. adaline_api/models/function_tool.py +106 -0
  59. adaline_api/models/function_tool_definition.py +91 -0
  60. adaline_api/models/function_tool_definition_type.py +104 -0
  61. adaline_api/models/function_tool_type.py +106 -0
  62. adaline_api/models/function_tool_type_definition.py +91 -0
  63. adaline_api/models/function_type.py +106 -0
  64. adaline_api/models/image_content.py +109 -0
  65. adaline_api/models/image_content_type.py +109 -0
  66. adaline_api/models/image_content_value.py +140 -0
  67. adaline_api/models/image_content_value_type.py +140 -0
  68. adaline_api/models/image_message_content.py +111 -0
  69. adaline_api/models/image_message_content_type.py +111 -0
  70. adaline_api/models/image_message_content_type_value.py +154 -0
  71. adaline_api/models/image_message_content_value.py +154 -0
  72. adaline_api/models/image_source.py +140 -0
  73. adaline_api/models/image_source_type.py +140 -0
  74. adaline_api/models/log_attributes_value.py +160 -0
  75. adaline_api/models/log_feedback_comment.py +98 -0
  76. adaline_api/models/log_span.py +180 -0
  77. adaline_api/models/log_span_all_of_internal_feedback.py +98 -0
  78. adaline_api/models/log_span_content.py +224 -0
  79. adaline_api/models/log_span_embeddings_content.py +101 -0
  80. adaline_api/models/log_span_event.py +96 -0
  81. adaline_api/models/log_span_function_content.py +101 -0
  82. adaline_api/models/log_span_guardrail_content.py +101 -0
  83. adaline_api/models/log_span_model_content.py +109 -0
  84. adaline_api/models/log_span_model_stream_content.py +111 -0
  85. adaline_api/models/log_span_other_content.py +101 -0
  86. adaline_api/models/log_span_parsed_content.py +101 -0
  87. adaline_api/models/log_span_retrieval_content.py +101 -0
  88. adaline_api/models/log_span_tool_content.py +101 -0
  89. adaline_api/models/log_trace.py +132 -0
  90. adaline_api/models/log_trace_attributes_inner.py +102 -0
  91. adaline_api/models/log_trace_attributes_value.py +160 -0
  92. adaline_api/models/log_trace_attributes_value_type.py +160 -0
  93. adaline_api/models/log_trace_tags_inner.py +96 -0
  94. adaline_api/models/log_trace_type.py +132 -0
  95. adaline_api/models/log_trace_type_attributes_inner.py +102 -0
  96. adaline_api/models/log_trace_type_tags_inner.py +96 -0
  97. adaline_api/models/mcp_server.py +114 -0
  98. adaline_api/models/mcp_server_tool_configuration.py +90 -0
  99. adaline_api/models/mcp_server_tool_configuration_type.py +90 -0
  100. adaline_api/models/mcp_server_type.py +114 -0
  101. adaline_api/models/message.py +98 -0
  102. adaline_api/models/message_content_inner.py +182 -0
  103. adaline_api/models/message_content_type_inner.py +182 -0
  104. adaline_api/models/message_type.py +98 -0
  105. adaline_api/models/modality_enum.py +41 -0
  106. adaline_api/models/modality_enum_type.py +41 -0
  107. adaline_api/models/pdf_content.py +106 -0
  108. adaline_api/models/pdf_content_file.py +91 -0
  109. adaline_api/models/pdf_content_type.py +106 -0
  110. adaline_api/models/pdf_content_type_file.py +91 -0
  111. adaline_api/models/pdf_content_value.py +140 -0
  112. adaline_api/models/pdf_content_value_type.py +140 -0
  113. adaline_api/models/pdf_message_content.py +108 -0
  114. adaline_api/models/pdf_message_content_file.py +91 -0
  115. adaline_api/models/pdf_message_content_type.py +108 -0
  116. adaline_api/models/pdf_message_content_type_file.py +91 -0
  117. adaline_api/models/pdf_message_content_type_value.py +154 -0
  118. adaline_api/models/pdf_message_content_value.py +154 -0
  119. adaline_api/models/prompt_variable.py +96 -0
  120. adaline_api/models/prompt_variable_value.py +210 -0
  121. adaline_api/models/reasoning_content.py +100 -0
  122. adaline_api/models/reasoning_content_type.py +100 -0
  123. adaline_api/models/reasoning_content_value.py +98 -0
  124. adaline_api/models/reasoning_content_value_type.py +98 -0
  125. adaline_api/models/reasoning_content_value_union.py +140 -0
  126. adaline_api/models/reasoning_content_value_union_type.py +140 -0
  127. adaline_api/models/reasoning_message_content.py +102 -0
  128. adaline_api/models/reasoning_message_content_type.py +102 -0
  129. adaline_api/models/reasoning_message_content_type_value.py +140 -0
  130. adaline_api/models/reasoning_message_content_value.py +140 -0
  131. adaline_api/models/reasoning_redacted_value.py +109 -0
  132. adaline_api/models/reasoning_redacted_value_type.py +109 -0
  133. adaline_api/models/reasoning_thinking_value.py +111 -0
  134. adaline_api/models/reasoning_thinking_value_type.py +111 -0
  135. adaline_api/models/reasoning_value.py +140 -0
  136. adaline_api/models/reasoning_value_type.py +140 -0
  137. adaline_api/models/redacted_reasoning_content_value.py +96 -0
  138. adaline_api/models/redacted_reasoning_content_value_type.py +96 -0
  139. adaline_api/models/response_schema.py +105 -0
  140. adaline_api/models/response_schema_property.py +135 -0
  141. adaline_api/models/response_schema_property_enum_inner.py +166 -0
  142. adaline_api/models/response_schema_property_type.py +143 -0
  143. adaline_api/models/response_schema_property_type_enum_inner.py +166 -0
  144. adaline_api/models/response_schema_property_type_type.py +143 -0
  145. adaline_api/models/response_schema_structure.py +122 -0
  146. adaline_api/models/response_schema_structure_type.py +122 -0
  147. adaline_api/models/response_schema_type.py +105 -0
  148. adaline_api/models/role_enum.py +39 -0
  149. adaline_api/models/role_enum_type.py +39 -0
  150. adaline_api/models/span_content_detailed.py +112 -0
  151. adaline_api/models/span_content_detailed_type.py +112 -0
  152. adaline_api/models/span_content_detailed_type_variables_value.py +94 -0
  153. adaline_api/models/span_content_detailed_variables_value.py +94 -0
  154. adaline_api/models/span_content_minimal.py +91 -0
  155. adaline_api/models/span_content_minimal_type.py +91 -0
  156. adaline_api/models/span_log_req_attributes.py +160 -0
  157. adaline_api/models/span_log_req_attributes_type.py +160 -0
  158. adaline_api/models/span_log_req_content.py +137 -0
  159. adaline_api/models/span_log_req_content_type.py +137 -0
  160. adaline_api/models/span_log_request.py +93 -0
  161. adaline_api/models/span_log_request_span.py +139 -0
  162. adaline_api/models/span_log_request_type.py +93 -0
  163. adaline_api/models/span_log_request_type_span.py +139 -0
  164. adaline_api/models/span_log_response.py +87 -0
  165. adaline_api/models/span_log_response_type.py +87 -0
  166. adaline_api/models/spans_request_attribute_value.py +160 -0
  167. adaline_api/models/spans_request_attribute_value_type.py +160 -0
  168. adaline_api/models/spans_request_content_value.py +143 -0
  169. adaline_api/models/spans_request_content_value_type.py +143 -0
  170. adaline_api/models/text_content.py +96 -0
  171. adaline_api/models/text_content_type.py +96 -0
  172. adaline_api/models/text_message_content.py +98 -0
  173. adaline_api/models/text_message_content_type.py +98 -0
  174. adaline_api/models/tool_call_content.py +105 -0
  175. adaline_api/models/tool_call_content_type.py +105 -0
  176. adaline_api/models/tool_call_message_content.py +107 -0
  177. adaline_api/models/tool_call_message_content_type.py +107 -0
  178. adaline_api/models/tool_response_content.py +109 -0
  179. adaline_api/models/tool_response_content_api_response.py +88 -0
  180. adaline_api/models/tool_response_content_type.py +109 -0
  181. adaline_api/models/tool_response_content_type_api_response.py +88 -0
  182. adaline_api/models/tool_response_message_content.py +111 -0
  183. adaline_api/models/tool_response_message_content_api_response.py +87 -0
  184. adaline_api/models/tool_response_message_content_type.py +111 -0
  185. adaline_api/models/tool_response_message_content_type_api_response.py +87 -0
  186. adaline_api/models/tool_type.py +113 -0
  187. adaline_api/models/trace_log_patch_request.py +137 -0
  188. adaline_api/models/trace_log_patch_request_one_of.py +97 -0
  189. adaline_api/models/trace_log_patch_request_one_of1.py +97 -0
  190. adaline_api/models/trace_log_patch_request_type.py +137 -0
  191. adaline_api/models/trace_log_patch_request_type_one_of.py +97 -0
  192. adaline_api/models/trace_log_patch_request_type_one_of1.py +97 -0
  193. adaline_api/models/trace_log_patch_response.py +87 -0
  194. adaline_api/models/trace_log_patch_response_type.py +87 -0
  195. adaline_api/models/trace_log_request.py +103 -0
  196. adaline_api/models/trace_log_request_spans_inner.py +135 -0
  197. adaline_api/models/trace_log_request_trace.py +121 -0
  198. adaline_api/models/trace_log_request_type.py +103 -0
  199. adaline_api/models/trace_log_request_type_spans_inner.py +135 -0
  200. adaline_api/models/trace_log_request_type_trace.py +121 -0
  201. adaline_api/models/trace_log_response.py +89 -0
  202. adaline_api/models/trace_log_response_type.py +89 -0
  203. adaline_api/models/trace_request_attribute_value.py +160 -0
  204. adaline_api/models/trace_request_attribute_value_type.py +160 -0
  205. adaline_api/models/update_log_trace_request.py +98 -0
  206. adaline_api/models/update_log_trace_request_attribute_item.py +140 -0
  207. adaline_api/models/update_log_trace_request_attribute_item_one_of.py +102 -0
  208. adaline_api/models/update_log_trace_request_attribute_item_one_of1.py +96 -0
  209. adaline_api/models/update_log_trace_request_attribute_item_one_of_value.py +160 -0
  210. adaline_api/models/update_log_trace_request_tag_item.py +140 -0
  211. adaline_api/models/update_log_trace_request_tag_item_one_of.py +97 -0
  212. adaline_api/models/update_log_trace_request_tag_item_one_of1.py +97 -0
  213. adaline_api/models/update_log_trace_request_trace.py +120 -0
  214. adaline_api/models/update_log_trace_request_type.py +98 -0
  215. adaline_api/models/update_log_trace_response.py +87 -0
  216. adaline_api/models/update_log_trace_response_type.py +87 -0
  217. adaline_api/models/url_image_content_value.py +96 -0
  218. adaline_api/models/url_image_content_value_type.py +96 -0
  219. adaline_api/models/url_media.py +109 -0
  220. adaline_api/models/url_media_type.py +109 -0
  221. adaline_api/models/url_pdf_content_value.py +96 -0
  222. adaline_api/models/url_pdf_content_value_type.py +96 -0
  223. adaline_api/models/variable.py +96 -0
  224. adaline_api/models/variable_type.py +96 -0
  225. adaline_api/models/variable_type_value.py +196 -0
  226. adaline_api/models/variable_value.py +196 -0
  227. adaline_api/models/variables_type.py +96 -0
  228. adaline_api/py.typed +0 -0
  229. adaline_api/rest.py +213 -0
  230. adaline_api-1.0.0.dist-info/METADATA +227 -0
  231. adaline_api-1.0.0.dist-info/RECORD +233 -0
  232. adaline_api-1.0.0.dist-info/WHEEL +5 -0
  233. adaline_api-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,582 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Adaline API
5
+
6
+ API for managing Adaline deployments, logs, and core type definitions.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ import copy
16
+ import http.client as httplib
17
+ import logging
18
+ from logging import FileHandler
19
+ import sys
20
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
21
+ from typing_extensions import NotRequired, Self
22
+
23
+ import urllib3
24
+
25
+
26
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
27
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
28
+ 'minimum', 'exclusiveMinimum', 'maxLength',
29
+ 'minLength', 'pattern', 'maxItems', 'minItems'
30
+ }
31
+
32
+ ServerVariablesT = Dict[str, str]
33
+
34
+ GenericAuthSetting = TypedDict(
35
+ "GenericAuthSetting",
36
+ {
37
+ "type": str,
38
+ "in": str,
39
+ "key": str,
40
+ "value": str,
41
+ },
42
+ )
43
+
44
+
45
+ OAuth2AuthSetting = TypedDict(
46
+ "OAuth2AuthSetting",
47
+ {
48
+ "type": Literal["oauth2"],
49
+ "in": Literal["header"],
50
+ "key": Literal["Authorization"],
51
+ "value": str,
52
+ },
53
+ )
54
+
55
+
56
+ APIKeyAuthSetting = TypedDict(
57
+ "APIKeyAuthSetting",
58
+ {
59
+ "type": Literal["api_key"],
60
+ "in": str,
61
+ "key": str,
62
+ "value": Optional[str],
63
+ },
64
+ )
65
+
66
+
67
+ BasicAuthSetting = TypedDict(
68
+ "BasicAuthSetting",
69
+ {
70
+ "type": Literal["basic"],
71
+ "in": Literal["header"],
72
+ "key": Literal["Authorization"],
73
+ "value": Optional[str],
74
+ },
75
+ )
76
+
77
+
78
+ BearerFormatAuthSetting = TypedDict(
79
+ "BearerFormatAuthSetting",
80
+ {
81
+ "type": Literal["bearer"],
82
+ "in": Literal["header"],
83
+ "format": Literal["JWT"],
84
+ "key": Literal["Authorization"],
85
+ "value": str,
86
+ },
87
+ )
88
+
89
+
90
+ BearerAuthSetting = TypedDict(
91
+ "BearerAuthSetting",
92
+ {
93
+ "type": Literal["bearer"],
94
+ "in": Literal["header"],
95
+ "key": Literal["Authorization"],
96
+ "value": str,
97
+ },
98
+ )
99
+
100
+
101
+ HTTPSignatureAuthSetting = TypedDict(
102
+ "HTTPSignatureAuthSetting",
103
+ {
104
+ "type": Literal["http-signature"],
105
+ "in": Literal["header"],
106
+ "key": Literal["Authorization"],
107
+ "value": None,
108
+ },
109
+ )
110
+
111
+
112
+ AuthSettings = TypedDict(
113
+ "AuthSettings",
114
+ {
115
+ "bearerAuth": BearerFormatAuthSetting,
116
+ },
117
+ total=False,
118
+ )
119
+
120
+
121
+ class HostSettingVariable(TypedDict):
122
+ description: str
123
+ default_value: str
124
+ enum_values: List[str]
125
+
126
+
127
+ class HostSetting(TypedDict):
128
+ url: str
129
+ description: str
130
+ variables: NotRequired[Dict[str, HostSettingVariable]]
131
+
132
+
133
+ class Configuration:
134
+ """This class contains various settings of the API client.
135
+
136
+ :param host: Base url.
137
+ :param ignore_operation_servers
138
+ Boolean to ignore operation servers for the API client.
139
+ Config will use `host` as the base url regardless of the operation servers.
140
+ :param api_key: Dict to store API key(s).
141
+ Each entry in the dict specifies an API key.
142
+ The dict key is the name of the security scheme in the OAS specification.
143
+ The dict value is the API key secret.
144
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
145
+ The dict key is the name of the security scheme in the OAS specification.
146
+ The dict value is an API key prefix when generating the auth data.
147
+ :param username: Username for HTTP basic authentication.
148
+ :param password: Password for HTTP basic authentication.
149
+ :param access_token: Access token.
150
+ :param server_index: Index to servers configuration.
151
+ :param server_variables: Mapping with string values to replace variables in
152
+ templated server configuration. The validation of enums is performed for
153
+ variables with defined enum values before.
154
+ :param server_operation_index: Mapping from operation ID to an index to server
155
+ configuration.
156
+ :param server_operation_variables: Mapping from operation ID to a mapping with
157
+ string values to replace variables in templated server configuration.
158
+ The validation of enums is performed for variables with defined enum
159
+ values before.
160
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
161
+ in PEM format.
162
+ :param retries: Number of retries for API requests.
163
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
164
+ in PEM (str) or DER (bytes) format.
165
+
166
+ :Example:
167
+ """
168
+
169
+ _default: ClassVar[Optional[Self]] = None
170
+
171
+ def __init__(
172
+ self,
173
+ host: Optional[str]=None,
174
+ api_key: Optional[Dict[str, str]]=None,
175
+ api_key_prefix: Optional[Dict[str, str]]=None,
176
+ username: Optional[str]=None,
177
+ password: Optional[str]=None,
178
+ access_token: Optional[str]=None,
179
+ server_index: Optional[int]=None,
180
+ server_variables: Optional[ServerVariablesT]=None,
181
+ server_operation_index: Optional[Dict[int, int]]=None,
182
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
183
+ ignore_operation_servers: bool=False,
184
+ ssl_ca_cert: Optional[str]=None,
185
+ retries: Optional[int] = None,
186
+ ca_cert_data: Optional[Union[str, bytes]] = None,
187
+ *,
188
+ debug: Optional[bool] = None,
189
+ ) -> None:
190
+ """Constructor
191
+ """
192
+ self._base_path = "https://api.adaline.ai/v2" if host is None else host
193
+ """Default Base url
194
+ """
195
+ self.server_index = 0 if server_index is None and host is None else server_index
196
+ self.server_operation_index = server_operation_index or {}
197
+ """Default server index
198
+ """
199
+ self.server_variables = server_variables or {}
200
+ self.server_operation_variables = server_operation_variables or {}
201
+ """Default server variables
202
+ """
203
+ self.ignore_operation_servers = ignore_operation_servers
204
+ """Ignore operation servers
205
+ """
206
+ self.temp_folder_path = None
207
+ """Temp file folder for downloading files
208
+ """
209
+ # Authentication Settings
210
+ self.api_key = {}
211
+ if api_key:
212
+ self.api_key = api_key
213
+ """dict to store API key(s)
214
+ """
215
+ self.api_key_prefix = {}
216
+ if api_key_prefix:
217
+ self.api_key_prefix = api_key_prefix
218
+ """dict to store API prefix (e.g. Bearer)
219
+ """
220
+ self.refresh_api_key_hook = None
221
+ """function hook to refresh API key if expired
222
+ """
223
+ self.username = username
224
+ """Username for HTTP basic authentication
225
+ """
226
+ self.password = password
227
+ """Password for HTTP basic authentication
228
+ """
229
+ self.access_token = access_token
230
+ """Access token
231
+ """
232
+ self.logger = {}
233
+ """Logging Settings
234
+ """
235
+ self.logger["package_logger"] = logging.getLogger("adaline_api")
236
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
237
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
238
+ """Log format
239
+ """
240
+ self.logger_stream_handler = None
241
+ """Log stream handler
242
+ """
243
+ self.logger_file_handler: Optional[FileHandler] = None
244
+ """Log file handler
245
+ """
246
+ self.logger_file = None
247
+ """Debug file location
248
+ """
249
+ if debug is not None:
250
+ self.debug = debug
251
+ else:
252
+ self.__debug = False
253
+ """Debug switch
254
+ """
255
+
256
+ self.verify_ssl = True
257
+ """SSL/TLS verification
258
+ Set this to false to skip verifying SSL certificate when calling API
259
+ from https server.
260
+ """
261
+ self.ssl_ca_cert = ssl_ca_cert
262
+ """Set this to customize the certificate file to verify the peer.
263
+ """
264
+ self.ca_cert_data = ca_cert_data
265
+ """Set this to verify the peer using PEM (str) or DER (bytes)
266
+ certificate data.
267
+ """
268
+ self.cert_file = None
269
+ """client certificate file
270
+ """
271
+ self.key_file = None
272
+ """client key file
273
+ """
274
+ self.assert_hostname = None
275
+ """Set this to True/False to enable/disable SSL hostname verification.
276
+ """
277
+ self.tls_server_name = None
278
+ """SSL/TLS Server Name Indication (SNI)
279
+ Set this to the SNI value expected by the server.
280
+ """
281
+
282
+ self.connection_pool_maxsize = 100
283
+ """This value is passed to the aiohttp to limit simultaneous connections.
284
+ Default values is 100, None means no-limit.
285
+ """
286
+
287
+ self.proxy: Optional[str] = None
288
+ """Proxy URL
289
+ """
290
+ self.proxy_headers = None
291
+ """Proxy headers
292
+ """
293
+ self.safe_chars_for_path_param = ''
294
+ """Safe chars for path_param
295
+ """
296
+ self.retries = retries
297
+ """Adding retries to override urllib3 default value 3
298
+ """
299
+ # Enable client side validation
300
+ self.client_side_validation = True
301
+
302
+ self.socket_options = None
303
+ """Options to pass down to the underlying urllib3 socket
304
+ """
305
+
306
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
307
+ """datetime format
308
+ """
309
+
310
+ self.date_format = "%Y-%m-%d"
311
+ """date format
312
+ """
313
+
314
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
315
+ cls = self.__class__
316
+ result = cls.__new__(cls)
317
+ memo[id(self)] = result
318
+ for k, v in self.__dict__.items():
319
+ if k not in ('logger', 'logger_file_handler'):
320
+ setattr(result, k, copy.deepcopy(v, memo))
321
+ # shallow copy of loggers
322
+ result.logger = copy.copy(self.logger)
323
+ # use setters to configure loggers
324
+ result.logger_file = self.logger_file
325
+ result.debug = self.debug
326
+ return result
327
+
328
+ def __setattr__(self, name: str, value: Any) -> None:
329
+ object.__setattr__(self, name, value)
330
+
331
+ @classmethod
332
+ def set_default(cls, default: Optional[Self]) -> None:
333
+ """Set default instance of configuration.
334
+
335
+ It stores default configuration, which can be
336
+ returned by get_default_copy method.
337
+
338
+ :param default: object of Configuration
339
+ """
340
+ cls._default = default
341
+
342
+ @classmethod
343
+ def get_default_copy(cls) -> Self:
344
+ """Deprecated. Please use `get_default` instead.
345
+
346
+ Deprecated. Please use `get_default` instead.
347
+
348
+ :return: The configuration object.
349
+ """
350
+ return cls.get_default()
351
+
352
+ @classmethod
353
+ def get_default(cls) -> Self:
354
+ """Return the default configuration.
355
+
356
+ This method returns newly created, based on default constructor,
357
+ object of Configuration class or returns a copy of default
358
+ configuration.
359
+
360
+ :return: The configuration object.
361
+ """
362
+ if cls._default is None:
363
+ cls._default = cls()
364
+ return cls._default
365
+
366
+ @property
367
+ def logger_file(self) -> Optional[str]:
368
+ """The logger file.
369
+
370
+ If the logger_file is None, then add stream handler and remove file
371
+ handler. Otherwise, add file handler and remove stream handler.
372
+
373
+ :param value: The logger_file path.
374
+ :type: str
375
+ """
376
+ return self.__logger_file
377
+
378
+ @logger_file.setter
379
+ def logger_file(self, value: Optional[str]) -> None:
380
+ """The logger file.
381
+
382
+ If the logger_file is None, then add stream handler and remove file
383
+ handler. Otherwise, add file handler and remove stream handler.
384
+
385
+ :param value: The logger_file path.
386
+ :type: str
387
+ """
388
+ self.__logger_file = value
389
+ if self.__logger_file:
390
+ # If set logging file,
391
+ # then add file handler and remove stream handler.
392
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
393
+ self.logger_file_handler.setFormatter(self.logger_formatter)
394
+ for _, logger in self.logger.items():
395
+ logger.addHandler(self.logger_file_handler)
396
+
397
+ @property
398
+ def debug(self) -> bool:
399
+ """Debug status
400
+
401
+ :param value: The debug status, True or False.
402
+ :type: bool
403
+ """
404
+ return self.__debug
405
+
406
+ @debug.setter
407
+ def debug(self, value: bool) -> None:
408
+ """Debug status
409
+
410
+ :param value: The debug status, True or False.
411
+ :type: bool
412
+ """
413
+ self.__debug = value
414
+ if self.__debug:
415
+ # if debug status is True, turn on debug logging
416
+ for _, logger in self.logger.items():
417
+ logger.setLevel(logging.DEBUG)
418
+ # turn on httplib debug
419
+ httplib.HTTPConnection.debuglevel = 1
420
+ else:
421
+ # if debug status is False, turn off debug logging,
422
+ # setting log level to default `logging.WARNING`
423
+ for _, logger in self.logger.items():
424
+ logger.setLevel(logging.WARNING)
425
+ # turn off httplib debug
426
+ httplib.HTTPConnection.debuglevel = 0
427
+
428
+ @property
429
+ def logger_format(self) -> str:
430
+ """The logger format.
431
+
432
+ The logger_formatter will be updated when sets logger_format.
433
+
434
+ :param value: The format string.
435
+ :type: str
436
+ """
437
+ return self.__logger_format
438
+
439
+ @logger_format.setter
440
+ def logger_format(self, value: str) -> None:
441
+ """The logger format.
442
+
443
+ The logger_formatter will be updated when sets logger_format.
444
+
445
+ :param value: The format string.
446
+ :type: str
447
+ """
448
+ self.__logger_format = value
449
+ self.logger_formatter = logging.Formatter(self.__logger_format)
450
+
451
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
452
+ """Gets API key (with prefix if set).
453
+
454
+ :param identifier: The identifier of apiKey.
455
+ :param alias: The alternative identifier of apiKey.
456
+ :return: The token for api key authentication.
457
+ """
458
+ if self.refresh_api_key_hook is not None:
459
+ self.refresh_api_key_hook(self)
460
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
461
+ if key:
462
+ prefix = self.api_key_prefix.get(identifier)
463
+ if prefix:
464
+ return "%s %s" % (prefix, key)
465
+ else:
466
+ return key
467
+
468
+ return None
469
+
470
+ def get_basic_auth_token(self) -> Optional[str]:
471
+ """Gets HTTP basic authentication header (string).
472
+
473
+ :return: The token for basic HTTP authentication.
474
+ """
475
+ username = ""
476
+ if self.username is not None:
477
+ username = self.username
478
+ password = ""
479
+ if self.password is not None:
480
+ password = self.password
481
+ return urllib3.util.make_headers(
482
+ basic_auth=username + ':' + password
483
+ ).get('authorization')
484
+
485
+ def auth_settings(self)-> AuthSettings:
486
+ """Gets Auth Settings dict for api client.
487
+
488
+ :return: The Auth Settings information dict.
489
+ """
490
+ auth: AuthSettings = {}
491
+ if self.access_token is not None:
492
+ auth['bearerAuth'] = {
493
+ 'type': 'bearer',
494
+ 'in': 'header',
495
+ 'format': 'JWT',
496
+ 'key': 'Authorization',
497
+ 'value': 'Bearer ' + self.access_token
498
+ }
499
+ return auth
500
+
501
+ def to_debug_report(self) -> str:
502
+ """Gets the essential information for debugging.
503
+
504
+ :return: The report for debugging.
505
+ """
506
+ return "Python SDK Debug Report:\n"\
507
+ "OS: {env}\n"\
508
+ "Python Version: {pyversion}\n"\
509
+ "Version of the API: 1.0.0\n"\
510
+ "SDK Package Version: 1.0.0".\
511
+ format(env=sys.platform, pyversion=sys.version)
512
+
513
+ def get_host_settings(self) -> List[HostSetting]:
514
+ """Gets an array of host settings
515
+
516
+ :return: An array of host settings
517
+ """
518
+ return [
519
+ {
520
+ 'url': "https://api.adaline.ai/v2",
521
+ 'description': "Production API",
522
+ },
523
+ {
524
+ 'url': "https://api.staging.adaline.ai/v2",
525
+ 'description': "Staging API",
526
+ }
527
+ ]
528
+
529
+ def get_host_from_settings(
530
+ self,
531
+ index: Optional[int],
532
+ variables: Optional[ServerVariablesT]=None,
533
+ servers: Optional[List[HostSetting]]=None,
534
+ ) -> str:
535
+ """Gets host URL based on the index and variables
536
+ :param index: array index of the host settings
537
+ :param variables: hash of variable and the corresponding value
538
+ :param servers: an array of host settings or None
539
+ :return: URL based on host settings
540
+ """
541
+ if index is None:
542
+ return self._base_path
543
+
544
+ variables = {} if variables is None else variables
545
+ servers = self.get_host_settings() if servers is None else servers
546
+
547
+ try:
548
+ server = servers[index]
549
+ except IndexError:
550
+ raise ValueError(
551
+ "Invalid index {0} when selecting the host settings. "
552
+ "Must be less than {1}".format(index, len(servers)))
553
+
554
+ url = server['url']
555
+
556
+ # go through variables and replace placeholders
557
+ for variable_name, variable in server.get('variables', {}).items():
558
+ used_value = variables.get(
559
+ variable_name, variable['default_value'])
560
+
561
+ if 'enum_values' in variable \
562
+ and used_value not in variable['enum_values']:
563
+ raise ValueError(
564
+ "The variable `{0}` in the host URL has invalid value "
565
+ "{1}. Must be {2}.".format(
566
+ variable_name, variables[variable_name],
567
+ variable['enum_values']))
568
+
569
+ url = url.replace("{" + variable_name + "}", used_value)
570
+
571
+ return url
572
+
573
+ @property
574
+ def host(self) -> str:
575
+ """Return generated host."""
576
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
577
+
578
+ @host.setter
579
+ def host(self, value: str) -> None:
580
+ """Fix base path."""
581
+ self._base_path = value
582
+ self.server_index = None