hatchet-sdk 0.40.0a9__py3-none-any.whl → 0.42.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.

Potentially problematic release.


This version of hatchet-sdk might be problematic. Click here for more details.

Files changed (152) hide show
  1. hatchet_sdk/clients/admin.py +129 -59
  2. hatchet_sdk/clients/dispatcher/action_listener.py +25 -2
  3. hatchet_sdk/clients/events.py +91 -52
  4. hatchet_sdk/clients/rest/__init__.py +21 -0
  5. hatchet_sdk/clients/rest/api/api_token_api.py +12 -9
  6. hatchet_sdk/clients/rest/api/default_api.py +24 -18
  7. hatchet_sdk/clients/rest/api/event_api.py +32 -24
  8. hatchet_sdk/clients/rest/api/github_api.py +4 -3
  9. hatchet_sdk/clients/rest/api/log_api.py +4 -3
  10. hatchet_sdk/clients/rest/api/metadata_api.py +12 -9
  11. hatchet_sdk/clients/rest/api/rate_limits_api.py +7 -4
  12. hatchet_sdk/clients/rest/api/slack_api.py +8 -6
  13. hatchet_sdk/clients/rest/api/sns_api.py +12 -9
  14. hatchet_sdk/clients/rest/api/step_run_api.py +28 -21
  15. hatchet_sdk/clients/rest/api/tenant_api.py +67 -49
  16. hatchet_sdk/clients/rest/api/user_api.py +24 -18
  17. hatchet_sdk/clients/rest/api/worker_api.py +12 -9
  18. hatchet_sdk/clients/rest/api/workflow_api.py +3073 -936
  19. hatchet_sdk/clients/rest/api/workflow_run_api.py +669 -21
  20. hatchet_sdk/clients/rest/api_client.py +34 -11
  21. hatchet_sdk/clients/rest/configuration.py +161 -36
  22. hatchet_sdk/clients/rest/models/__init__.py +21 -0
  23. hatchet_sdk/clients/rest/models/api_errors.py +3 -3
  24. hatchet_sdk/clients/rest/models/bulk_create_event_request.py +3 -3
  25. hatchet_sdk/clients/rest/models/bulk_create_event_response.py +3 -3
  26. hatchet_sdk/clients/{cloud_rest/models/managed_worker_create_request_build_config_steps_inner.py → rest/models/create_cron_workflow_trigger_request.py} +18 -14
  27. hatchet_sdk/clients/{cloud_rest/models/github_app_list_installations200_response_rows_inner.py → rest/models/cron_workflows.py} +54 -21
  28. hatchet_sdk/clients/{cloud_rest/models/log_list200_response.py → rest/models/cron_workflows_list.py} +13 -22
  29. hatchet_sdk/clients/rest/models/cron_workflows_order_by_field.py +37 -0
  30. hatchet_sdk/clients/rest/models/event_list.py +3 -3
  31. hatchet_sdk/clients/rest/models/get_step_run_diff_response.py +3 -3
  32. hatchet_sdk/clients/rest/models/job.py +3 -3
  33. hatchet_sdk/clients/rest/models/job_run.py +3 -3
  34. hatchet_sdk/clients/rest/models/list_api_tokens_response.py +3 -3
  35. hatchet_sdk/clients/rest/models/list_pull_requests_response.py +3 -3
  36. hatchet_sdk/clients/rest/models/list_slack_webhooks.py +3 -3
  37. hatchet_sdk/clients/rest/models/list_sns_integrations.py +3 -3
  38. hatchet_sdk/clients/rest/models/log_line_list.py +3 -3
  39. hatchet_sdk/clients/rest/models/rate_limit_list.py +3 -3
  40. hatchet_sdk/clients/rest/models/replay_workflow_runs_response.py +3 -3
  41. hatchet_sdk/clients/{cloud_rest/models/log_list200_response_rows_inner.py → rest/models/schedule_workflow_run_request.py} +12 -12
  42. hatchet_sdk/clients/rest/models/scheduled_run_status.py +42 -0
  43. hatchet_sdk/clients/rest/models/scheduled_workflows.py +153 -0
  44. hatchet_sdk/clients/{cloud_rest/models/managed_worker_list200_response.py → rest/models/scheduled_workflows_list.py} +13 -22
  45. hatchet_sdk/clients/rest/models/scheduled_workflows_order_by_field.py +37 -0
  46. hatchet_sdk/clients/rest/models/step_run_archive_list.py +3 -3
  47. hatchet_sdk/clients/rest/models/step_run_event_list.py +3 -3
  48. hatchet_sdk/clients/rest/models/tenant_alert_email_group_list.py +3 -3
  49. hatchet_sdk/clients/rest/models/tenant_invite_list.py +3 -3
  50. hatchet_sdk/clients/rest/models/tenant_list.py +3 -3
  51. hatchet_sdk/clients/rest/models/tenant_member_list.py +3 -3
  52. hatchet_sdk/clients/rest/models/tenant_queue_metrics.py +16 -0
  53. hatchet_sdk/clients/rest/models/tenant_resource_policy.py +3 -3
  54. hatchet_sdk/clients/rest/models/tenant_step_run_queue_metrics.py +1 -1
  55. hatchet_sdk/clients/rest/models/user_tenant_memberships_list.py +3 -3
  56. hatchet_sdk/clients/rest/models/webhook_worker_list_response.py +3 -3
  57. hatchet_sdk/clients/rest/models/webhook_worker_request_list_response.py +3 -3
  58. hatchet_sdk/clients/rest/models/worker.py +20 -9
  59. hatchet_sdk/clients/rest/models/worker_list.py +3 -3
  60. hatchet_sdk/clients/{cloud_rest/models/tenant_billing_state_get200_response_payment_methods_inner.py → rest/models/worker_runtime_info.py} +23 -19
  61. hatchet_sdk/clients/rest/models/worker_runtime_sdks.py +38 -0
  62. hatchet_sdk/clients/rest/models/workflow.py +9 -9
  63. hatchet_sdk/clients/rest/models/workflow_list.py +3 -3
  64. hatchet_sdk/clients/rest/models/workflow_run.py +3 -3
  65. hatchet_sdk/clients/rest/models/workflow_run_list.py +3 -3
  66. hatchet_sdk/clients/rest/models/workflow_run_shape.py +3 -3
  67. hatchet_sdk/clients/rest/models/workflow_runs_metrics.py +1 -5
  68. hatchet_sdk/clients/rest/models/workflow_triggers.py +6 -6
  69. hatchet_sdk/clients/rest/models/workflow_version.py +3 -3
  70. hatchet_sdk/clients/rest/rest.py +3 -3
  71. hatchet_sdk/clients/rest_client.py +200 -21
  72. hatchet_sdk/contracts/dispatcher_pb2.py +71 -67
  73. hatchet_sdk/contracts/dispatcher_pb2.pyi +31 -2
  74. hatchet_sdk/contracts/events_pb2.pyi +2 -0
  75. hatchet_sdk/contracts/workflows_pb2.py +42 -40
  76. hatchet_sdk/contracts/workflows_pb2.pyi +24 -6
  77. hatchet_sdk/features/cron.py +286 -0
  78. hatchet_sdk/features/scheduled.py +248 -0
  79. hatchet_sdk/hatchet.py +80 -79
  80. hatchet_sdk/loader.py +37 -14
  81. hatchet_sdk/utils/serialization.py +15 -0
  82. hatchet_sdk/utils/tracing.py +67 -0
  83. hatchet_sdk/worker/runner/runner.py +158 -112
  84. hatchet_sdk/worker/worker.py +1 -17
  85. hatchet_sdk/workflow.py +4 -0
  86. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/METADATA +8 -2
  87. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/RECORD +89 -143
  88. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/entry_points.txt +1 -1
  89. hatchet_sdk/clients/cloud_rest/__init__.py +0 -186
  90. hatchet_sdk/clients/cloud_rest/api/__init__.py +0 -14
  91. hatchet_sdk/clients/cloud_rest/api/billing_api.py +0 -819
  92. hatchet_sdk/clients/cloud_rest/api/build_api.py +0 -298
  93. hatchet_sdk/clients/cloud_rest/api/feature_flags_api.py +0 -295
  94. hatchet_sdk/clients/cloud_rest/api/github_api.py +0 -1347
  95. hatchet_sdk/clients/cloud_rest/api/log_api.py +0 -971
  96. hatchet_sdk/clients/cloud_rest/api/managed_worker_api.py +0 -2546
  97. hatchet_sdk/clients/cloud_rest/api/metadata_api.py +0 -265
  98. hatchet_sdk/clients/cloud_rest/api/metrics_api.py +0 -1026
  99. hatchet_sdk/clients/cloud_rest/api/tenant_api.py +0 -301
  100. hatchet_sdk/clients/cloud_rest/api/user_api.py +0 -473
  101. hatchet_sdk/clients/cloud_rest/api/workflow_api.py +0 -369
  102. hatchet_sdk/clients/cloud_rest/api_client.py +0 -727
  103. hatchet_sdk/clients/cloud_rest/api_response.py +0 -22
  104. hatchet_sdk/clients/cloud_rest/configuration.py +0 -488
  105. hatchet_sdk/clients/cloud_rest/exceptions.py +0 -200
  106. hatchet_sdk/clients/cloud_rest/models/__init__.py +0 -157
  107. hatchet_sdk/clients/cloud_rest/models/billing_portal_link_get200_response.py +0 -85
  108. hatchet_sdk/clients/cloud_rest/models/build_get200_response.py +0 -121
  109. hatchet_sdk/clients/cloud_rest/models/github_app_list_branches200_response_inner.py +0 -86
  110. hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response.py +0 -119
  111. hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_pagination.py +0 -95
  112. hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner_metadata.py +0 -98
  113. hatchet_sdk/clients/cloud_rest/models/github_app_list_repos200_response_inner.py +0 -86
  114. hatchet_sdk/clients/cloud_rest/models/infra_as_code_create_request.py +0 -107
  115. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner.py +0 -136
  116. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_event.py +0 -83
  117. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly.py +0 -100
  118. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly_app.py +0 -86
  119. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_log.py +0 -83
  120. hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request.py +0 -128
  121. hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config.py +0 -121
  122. hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_runtime_config.py +0 -166
  123. hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response.py +0 -119
  124. hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response_rows_inner.py +0 -117
  125. hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response.py +0 -119
  126. hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response_rows_inner.py +0 -113
  127. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner.py +0 -154
  128. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config.py +0 -151
  129. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config_steps_inner.py +0 -109
  130. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_runtime_configs_inner.py +0 -171
  131. hatchet_sdk/clients/cloud_rest/models/managed_worker_update_request.py +0 -131
  132. hatchet_sdk/clients/cloud_rest/models/metadata_get200_response.py +0 -101
  133. hatchet_sdk/clients/cloud_rest/models/metadata_get400_response.py +0 -105
  134. hatchet_sdk/clients/cloud_rest/models/metadata_get400_response_errors_inner.py +0 -102
  135. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner.py +0 -108
  136. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner.py +0 -102
  137. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram.py +0 -113
  138. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner.py +0 -93
  139. hatchet_sdk/clients/cloud_rest/models/runtime_config_list_actions200_response.py +0 -83
  140. hatchet_sdk/clients/cloud_rest/models/subscription_upsert200_response.py +0 -114
  141. hatchet_sdk/clients/cloud_rest/models/subscription_upsert_request.py +0 -88
  142. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response.py +0 -170
  143. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_coupons_inner.py +0 -137
  144. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_plans_inner.py +0 -103
  145. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_subscription.py +0 -114
  146. hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response.py +0 -107
  147. hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response_results_inner.py +0 -105
  148. hatchet_sdk/clients/cloud_rest/rest.py +0 -182
  149. hatchet_sdk/compute/__init__.py +0 -0
  150. hatchet_sdk/compute/configs.py +0 -34
  151. hatchet_sdk/compute/managed_compute.py +0 -111
  152. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/WHEEL +0 -0
