pingram-python 0.1.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 (189) hide show
  1. pingram/__init__.py +395 -0
  2. pingram/api/__init__.py +21 -0
  3. pingram/api/account_api.py +2198 -0
  4. pingram/api/addresses_api.py +860 -0
  5. pingram/api/components_api.py +1681 -0
  6. pingram/api/default_api.py +320 -0
  7. pingram/api/domains_api.py +849 -0
  8. pingram/api/editor_api.py +320 -0
  9. pingram/api/environments_api.py +878 -0
  10. pingram/api/health_api.py +287 -0
  11. pingram/api/insights_api.py +321 -0
  12. pingram/api/keys_api.py +849 -0
  13. pingram/api/logs_api.py +1632 -0
  14. pingram/api/members_api.py +1780 -0
  15. pingram/api/sender_api.py +892 -0
  16. pingram/api/templates_api.py +1889 -0
  17. pingram/api/types_api.py +1411 -0
  18. pingram/api/user_api.py +2534 -0
  19. pingram/api/users_api.py +936 -0
  20. pingram/api_client.py +807 -0
  21. pingram/api_response.py +21 -0
  22. pingram/client_wrapper.py +357 -0
  23. pingram/configuration.py +623 -0
  24. pingram/exceptions.py +219 -0
  25. pingram/models/__init__.py +173 -0
  26. pingram/models/account_addresses_response.py +95 -0
  27. pingram/models/account_addresses_response_addresses_inner.py +104 -0
  28. pingram/models/account_get_response.py +143 -0
  29. pingram/models/account_get_response_pending_downgrade_usage_limit.py +99 -0
  30. pingram/models/address_response.py +91 -0
  31. pingram/models/auto_join_get_response.py +89 -0
  32. pingram/models/auto_join_post_response.py +89 -0
  33. pingram/models/auto_join_request_body.py +87 -0
  34. pingram/models/bee_token_v2.py +89 -0
  35. pingram/models/billing_post_request_body.py +91 -0
  36. pingram/models/billing_post_response_body.py +149 -0
  37. pingram/models/billing_post_response_body_pending_downgrade_usage_limit.py +99 -0
  38. pingram/models/channels_enum.py +42 -0
  39. pingram/models/create_account_request_body.py +87 -0
  40. pingram/models/create_account_response.py +89 -0
  41. pingram/models/create_address_request.py +91 -0
  42. pingram/models/create_key_request.py +98 -0
  43. pingram/models/create_key_response.py +104 -0
  44. pingram/models/delete_key_response.py +87 -0
  45. pingram/models/delete_user_response.py +87 -0
  46. pingram/models/email_auth_token_post_request.py +87 -0
  47. pingram/models/email_component_patch_request.py +93 -0
  48. pingram/models/email_component_post_request.py +95 -0
  49. pingram/models/email_component_response.py +120 -0
  50. pingram/models/email_component_response_referenced_by_inner.py +92 -0
  51. pingram/models/environment.py +96 -0
  52. pingram/models/environment_create_request.py +87 -0
  53. pingram/models/environment_patch_request.py +94 -0
  54. pingram/models/get_account_metadata_response.py +91 -0
  55. pingram/models/get_account_metadata_response_user_account_metadata.py +91 -0
  56. pingram/models/get_email_components_response_inner.py +120 -0
  57. pingram/models/get_environments_response_inner.py +96 -0
  58. pingram/models/get_inapp_notifications_response.py +95 -0
  59. pingram/models/get_inapp_notifications_response_notifications_inner.py +137 -0
  60. pingram/models/get_inapp_notifications_response_notifications_inner_delivery_options.py +106 -0
  61. pingram/models/get_inapp_notifications_response_notifications_inner_delivery_options_instant.py +93 -0
  62. pingram/models/get_inapp_notifications_response_notifications_inner_delivery_options_off.py +87 -0
  63. pingram/models/get_inapp_notifications_response_notifications_inner_replies_inner.py +89 -0
  64. pingram/models/get_inapp_notifications_response_notifications_inner_template.py +136 -0
  65. pingram/models/get_inapp_notifications_response_notifications_inner_template_any_of.py +98 -0
  66. pingram/models/get_keys_response.py +95 -0
  67. pingram/models/get_keys_response_keys_inner.py +110 -0
  68. pingram/models/get_logs_response.py +97 -0
  69. pingram/models/get_logs_response_messages_inner.py +141 -0
  70. pingram/models/get_logs_response_messages_inner_attachments_inner.py +93 -0
  71. pingram/models/get_members_response_inner.py +95 -0
  72. pingram/models/get_metrics_response_inner.py +116 -0
  73. pingram/models/get_metrics_response_inner_messages_inner.py +89 -0
  74. pingram/models/get_notifications_response_inner.py +126 -0
  75. pingram/models/get_notifications_response_inner_deduplication.py +87 -0
  76. pingram/models/get_notifications_response_inner_options.py +122 -0
  77. pingram/models/get_notifications_response_inner_options_email.py +128 -0
  78. pingram/models/get_notifications_response_inner_options_email_daily.py +89 -0
  79. pingram/models/get_notifications_response_inner_options_email_monthly.py +101 -0
  80. pingram/models/get_notifications_response_inner_options_email_weekly.py +91 -0
  81. pingram/models/get_notifications_response_inner_templates_inner.py +90 -0
  82. pingram/models/get_notifications_response_inner_throttling.py +111 -0
  83. pingram/models/get_senders_response_inner.py +128 -0
  84. pingram/models/get_templates_response.py +136 -0
  85. pingram/models/get_users_response.py +99 -0
  86. pingram/models/get_users_response_users_inner.py +133 -0
  87. pingram/models/get_users_response_users_inner_email_suppression_status.py +96 -0
  88. pingram/models/get_users_response_users_inner_push_tokens_inner.py +104 -0
  89. pingram/models/get_users_response_users_inner_push_tokens_inner_device.py +97 -0
  90. pingram/models/get_users_response_users_inner_slack_token.py +140 -0
  91. pingram/models/get_users_response_users_inner_slack_token_authed_user.py +97 -0
  92. pingram/models/get_users_response_users_inner_slack_token_enterprise.py +89 -0
  93. pingram/models/get_users_response_users_inner_slack_token_incoming_webhook.py +93 -0
  94. pingram/models/get_users_response_users_inner_slack_token_response_metadata.py +97 -0
  95. pingram/models/get_users_response_users_inner_web_push_tokens_inner.py +91 -0
  96. pingram/models/get_users_response_users_inner_web_push_tokens_inner_sub.py +93 -0
  97. pingram/models/get_users_response_users_inner_web_push_tokens_inner_sub_keys.py +89 -0
  98. pingram/models/in_app_notification_patch_request.py +112 -0
  99. pingram/models/in_app_notification_unread_clear_request.py +89 -0
  100. pingram/models/inapp_unread_count_response.py +87 -0
  101. pingram/models/inbound_request_body.py +138 -0
  102. pingram/models/inbound_response_body.py +104 -0
  103. pingram/models/inbound_response_body_results_inner.py +103 -0
  104. pingram/models/ingishts_post_request.py +121 -0
  105. pingram/models/ingishts_post_request_label_options.py +87 -0
  106. pingram/models/ingishts_post_request_metric_data_queries_inner.py +103 -0
  107. pingram/models/ingishts_post_request_metric_data_queries_inner_metric_stat.py +107 -0
  108. pingram/models/ingishts_post_request_metric_data_queries_inner_metric_stat_metric.py +99 -0
  109. pingram/models/ingishts_post_request_metric_data_queries_inner_metric_stat_metric_dimensions_inner.py +89 -0
  110. pingram/models/intercom_webhook.py +106 -0
  111. pingram/models/intercom_webhook_data.py +91 -0
  112. pingram/models/intercom_webhook_data_item.py +136 -0
  113. pingram/models/intercom_webhook_data_item_any_of.py +140 -0
  114. pingram/models/intercom_webhook_data_item_any_of_contacts.py +104 -0
  115. pingram/models/intercom_webhook_data_item_any_of_contacts_contacts_inner.py +91 -0
  116. pingram/models/intercom_webhook_data_item_any_of_source.py +101 -0
  117. pingram/models/intercom_webhook_data_item_any_of_source_author.py +93 -0
  118. pingram/models/invite_post_response.py +89 -0
  119. pingram/models/log_query_post_body.py +109 -0
  120. pingram/models/logs_bulk_request.py +87 -0
  121. pingram/models/logs_get_response.py +95 -0
  122. pingram/models/logs_get_response_logs_inner.py +627 -0
  123. pingram/models/logs_query_response.py +87 -0
  124. pingram/models/logs_query_result_response.py +101 -0
  125. pingram/models/logs_retention_response.py +87 -0
  126. pingram/models/logs_tail_response.py +95 -0
  127. pingram/models/member_invite_request.py +89 -0
  128. pingram/models/member_update_request.py +87 -0
  129. pingram/models/message_response.py +87 -0
  130. pingram/models/notification.py +126 -0
  131. pingram/models/notification_create_request.py +97 -0
  132. pingram/models/notification_patch_request.py +112 -0
  133. pingram/models/post_email_test_request.py +99 -0
  134. pingram/models/post_email_test_response.py +89 -0
  135. pingram/models/post_senders_request_body.py +87 -0
  136. pingram/models/post_user_request.py +121 -0
  137. pingram/models/sender_post_body.py +166 -0
  138. pingram/models/sender_post_body_email.py +95 -0
  139. pingram/models/sender_post_body_inapp.py +91 -0
  140. pingram/models/sender_post_body_mobile_push.py +89 -0
  141. pingram/models/sender_post_body_options.py +103 -0
  142. pingram/models/sender_post_body_options_apn.py +99 -0
  143. pingram/models/sender_post_body_options_email.py +107 -0
  144. pingram/models/sender_post_body_options_email_attachments_inner.py +134 -0
  145. pingram/models/sender_post_body_options_email_attachments_inner_any_of.py +89 -0
  146. pingram/models/sender_post_body_options_email_attachments_inner_any_of1.py +91 -0
  147. pingram/models/sender_post_body_options_fcm.py +91 -0
  148. pingram/models/sender_post_body_options_fcm_android.py +103 -0
  149. pingram/models/sender_post_body_slack.py +123 -0
  150. pingram/models/sender_post_body_slack_metadata.py +99 -0
  151. pingram/models/sender_post_body_slack_metadata_entities_inner.py +99 -0
  152. pingram/models/sender_post_body_slack_metadata_entities_inner_external_ref.py +89 -0
  153. pingram/models/sender_post_body_sms.py +93 -0
  154. pingram/models/sender_post_body_sms_auto_reply.py +87 -0
  155. pingram/models/sender_post_body_to.py +133 -0
  156. pingram/models/sender_post_body_user.py +133 -0
  157. pingram/models/sender_post_body_web_push.py +93 -0
  158. pingram/models/sender_post_response.py +89 -0
  159. pingram/models/set_default_template_request.py +97 -0
  160. pingram/models/slack_interactivity_response.py +87 -0
  161. pingram/models/slack_oauth_request.py +89 -0
  162. pingram/models/success_response.py +87 -0
  163. pingram/models/supabase_configure_request.py +93 -0
  164. pingram/models/supabase_configure_response.py +89 -0
  165. pingram/models/supabase_o_auth_request.py +91 -0
  166. pingram/models/supabase_o_auth_response.py +89 -0
  167. pingram/models/supabase_projects_response.py +95 -0
  168. pingram/models/supabase_projects_response_projects_inner.py +95 -0
  169. pingram/models/supabase_status_response.py +93 -0
  170. pingram/models/template.py +98 -0
  171. pingram/models/template_patch_request.py +134 -0
  172. pingram/models/template_patch_request_any_of.py +97 -0
  173. pingram/models/template_patch_request_any_of1.py +103 -0
  174. pingram/models/template_patch_request_any_of1_batch.py +91 -0
  175. pingram/models/template_patch_request_any_of1_instant.py +91 -0
  176. pingram/models/template_post_request.py +131 -0
  177. pingram/models/template_post_request_batch.py +91 -0
  178. pingram/models/template_post_request_instant.py +91 -0
  179. pingram/models/update_address_request.py +91 -0
  180. pingram/models/user.py +133 -0
  181. pingram/models/user_suppression_delete_response.py +91 -0
  182. pingram/models/webhook_response.py +104 -0
  183. pingram/py.typed +0 -0
  184. pingram/rest.py +199 -0
  185. pingram_python-0.1.0.dist-info/METADATA +69 -0
  186. pingram_python-0.1.0.dist-info/RECORD +189 -0
  187. pingram_python-0.1.0.dist-info/WHEEL +5 -0
  188. pingram_python-0.1.0.dist-info/licenses/LICENSE +21 -0
  189. pingram_python-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,623 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ NotificationAPI