@@ -1,22 +0,0 @@
1
- """API response object."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Generic, Mapping, Optional, TypeVar
6
-
7
- from pydantic import BaseModel, Field, StrictBytes, StrictInt
8
-
9
- T = TypeVar("T")
10
-
11
-
12
- class ApiResponse(BaseModel, Generic[T]):
13
- """
14
- API response object
15
- """
16
-
17
- status_code: StrictInt = Field(description="HTTP status code")
18
- headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
19
- data: T = Field(description="Deserialized data given the data type")
20
- raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
21
-
22
- model_config = {"arbitrary_types_allowed": True}
@@ -1,488 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Hatchet API
5
-
6
- The Hatchet API
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
- import sys
19
- from logging import FileHandler
20
- from typing import Optional
21
-
22
- import urllib3
23
-
24
- JSON_SCHEMA_VALIDATION_KEYWORDS = {
25
- "multipleOf",
26
- "maximum",
27
- "exclusiveMaximum",
28
- "minimum",
29
- "exclusiveMinimum",
30
- "maxLength",
31
- "minLength",
32
- "pattern",
33
- "maxItems",
34
- "minItems",
35
- }
36
-
37
-
38
- class Configuration:
39
- """This class contains various settings of the API client.
40
-
41
- :param host: Base url.
42
- :param api_key: Dict to store API key(s).
43
- Each entry in the dict specifies an API key.
44
- The dict key is the name of the security scheme in the OAS specification.
45
- The dict value is the API key secret.
46
- :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
47
- The dict key is the name of the security scheme in the OAS specification.
48
- The dict value is an API key prefix when generating the auth data.
49
- :param username: Username for HTTP basic authentication.
50
- :param password: Password for HTTP basic authentication.
51
- :param access_token: Access token.
52
- :param server_index: Index to servers configuration.
53
- :param server_variables: Mapping with string values to replace variables in
54
- templated server configuration. The validation of enums is performed for
55
- variables with defined enum values before.
56
- :param server_operation_index: Mapping from operation ID to an index to server
57
- configuration.
58
- :param server_operation_variables: Mapping from operation ID to a mapping with
59
- string values to replace variables in templated server configuration.
60
- The validation of enums is performed for variables with defined enum
61
- values before.
62
- :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
63
- in PEM format.
64
-
65
- :Example:
66
-
67
- API Key Authentication Example.
68
- Given the following security scheme in the OpenAPI specification:
69
- components:
70
- securitySchemes:
71
- cookieAuth: # name for the security scheme
72
- type: apiKey
73
- in: cookie
74
- name: JSESSIONID # cookie name
75
-
76
- You can programmatically set the cookie:
77
-
78
- conf = hatchet_sdk.clients.cloud_rest.Configuration(
79
- api_key={'cookieAuth': 'abc123'}
80
- api_key_prefix={'cookieAuth': 'JSESSIONID'}
81
- )
82
-
83
- The following cookie will be added to the HTTP request:
84
- Cookie: JSESSIONID abc123
85
- """
86
-
87
- _default = None
88
-
89
- def __init__(
90
- self,
91
- host=None,
92
- api_key=None,
93
- api_key_prefix=None,
94
- username=None,
95
- password=None,
96
- access_token=None,
97
- server_index=None,
98
- server_variables=None,
99
- server_operation_index=None,
100
- server_operation_variables=None,
101
- ssl_ca_cert=None,
102
- ) -> None:
103
- """Constructor"""
104
- self._base_path = "http://localhost" if host is None else host
105
- """Default Base url
106
- """
107
- self.server_index = 0 if server_index is None and host is None else server_index
108
- self.server_operation_index = server_operation_index or {}
109
- """Default server index
110
- """
111
- self.server_variables = server_variables or {}
112
- self.server_operation_variables = server_operation_variables or {}
113
- """Default server variables
114
- """
115
- self.temp_folder_path = None
116
- """Temp file folder for downloading files
117
- """
118
- # Authentication Settings
119
- self.api_key = {}
120
- if api_key:
121
- self.api_key = api_key
122
- """dict to store API key(s)
123
- """
124
- self.api_key_prefix = {}
125
- if api_key_prefix:
126
- self.api_key_prefix = api_key_prefix
127
- """dict to store API prefix (e.g. Bearer)
128
- """
129
- self.refresh_api_key_hook = None
130
- """function hook to refresh API key if expired
131
- """
132
- self.username = username
133
- """Username for HTTP basic authentication
134
- """
135
- self.password = password
136
- """Password for HTTP basic authentication
137
- """
138
- self.access_token = access_token
139
- """Access token
140
- """
141
- self.logger = {}
142
- """Logging Settings
143
- """
144
- self.logger["package_logger"] = logging.getLogger(
145
- "hatchet_sdk.clients.cloud_rest"
146
- )
147
- self.logger["urllib3_logger"] = logging.getLogger("urllib3")
148
- self.logger_format = "%(asctime)s %(levelname)s %(message)s"
149
- """Log format
150
- """
151
- self.logger_stream_handler = None
152
- """Log stream handler
153
- """
154
- self.logger_file_handler: Optional[FileHandler] = None
155
- """Log file handler
156
- """
157
- self.logger_file = None
158
- """Debug file location
159
- """
160
- self.debug = False
161
- """Debug switch
162
- """
163
-
164
- self.verify_ssl = True
165
- """SSL/TLS verification
166
- Set this to false to skip verifying SSL certificate when calling API
167
- from https server.
168
- """
169
- self.ssl_ca_cert = ssl_ca_cert
170
- """Set this to customize the certificate file to verify the peer.
171
- """
172
- self.cert_file = None
173
- """client certificate file
174
- """
175
- self.key_file = None
176
- """client key file
177
- """
178
- self.assert_hostname = None
179
- """Set this to True/False to enable/disable SSL hostname verification.
180
- """
181
- self.tls_server_name = None
182
- """SSL/TLS Server Name Indication (SNI)
183
- Set this to the SNI value expected by the server.
184
- """
185
-
186
- self.connection_pool_maxsize = 100
187
- """This value is passed to the aiohttp to limit simultaneous connections.
188
- Default values is 100, None means no-limit.
189
- """
190
-
191
- self.proxy: Optional[str] = None
192
- """Proxy URL
193
- """
194
- self.proxy_headers = None
195
- """Proxy headers
196
- """
197
- self.safe_chars_for_path_param = ""
198
- """Safe chars for path_param
199
- """
200
- self.retries = None
201
- """Adding retries to override urllib3 default value 3
202
- """
203
- # Enable client side validation
204
- self.client_side_validation = True
205
-
206
- self.socket_options = None
207
- """Options to pass down to the underlying urllib3 socket
208
- """
209
-
210
- self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
211
- """datetime format
212
- """
213
-
214
- self.date_format = "%Y-%m-%d"
215
- """date format
216
- """
217
-
218
- def __deepcopy__(self, memo):
219
- cls = self.__class__
220
- result = cls.__new__(cls)
221
- memo[id(self)] = result
222
- for k, v in self.__dict__.items():
223
- if k not in ("logger", "logger_file_handler"):
224
- setattr(result, k, copy.deepcopy(v, memo))
225
- # shallow copy of loggers
226
- result.logger = copy.copy(self.logger)
227
- # use setters to configure loggers
228
- result.logger_file = self.logger_file
229
- result.debug = self.debug
230
- return result
231
-
232
- def __setattr__(self, name, value):
233
- object.__setattr__(self, name, value)
234
-
235
- @classmethod
236
- def set_default(cls, default):
237
- """Set default instance of configuration.
238
-
239
- It stores default configuration, which can be
240
- returned by get_default_copy method.
241
-
242
- :param default: object of Configuration
243
- """
244
- cls._default = default
245
-
246
- @classmethod
247
- def get_default_copy(cls):
248
- """Deprecated. Please use `get_default` instead.
249
-
250
- Deprecated. Please use `get_default` instead.
251
-
252
- :return: The configuration object.
253
- """
254
- return cls.get_default()
255
-
256
- @classmethod
257
- def get_default(cls):
258
- """Return the default configuration.
259
-
260
- This method returns newly created, based on default constructor,
261
- object of Configuration class or returns a copy of default
262
- configuration.
263
-
264
- :return: The configuration object.
265
- """
266
- if cls._default is None:
267
- cls._default = Configuration()
268
- return cls._default
269
-
270
- @property
271
- def logger_file(self):
272
- """The logger file.
273
-
274
- If the logger_file is None, then add stream handler and remove file
275
- handler. Otherwise, add file handler and remove stream handler.
276
-
277
- :param value: The logger_file path.
278
- :type: str
279
- """
280
- return self.__logger_file
281
-
282
- @logger_file.setter
283
- def logger_file(self, value):
284
- """The logger file.
285
-
286
- If the logger_file is None, then add stream handler and remove file
287
- handler. Otherwise, add file handler and remove stream handler.
288
-
289
- :param value: The logger_file path.
290
- :type: str
291
- """
292
- self.__logger_file = value
293
- if self.__logger_file:
294
- # If set logging file,
295
- # then add file handler and remove stream handler.
296
- self.logger_file_handler = logging.FileHandler(self.__logger_file)
297
- self.logger_file_handler.setFormatter(self.logger_formatter)
298
- for _, logger in self.logger.items():
299
- logger.addHandler(self.logger_file_handler)
300
-
301
- @property
302
- def debug(self):
303
- """Debug status
304
-
305
- :param value: The debug status, True or False.
306
- :type: bool
307
- """
308
- return self.__debug
309
-
310
- @debug.setter
311
- def debug(self, value):
312
- """Debug status
313
-
314
- :param value: The debug status, True or False.
315
- :type: bool
316
- """
317
- self.__debug = value
318
- if self.__debug:
319
- # if debug status is True, turn on debug logging
320
- for _, logger in self.logger.items():
321
- logger.setLevel(logging.DEBUG)
322
- # turn on httplib debug
323
- httplib.HTTPConnection.debuglevel = 1
324
- else:
325
- # if debug status is False, turn off debug logging,
326
- # setting log level to default `logging.WARNING`
327
- for _, logger in self.logger.items():
328
- logger.setLevel(logging.WARNING)
329
- # turn off httplib debug
330
- httplib.HTTPConnection.debuglevel = 0
331
-
332
- @property
333
- def logger_format(self):
334
- """The logger format.
335
-
336
- The logger_formatter will be updated when sets logger_format.
337
-
338
- :param value: The format string.
339
- :type: str
340
- """
341
- return self.__logger_format
342
-
343
- @logger_format.setter
344
- def logger_format(self, value):
345
- """The logger format.
346
-
347
- The logger_formatter will be updated when sets logger_format.
348
-
349
- :param value: The format string.
350
- :type: str
351
- """
352
- self.__logger_format = value
353
- self.logger_formatter = logging.Formatter(self.__logger_format)
354
-
355
- def get_api_key_with_prefix(self, identifier, alias=None):
356
- """Gets API key (with prefix if set).
357
-
358
- :param identifier: The identifier of apiKey.
359
- :param alias: The alternative identifier of apiKey.
360
- :return: The token for api key authentication.
361
- """
362
- if self.refresh_api_key_hook is not None:
363
- self.refresh_api_key_hook(self)
364
- key = self.api_key.get(
365
- identifier, self.api_key.get(alias) if alias is not None else None
366
- )
367
- if key:
368
- prefix = self.api_key_prefix.get(identifier)
369
- if prefix:
370
- return "%s %s" % (prefix, key)
371
- else:
372
- return key
373
-
374
- def get_basic_auth_token(self):
375
- """Gets HTTP basic authentication header (string).
376
-
377
- :return: The token for basic HTTP authentication.
378
- """
379
- username = ""
380
- if self.username is not None:
381
- username = self.username
382
- password = ""
383
- if self.password is not None:
384
- password = self.password
385
- return urllib3.util.make_headers(basic_auth=username + ":" + password).get(
386
- "authorization"
387
- )
388
-
389
- def auth_settings(self):
390
- """Gets Auth Settings dict for api client.
391
-
392
- :return: The Auth Settings information dict.
393
- """
394
- auth = {}
395
- if self.access_token is not None:
396
- auth["bearerAuth"] = {
397
- "type": "bearer",
398
- "in": "header",
399
- "key": "Authorization",
400
- "value": "Bearer " + self.access_token,
401
- }
402
- if "cookieAuth" in self.api_key:
403
- auth["cookieAuth"] = {
404
- "type": "api_key",
405
- "in": "cookie",
406
- "key": "hatchet",
407
- "value": self.get_api_key_with_prefix(
408
- "cookieAuth",
409
- ),
410
- }
411
- return auth
412
-
413
- def to_debug_report(self):
414
- """Gets the essential information for debugging.
415
-
416
- :return: The report for debugging.
417
- """
418
- return (
419
- "Python SDK Debug Report:\n"
420
- "OS: {env}\n"
421
- "Python Version: {pyversion}\n"
422
- "Version of the API: 1.0.0\n"
423
- "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version)
424
- )
425
-
426
- def get_host_settings(self):
427
- """Gets an array of host settings
428
-
429
- :return: An array of host settings
430
- """
431
- return [
432
- {
433
- "url": "",
434
- "description": "No description provided",
435
- }
436
- ]
437
-
438
- def get_host_from_settings(self, index, variables=None, servers=None):
439
- """Gets host URL based on the index and variables
440
- :param index: array index of the host settings
441
- :param variables: hash of variable and the corresponding value
442
- :param servers: an array of host settings or None
443
- :return: URL based on host settings
444
- """
445
- if index is None:
446
- return self._base_path
447
-
448
- variables = {} if variables is None else variables
449
- servers = self.get_host_settings() if servers is None else servers
450
-
451
- try:
452
- server = servers[index]
453
- except IndexError:
454
- raise ValueError(
455
- "Invalid index {0} when selecting the host settings. "
456
- "Must be less than {1}".format(index, len(servers))
457
- )
458
-
459
- url = server["url"]
460
-
461
- # go through variables and replace placeholders
462
- for variable_name, variable in server.get("variables", {}).items():
463
- used_value = variables.get(variable_name, variable["default_value"])
464
-
465
- if "enum_values" in variable and used_value not in variable["enum_values"]:
466
- raise ValueError(
467
- "The variable `{0}` in the host URL has invalid value "
468
- "{1}. Must be {2}.".format(
469
- variable_name, variables[variable_name], variable["enum_values"]
470
- )
471
- )
472
-
473
- url = url.replace("{" + variable_name + "}", used_value)
474
-
475
- return url
476
-
477
- @property
478
- def host(self):
479
- """Return generated host."""
480
- return self.get_host_from_settings(
481
- self.server_index, variables=self.server_variables
482
- )
483
-
484
- @host.setter
485
- def host(self, value):
486
- """Fix base path."""
487
- self._base_path = value
488
- self.server_index = None
@@ -1,200 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Hatchet API
5
-
6
- The Hatchet API
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
- from typing import Any, Optional
15
-
16
- from typing_extensions import Self
17
-
18
-
19
- class OpenApiException(Exception):
20
- """The base exception class for all OpenAPIExceptions"""
21
-
22
-
23
- class ApiTypeError(OpenApiException, TypeError):
24
- def __init__(
25
- self, msg, path_to_item=None, valid_classes=None, key_type=None
26
- ) -> None:
27
- """Raises an exception for TypeErrors
28
-
29
- Args:
30
- msg (str): the exception message
31
-
32
- Keyword Args:
33
- path_to_item (list): a list of keys an indices to get to the
34
- current_item
35
- None if unset
36
- valid_classes (tuple): the primitive classes that current item
37
- should be an instance of
38
- None if unset
39
- key_type (bool): False if our value is a value in a dict
40
- True if it is a key in a dict
41
- False if our item is an item in a list
42
- None if unset
43
- """
44
- self.path_to_item = path_to_item
45
- self.valid_classes = valid_classes
46
- self.key_type = key_type
47
- full_msg = msg
48
- if path_to_item:
49
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
50
- super(ApiTypeError, self).__init__(full_msg)
51
-
52
-
53
- class ApiValueError(OpenApiException, ValueError):
54
- def __init__(self, msg, path_to_item=None) -> None:
55
- """
56
- Args:
57
- msg (str): the exception message
58
-
59
- Keyword Args:
60
- path_to_item (list) the path to the exception in the
61
- received_data dict. None if unset
62
- """
63
-
64
- self.path_to_item = path_to_item
65
- full_msg = msg
66
- if path_to_item:
67
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
68
- super(ApiValueError, self).__init__(full_msg)
69
-
70
-
71
- class ApiAttributeError(OpenApiException, AttributeError):
72
- def __init__(self, msg, path_to_item=None) -> None:
73
- """
74
- Raised when an attribute reference or assignment fails.
75
-
76
- Args:
77
- msg (str): the exception message
78
-
79
- Keyword Args:
80
- path_to_item (None/list) the path to the exception in the
81
- received_data dict
82
- """
83
- self.path_to_item = path_to_item
84
- full_msg = msg
85
- if path_to_item:
86
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
87
- super(ApiAttributeError, self).__init__(full_msg)
88
-
89
-
90
- class ApiKeyError(OpenApiException, KeyError):
91
- def __init__(self, msg, path_to_item=None) -> None:
92
- """
93
- Args:
94
- msg (str): the exception message
95
-
96
- Keyword Args:
97
- path_to_item (None/list) the path to the exception in the
98
- received_data dict
99
- """
100
- self.path_to_item = path_to_item
101
- full_msg = msg
102
- if path_to_item:
103
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
104
- super(ApiKeyError, self).__init__(full_msg)
105
-
106
-
107
- class ApiException(OpenApiException):
108
-
109
- def __init__(
110
- self,
111
- status=None,
112
- reason=None,
113
- http_resp=None,
114
- *,
115
- body: Optional[str] = None,
116
- data: Optional[Any] = None,
117
- ) -> None:
118
- self.status = status
119
- self.reason = reason
120
- self.body = body
121
- self.data = data
122
- self.headers = None
123
-
124
- if http_resp:
125
- if self.status is None:
126
- self.status = http_resp.status
127
- if self.reason is None:
128
- self.reason = http_resp.reason
129
- if self.body is None:
130
- try:
131
- self.body = http_resp.data.decode("utf-8")
132
- except Exception:
133
- pass
134
- self.headers = http_resp.getheaders()
135
-
136
- @classmethod
137
- def from_response(
138
- cls,
139
- *,
140
- http_resp,
141
- body: Optional[str],
142
- data: Optional[Any],
143
- ) -> Self:
144
- if http_resp.status == 400:
145
- raise BadRequestException(http_resp=http_resp, body=body, data=data)
146
-
147
- if http_resp.status == 401:
148
- raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
149
-
150
- if http_resp.status == 403:
151
- raise ForbiddenException(http_resp=http_resp, body=body, data=data)
152
-
153
- if http_resp.status == 404:
154
- raise NotFoundException(http_resp=http_resp, body=body, data=data)
155
-
156
- if 500 <= http_resp.status <= 599:
157
- raise ServiceException(http_resp=http_resp, body=body, data=data)
158
- raise ApiException(http_resp=http_resp, body=body, data=data)
159
-
160
- def __str__(self):
161
- """Custom error messages for exception"""
162
- error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
163
- if self.headers:
164
- error_message += "HTTP response headers: {0}\n".format(self.headers)
165
-
166
- if self.data or self.body:
167
- error_message += "HTTP response body: {0}\n".format(self.data or self.body)
168
-
169
- return error_message
170
-
171
-
172
- class BadRequestException(ApiException):
173
- pass
174
-
175
-
176
- class NotFoundException(ApiException):
177
- pass
178
-
179
-
180
- class UnauthorizedException(ApiException):
181
- pass
182
-
183
-
184
- class ForbiddenException(ApiException):
185
- pass
186
-
187
-
188
- class ServiceException(ApiException):
189
- pass
190
-
191
-
192
- def render_path(path_to_item):
193
- """Returns a string representation of a path"""
194
- result = ""
195
- for pth in path_to_item:
196
- if isinstance(pth, int):
197
- result += "[{0}]".format(pth)
198
- else:
199
- result += "['{0}']".format(pth)
200
- return result