5
+
6
+ Internal API for notification delivery and management
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 base64
16
+ import copy
17
+ import http.client as httplib
18
+ import logging
19
+ from logging import FileHandler
20
+ import sys
21
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
22
+ from typing_extensions import NotRequired, Self
23
+
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
+ "apiKey": BearerFormatAuthSetting,
116
+ "clientCredentials": BasicAuthSetting,
117
+ "endUser": BasicAuthSetting,
118
+ "endUserHashed": BasicAuthSetting,
119
+ },
120
+ total=False,
121
+ )
122
+
123
+
124
+ class HostSettingVariable(TypedDict):
125
+ description: str
126
+ default_value: str
127
+ enum_values: List[str]
128
+
129
+
130
+ class HostSetting(TypedDict):
131
+ url: str
132
+ description: str
133
+ variables: NotRequired[Dict[str, HostSettingVariable]]
134
+
135
+
136
+ class Configuration:
137
+ """This class contains various settings of the API client.
138
+
139
+ :param host: Base url.
140
+ :param ignore_operation_servers
141
+ Boolean to ignore operation servers for the API client.
142
+ Config will use `host` as the base url regardless of the operation servers.
143
+ :param api_key: Dict to store API key(s).
144
+ Each entry in the dict specifies an API key.
145
+ The dict key is the name of the security scheme in the OAS specification.
146
+ The dict value is the API key secret.
147
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
148
+ The dict key is the name of the security scheme in the OAS specification.
149
+ The dict value is an API key prefix when generating the auth data.
150
+ :param username: Username for HTTP basic authentication.
151
+ :param password: Password for HTTP basic authentication.
152
+ :param access_token: Access token.
153
+ :param server_index: Index to servers configuration.
154
+ :param server_variables: Mapping with string values to replace variables in
155
+ templated server configuration. The validation of enums is performed for
156
+ variables with defined enum values before.
157
+ :param server_operation_index: Mapping from operation ID to an index to server
158
+ configuration.
159
+ :param server_operation_variables: Mapping from operation ID to a mapping with
160
+ string values to replace variables in templated server configuration.
161
+ The validation of enums is performed for variables with defined enum
162
+ values before.
163
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
164
+ in PEM format.
165
+ :param retries: Number of retries for API requests.
166
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
167
+ in PEM (str) or DER (bytes) format.
168
+ :param cert_file: the path to a client certificate file, for mTLS.
169
+ :param key_file: the path to a client key file, for mTLS.
170
+
171
+ :Example:
172
+
173
+ HTTP Basic Authentication Example.
174
+ Given the following security scheme in the OpenAPI specification:
175
+ components:
176
+ securitySchemes:
177
+ http_basic_auth:
178
+ type: http
179
+ scheme: basic
180
+
181
+ Configure API client with HTTP basic authentication:
182
+
183
+ conf = pingram.Configuration(
184
+ username='the-user',
185
+ password='the-password',
186
+ )
187
+
188
+ """
189
+
190
+ _default: ClassVar[Optional[Self]] = None
191
+
192
+ def __init__(
193
+ self,
194
+ host: Optional[str]=None,
195
+ api_key: Optional[Dict[str, str]]=None,
196
+ api_key_prefix: Optional[Dict[str, str]]=None,
197
+ username: Optional[str]=None,
198
+ password: Optional[str]=None,
199
+ access_token: Optional[str]=None,
200
+ server_index: Optional[int]=None,
201
+ server_variables: Optional[ServerVariablesT]=None,
202
+ server_operation_index: Optional[Dict[int, int]]=None,
203
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
204
+ ignore_operation_servers: bool=False,
205
+ ssl_ca_cert: Optional[str]=None,
206
+ retries: Optional[int] = None,
207
+ ca_cert_data: Optional[Union[str, bytes]] = None,
208
+ cert_file: Optional[str]=None,
209
+ key_file: Optional[str]=None,
210
+ *,
211
+ debug: Optional[bool] = None,
212
+ ) -> None:
213
+ """Constructor
214
+ """
215
+ self._base_path = "https://api.notificationapi.com" if host is None else host
216
+ """Default Base url
217
+ """
218
+ self.server_index = 0 if server_index is None and host is None else server_index
219
+ self.server_operation_index = server_operation_index or {}
220
+ """Default server index
221
+ """
222
+ self.server_variables = server_variables or {}
223
+ self.server_operation_variables = server_operation_variables or {}
224
+ """Default server variables
225
+ """
226
+ self.ignore_operation_servers = ignore_operation_servers
227
+ """Ignore operation servers
228
+ """
229
+ self.temp_folder_path = None
230
+ """Temp file folder for downloading files
231
+ """
232
+ # Authentication Settings
233
+ self.api_key = {}
234
+ if api_key:
235
+ self.api_key = api_key
236
+ """dict to store API key(s)
237
+ """
238
+ self.api_key_prefix = {}
239
+ if api_key_prefix:
240
+ self.api_key_prefix = api_key_prefix
241
+ """dict to store API prefix (e.g. Bearer)
242
+ """
243
+ self.refresh_api_key_hook = None
244
+ """function hook to refresh API key if expired
245
+ """
246
+ self.username = username
247
+ """Username for HTTP basic authentication
248
+ """
249
+ self.password = password
250
+ """Password for HTTP basic authentication
251
+ """
252
+ self.access_token = access_token
253
+ """Access token
254
+ """
255
+ self.logger = {}
256
+ """Logging Settings
257
+ """
258
+ self.logger["package_logger"] = logging.getLogger("pingram")
259
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
260
+ """Log format
261
+ """
262
+ self.logger_stream_handler = None
263
+ """Log stream handler
264
+ """
265
+ self.logger_file_handler: Optional[FileHandler] = None
266
+ """Log file handler
267
+ """
268
+ self.logger_file = None
269
+ """Debug file location
270
+ """
271
+ if debug is not None:
272
+ self.debug = debug
273
+ else:
274
+ self.__debug = False
275
+ """Debug switch
276
+ """
277
+
278
+ self.verify_ssl = True
279
+ """SSL/TLS verification
280
+ Set this to false to skip verifying SSL certificate when calling API
281
+ from https server.
282
+ """
283
+ self.ssl_ca_cert = ssl_ca_cert
284
+ """Set this to customize the certificate file to verify the peer.
285
+ """
286
+ self.ca_cert_data = ca_cert_data
287
+ """Set this to verify the peer using PEM (str) or DER (bytes)
288
+ certificate data.
289
+ """
290
+ self.cert_file = cert_file
291
+ """client certificate file
292
+ """
293
+ self.key_file = key_file
294
+ """client key file
295
+ """
296
+ self.assert_hostname = None
297
+ """Set this to True/False to enable/disable SSL hostname verification.
298
+ """
299
+ self.tls_server_name = None
300
+ """SSL/TLS Server Name Indication (SNI)
301
+ Set this to the SNI value expected by the server.
302
+ """
303
+
304
+ self.connection_pool_maxsize = 100
305
+ """This value is passed to the aiohttp to limit simultaneous connections.
306
+ Default values is 100, None means no-limit.
307
+ """
308
+
309
+ self.proxy: Optional[str] = None
310
+ """Proxy URL
311
+ """
312
+ self.proxy_headers = None
313
+ """Proxy headers
314
+ """
315
+ self.safe_chars_for_path_param = ''
316
+ """Safe chars for path_param
317
+ """
318
+ self.retries = retries
319
+ """Adding retries to override urllib3 default value 3
320
+ """
321
+ # Enable client side validation
322
+ self.client_side_validation = True
323
+
324
+ self.socket_options = None
325
+ """Options to pass down to the underlying urllib3 socket
326
+ """
327
+
328
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
329
+ """datetime format
330
+ """
331
+
332
+ self.date_format = "%Y-%m-%d"
333
+ """date format
334
+ """
335
+
336
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
337
+ cls = self.__class__
338
+ result = cls.__new__(cls)
339
+ memo[id(self)] = result
340
+ for k, v in self.__dict__.items():
341
+ if k not in ('logger', 'logger_file_handler'):
342
+ setattr(result, k, copy.deepcopy(v, memo))
343
+ # shallow copy of loggers
344
+ result.logger = copy.copy(self.logger)
345
+ # use setters to configure loggers
346
+ result.logger_file = self.logger_file
347
+ result.debug = self.debug
348
+ return result
349
+
350
+ def __setattr__(self, name: str, value: Any) -> None:
351
+ object.__setattr__(self, name, value)
352
+
353
+ @classmethod
354
+ def set_default(cls, default: Optional[Self]) -> None:
355
+ """Set default instance of configuration.
356
+
357
+ It stores default configuration, which can be
358
+ returned by get_default_copy method.
359
+
360
+ :param default: object of Configuration
361
+ """
362
+ cls._default = default
363
+
364
+ @classmethod
365
+ def get_default_copy(cls) -> Self:
366
+ """Deprecated. Please use `get_default` instead.
367
+
368
+ Deprecated. Please use `get_default` instead.
369
+
370
+ :return: The configuration object.
371
+ """
372
+ return cls.get_default()
373
+
374
+ @classmethod
375
+ def get_default(cls) -> Self:
376
+ """Return the default configuration.
377
+
378
+ This method returns newly created, based on default constructor,
379
+ object of Configuration class or returns a copy of default
380
+ configuration.
381
+
382
+ :return: The configuration object.
383
+ """
384
+ if cls._default is None:
385
+ cls._default = cls()
386
+ return cls._default
387
+
388
+ @property
389
+ def logger_file(self) -> Optional[str]:
390
+ """The logger file.
391
+
392
+ If the logger_file is None, then add stream handler and remove file
393
+ handler. Otherwise, add file handler and remove stream handler.
394
+
395
+ :param value: The logger_file path.
396
+ :type: str
397
+ """
398
+ return self.__logger_file
399
+
400
+ @logger_file.setter
401
+ def logger_file(self, value: Optional[str]) -> None:
402
+ """The logger file.
403
+
404
+ If the logger_file is None, then add stream handler and remove file
405
+ handler. Otherwise, add file handler and remove stream handler.
406
+
407
+ :param value: The logger_file path.
408
+ :type: str
409
+ """
410
+ self.__logger_file = value
411
+ if self.__logger_file:
412
+ # If set logging file,
413
+ # then add file handler and remove stream handler.
414
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
415
+ self.logger_file_handler.setFormatter(self.logger_formatter)
416
+ for _, logger in self.logger.items():
417
+ logger.addHandler(self.logger_file_handler)
418
+
419
+ @property
420
+ def debug(self) -> bool:
421
+ """Debug status
422
+
423
+ :param value: The debug status, True or False.
424
+ :type: bool
425
+ """
426
+ return self.__debug
427
+
428
+ @debug.setter
429
+ def debug(self, value: bool) -> None:
430
+ """Debug status
431
+
432
+ :param value: The debug status, True or False.
433
+ :type: bool
434
+ """
435
+ self.__debug = value
436
+ if self.__debug:
437
+ # if debug status is True, turn on debug logging
438
+ for _, logger in self.logger.items():
439
+ logger.setLevel(logging.DEBUG)
440
+ # turn on httplib debug
441
+ httplib.HTTPConnection.debuglevel = 1
442
+ else:
443
+ # if debug status is False, turn off debug logging,
444
+ # setting log level to default `logging.WARNING`
445
+ for _, logger in self.logger.items():
446
+ logger.setLevel(logging.WARNING)
447
+ # turn off httplib debug
448
+ httplib.HTTPConnection.debuglevel = 0
449
+
450
+ @property
451
+ def logger_format(self) -> str:
452
+ """The logger format.
453
+
454
+ The logger_formatter will be updated when sets logger_format.
455
+
456
+ :param value: The format string.
457
+ :type: str
458
+ """
459
+ return self.__logger_format
460
+
461
+ @logger_format.setter
462
+ def logger_format(self, value: str) -> None:
463
+ """The logger format.
464
+
465
+ The logger_formatter will be updated when sets logger_format.
466
+
467
+ :param value: The format string.
468
+ :type: str
469
+ """
470
+ self.__logger_format = value
471
+ self.logger_formatter = logging.Formatter(self.__logger_format)
472
+
473
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
474
+ """Gets API key (with prefix if set).
475
+
476
+ :param identifier: The identifier of apiKey.
477
+ :param alias: The alternative identifier of apiKey.
478
+ :return: The token for api key authentication.
479
+ """
480
+ if self.refresh_api_key_hook is not None:
481
+ self.refresh_api_key_hook(self)
482
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
483
+ if key:
484
+ prefix = self.api_key_prefix.get(identifier)
485
+ if prefix:
486
+ return "%s %s" % (prefix, key)
487
+ else:
488
+ return key
489
+
490
+ return None
491
+
492
+ def get_basic_auth_token(self) -> Optional[str]:
493
+ """Gets HTTP basic authentication header (string).
494
+
495
+ :return: The token for basic HTTP authentication.
496
+ """
497
+ username = ""
498
+ if self.username is not None:
499
+ username = self.username
500
+ password = ""
501
+ if self.password is not None:
502
+ password = self.password
503
+
504
+ return "Basic " + base64.b64encode(
505
+ (username + ":" + password).encode('utf-8')
506
+ ).decode('utf-8')
507
+
508
+ def auth_settings(self)-> AuthSettings:
509
+ """Gets Auth Settings dict for api client.
510
+
511
+ :return: The Auth Settings information dict.
512
+ """
513
+ auth: AuthSettings = {}
514
+ if self.access_token is not None:
515
+ auth['apiKey'] = {
516
+ 'type': 'bearer',
517
+ 'in': 'header',
518
+ 'format': 'JWT',
519
+ 'key': 'Authorization',
520
+ 'value': 'Bearer ' + self.access_token
521
+ }
522
+ if self.username is not None and self.password is not None:
523
+ auth['clientCredentials'] = {
524
+ 'type': 'basic',
525
+ 'in': 'header',
526
+ 'key': 'Authorization',
527
+ 'value': self.get_basic_auth_token()
528
+ }
529
+ if self.username is not None and self.password is not None:
530
+ auth['endUser'] = {
531
+ 'type': 'basic',
532
+ 'in': 'header',
533
+ 'key': 'Authorization',
534
+ 'value': self.get_basic_auth_token()
535
+ }
536
+ if self.username is not None and self.password is not None:
537
+ auth['endUserHashed'] = {
538
+ 'type': 'basic',
539
+ 'in': 'header',
540
+ 'key': 'Authorization',
541
+ 'value': self.get_basic_auth_token()
542
+ }
543
+ return auth
544
+
545
+ def to_debug_report(self) -> str:
546
+ """Gets the essential information for debugging.
547
+
548
+ :return: The report for debugging.
549
+ """
550
+ return "Python SDK Debug Report:\n"\
551
+ "OS: {env}\n"\
552
+ "Python Version: {pyversion}\n"\
553
+ "Version of the API: 1.0.0\n"\
554
+ "SDK Package Version: 0.1.0".\
555
+ format(env=sys.platform, pyversion=sys.version)
556
+
557
+ def get_host_settings(self) -> List[HostSetting]:
558
+ """Gets an array of host settings
559
+
560
+ :return: An array of host settings
561
+ """
562
+ return [
563
+ {
564
+ 'url': "https://api.notificationapi.com",
565
+ 'description': "Production",
566
+ }
567
+ ]
568
+
569
+ def get_host_from_settings(
570
+ self,
571
+ index: Optional[int],
572
+ variables: Optional[ServerVariablesT]=None,
573
+ servers: Optional[List[HostSetting]]=None,
574
+ ) -> str:
575
+ """Gets host URL based on the index and variables
576
+ :param index: array index of the host settings
577
+ :param variables: hash of variable and the corresponding value
578
+ :param servers: an array of host settings or None
579
+ :return: URL based on host settings
580
+ """
581
+ if index is None:
582
+ return self._base_path
583
+
584
+ variables = {} if variables is None else variables
585
+ servers = self.get_host_settings() if servers is None else servers
586
+
587
+ try:
588
+ server = servers[index]
589
+ except IndexError:
590
+ raise ValueError(
591
+ "Invalid index {0} when selecting the host settings. "
592
+ "Must be less than {1}".format(index, len(servers)))
593
+
594
+ url = server['url']
595
+
596
+ # go through variables and replace placeholders
597
+ for variable_name, variable in server.get('variables', {}).items():
598
+ used_value = variables.get(
599
+ variable_name, variable['default_value'])
600
+
601
+ if 'enum_values' in variable \
602
+ and variable['enum_values'] \
603
+ and used_value not in variable['enum_values']:
604
+ raise ValueError(
605
+ "The variable `{0}` in the host URL has invalid value "
606
+ "{1}. Must be {2}.".format(
607
+ variable_name, variables[variable_name],
608
+ variable['enum_values']))
609
+
610
+ url = url.replace("{" + variable_name + "}", used_value)
611
+
612
+ return url
613
+
614
+ @property
615
+ def host(self) -> str:
616
+ """Return generated host."""
617
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
618
+
619
+ @host.setter
620
+ def host(self, value: str) -> None:
621
+ """Fix base path."""
622
+ self._base_path = value
623
+ self.server_index = None