hatchet-sdk 1.18.1__py3-none-any.whl → 1.19.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 (225) hide show
  1. {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/METADATA +2 -3
  2. {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/RECORD +4 -225
  3. hatchet_sdk/v0/__init__.py +0 -251
  4. hatchet_sdk/v0/client.py +0 -119
  5. hatchet_sdk/v0/clients/admin.py +0 -541
  6. hatchet_sdk/v0/clients/dispatcher/action_listener.py +0 -422
  7. hatchet_sdk/v0/clients/dispatcher/dispatcher.py +0 -204
  8. hatchet_sdk/v0/clients/event_ts.py +0 -28
  9. hatchet_sdk/v0/clients/events.py +0 -182
  10. hatchet_sdk/v0/clients/rest/__init__.py +0 -307
  11. hatchet_sdk/v0/clients/rest/api/__init__.py +0 -19
  12. hatchet_sdk/v0/clients/rest/api/api_token_api.py +0 -858
  13. hatchet_sdk/v0/clients/rest/api/default_api.py +0 -2259
  14. hatchet_sdk/v0/clients/rest/api/event_api.py +0 -2548
  15. hatchet_sdk/v0/clients/rest/api/github_api.py +0 -331
  16. hatchet_sdk/v0/clients/rest/api/healthcheck_api.py +0 -483
  17. hatchet_sdk/v0/clients/rest/api/log_api.py +0 -449
  18. hatchet_sdk/v0/clients/rest/api/metadata_api.py +0 -728
  19. hatchet_sdk/v0/clients/rest/api/rate_limits_api.py +0 -423
  20. hatchet_sdk/v0/clients/rest/api/slack_api.py +0 -577
  21. hatchet_sdk/v0/clients/rest/api/sns_api.py +0 -872
  22. hatchet_sdk/v0/clients/rest/api/step_run_api.py +0 -2202
  23. hatchet_sdk/v0/clients/rest/api/tenant_api.py +0 -4430
  24. hatchet_sdk/v0/clients/rest/api/user_api.py +0 -2888
  25. hatchet_sdk/v0/clients/rest/api/worker_api.py +0 -858
  26. hatchet_sdk/v0/clients/rest/api/workflow_api.py +0 -6312
  27. hatchet_sdk/v0/clients/rest/api/workflow_run_api.py +0 -1932
  28. hatchet_sdk/v0/clients/rest/api/workflow_runs_api.py +0 -610
  29. hatchet_sdk/v0/clients/rest/api_client.py +0 -759
  30. hatchet_sdk/v0/clients/rest/api_response.py +0 -22
  31. hatchet_sdk/v0/clients/rest/configuration.py +0 -611
  32. hatchet_sdk/v0/clients/rest/exceptions.py +0 -200
  33. hatchet_sdk/v0/clients/rest/models/__init__.py +0 -274
  34. hatchet_sdk/v0/clients/rest/models/accept_invite_request.py +0 -83
  35. hatchet_sdk/v0/clients/rest/models/api_error.py +0 -102
  36. hatchet_sdk/v0/clients/rest/models/api_errors.py +0 -100
  37. hatchet_sdk/v0/clients/rest/models/api_meta.py +0 -144
  38. hatchet_sdk/v0/clients/rest/models/api_meta_auth.py +0 -85
  39. hatchet_sdk/v0/clients/rest/models/api_meta_integration.py +0 -88
  40. hatchet_sdk/v0/clients/rest/models/api_meta_posthog.py +0 -90
  41. hatchet_sdk/v0/clients/rest/models/api_resource_meta.py +0 -98
  42. hatchet_sdk/v0/clients/rest/models/api_token.py +0 -105
  43. hatchet_sdk/v0/clients/rest/models/bulk_create_event_request.py +0 -100
  44. hatchet_sdk/v0/clients/rest/models/bulk_create_event_response.py +0 -110
  45. hatchet_sdk/v0/clients/rest/models/cancel_event_request.py +0 -85
  46. hatchet_sdk/v0/clients/rest/models/cancel_step_run_request.py +0 -83
  47. hatchet_sdk/v0/clients/rest/models/concurrency_limit_strategy.py +0 -39
  48. hatchet_sdk/v0/clients/rest/models/create_api_token_request.py +0 -92
  49. hatchet_sdk/v0/clients/rest/models/create_api_token_response.py +0 -83
  50. hatchet_sdk/v0/clients/rest/models/create_cron_workflow_trigger_request.py +0 -98
  51. hatchet_sdk/v0/clients/rest/models/create_event_request.py +0 -95
  52. hatchet_sdk/v0/clients/rest/models/create_pull_request_from_step_run.py +0 -83
  53. hatchet_sdk/v0/clients/rest/models/create_sns_integration_request.py +0 -85
  54. hatchet_sdk/v0/clients/rest/models/create_tenant_alert_email_group_request.py +0 -83
  55. hatchet_sdk/v0/clients/rest/models/create_tenant_invite_request.py +0 -86
  56. hatchet_sdk/v0/clients/rest/models/create_tenant_request.py +0 -84
  57. hatchet_sdk/v0/clients/rest/models/cron_workflows.py +0 -131
  58. hatchet_sdk/v0/clients/rest/models/cron_workflows_list.py +0 -110
  59. hatchet_sdk/v0/clients/rest/models/cron_workflows_method.py +0 -37
  60. hatchet_sdk/v0/clients/rest/models/cron_workflows_order_by_field.py +0 -37
  61. hatchet_sdk/v0/clients/rest/models/event.py +0 -143
  62. hatchet_sdk/v0/clients/rest/models/event_data.py +0 -83
  63. hatchet_sdk/v0/clients/rest/models/event_key_list.py +0 -98
  64. hatchet_sdk/v0/clients/rest/models/event_list.py +0 -110
  65. hatchet_sdk/v0/clients/rest/models/event_order_by_direction.py +0 -37
  66. hatchet_sdk/v0/clients/rest/models/event_order_by_field.py +0 -36
  67. hatchet_sdk/v0/clients/rest/models/event_update_cancel200_response.py +0 -85
  68. hatchet_sdk/v0/clients/rest/models/event_workflow_run_summary.py +0 -116
  69. hatchet_sdk/v0/clients/rest/models/events.py +0 -110
  70. hatchet_sdk/v0/clients/rest/models/get_step_run_diff_response.py +0 -100
  71. hatchet_sdk/v0/clients/rest/models/github_app_installation.py +0 -107
  72. hatchet_sdk/v0/clients/rest/models/github_branch.py +0 -86
  73. hatchet_sdk/v0/clients/rest/models/github_repo.py +0 -86
  74. hatchet_sdk/v0/clients/rest/models/info_get_version200_response.py +0 -83
  75. hatchet_sdk/v0/clients/rest/models/job.py +0 -132
  76. hatchet_sdk/v0/clients/rest/models/job_run.py +0 -176
  77. hatchet_sdk/v0/clients/rest/models/job_run_status.py +0 -41
  78. hatchet_sdk/v0/clients/rest/models/link_github_repository_request.py +0 -106
  79. hatchet_sdk/v0/clients/rest/models/list_api_tokens_response.py +0 -110
  80. hatchet_sdk/v0/clients/rest/models/list_github_app_installations_response.py +0 -112
  81. hatchet_sdk/v0/clients/rest/models/list_pull_requests_response.py +0 -100
  82. hatchet_sdk/v0/clients/rest/models/list_slack_webhooks.py +0 -110
  83. hatchet_sdk/v0/clients/rest/models/list_sns_integrations.py +0 -110
  84. hatchet_sdk/v0/clients/rest/models/log_line.py +0 -94
  85. hatchet_sdk/v0/clients/rest/models/log_line_level.py +0 -39
  86. hatchet_sdk/v0/clients/rest/models/log_line_list.py +0 -110
  87. hatchet_sdk/v0/clients/rest/models/log_line_order_by_direction.py +0 -37
  88. hatchet_sdk/v0/clients/rest/models/log_line_order_by_field.py +0 -36
  89. hatchet_sdk/v0/clients/rest/models/pagination_response.py +0 -95
  90. hatchet_sdk/v0/clients/rest/models/pull_request.py +0 -112
  91. hatchet_sdk/v0/clients/rest/models/pull_request_state.py +0 -37
  92. hatchet_sdk/v0/clients/rest/models/queue_metrics.py +0 -97
  93. hatchet_sdk/v0/clients/rest/models/rate_limit.py +0 -117
  94. hatchet_sdk/v0/clients/rest/models/rate_limit_list.py +0 -110
  95. hatchet_sdk/v0/clients/rest/models/rate_limit_order_by_direction.py +0 -37
  96. hatchet_sdk/v0/clients/rest/models/rate_limit_order_by_field.py +0 -38
  97. hatchet_sdk/v0/clients/rest/models/recent_step_runs.py +0 -118
  98. hatchet_sdk/v0/clients/rest/models/reject_invite_request.py +0 -83
  99. hatchet_sdk/v0/clients/rest/models/replay_event_request.py +0 -85
  100. hatchet_sdk/v0/clients/rest/models/replay_workflow_runs_request.py +0 -85
  101. hatchet_sdk/v0/clients/rest/models/replay_workflow_runs_response.py +0 -100
  102. hatchet_sdk/v0/clients/rest/models/rerun_step_run_request.py +0 -83
  103. hatchet_sdk/v0/clients/rest/models/schedule_workflow_run_request.py +0 -92
  104. hatchet_sdk/v0/clients/rest/models/scheduled_run_status.py +0 -42
  105. hatchet_sdk/v0/clients/rest/models/scheduled_workflows.py +0 -149
  106. hatchet_sdk/v0/clients/rest/models/scheduled_workflows_list.py +0 -110
  107. hatchet_sdk/v0/clients/rest/models/scheduled_workflows_method.py +0 -37
  108. hatchet_sdk/v0/clients/rest/models/scheduled_workflows_order_by_field.py +0 -37
  109. hatchet_sdk/v0/clients/rest/models/semaphore_slots.py +0 -113
  110. hatchet_sdk/v0/clients/rest/models/slack_webhook.py +0 -127
  111. hatchet_sdk/v0/clients/rest/models/sns_integration.py +0 -114
  112. hatchet_sdk/v0/clients/rest/models/step.py +0 -123
  113. hatchet_sdk/v0/clients/rest/models/step_run.py +0 -202
  114. hatchet_sdk/v0/clients/rest/models/step_run_archive.py +0 -142
  115. hatchet_sdk/v0/clients/rest/models/step_run_archive_list.py +0 -110
  116. hatchet_sdk/v0/clients/rest/models/step_run_diff.py +0 -91
  117. hatchet_sdk/v0/clients/rest/models/step_run_event.py +0 -122
  118. hatchet_sdk/v0/clients/rest/models/step_run_event_list.py +0 -110
  119. hatchet_sdk/v0/clients/rest/models/step_run_event_reason.py +0 -52
  120. hatchet_sdk/v0/clients/rest/models/step_run_event_severity.py +0 -38
  121. hatchet_sdk/v0/clients/rest/models/step_run_status.py +0 -44
  122. hatchet_sdk/v0/clients/rest/models/tenant.py +0 -118
  123. hatchet_sdk/v0/clients/rest/models/tenant_alert_email_group.py +0 -98
  124. hatchet_sdk/v0/clients/rest/models/tenant_alert_email_group_list.py +0 -112
  125. hatchet_sdk/v0/clients/rest/models/tenant_alerting_settings.py +0 -143
  126. hatchet_sdk/v0/clients/rest/models/tenant_invite.py +0 -120
  127. hatchet_sdk/v0/clients/rest/models/tenant_invite_list.py +0 -110
  128. hatchet_sdk/v0/clients/rest/models/tenant_list.py +0 -110
  129. hatchet_sdk/v0/clients/rest/models/tenant_member.py +0 -123
  130. hatchet_sdk/v0/clients/rest/models/tenant_member_list.py +0 -110
  131. hatchet_sdk/v0/clients/rest/models/tenant_member_role.py +0 -38
  132. hatchet_sdk/v0/clients/rest/models/tenant_queue_metrics.py +0 -116
  133. hatchet_sdk/v0/clients/rest/models/tenant_resource.py +0 -40
  134. hatchet_sdk/v0/clients/rest/models/tenant_resource_limit.py +0 -135
  135. hatchet_sdk/v0/clients/rest/models/tenant_resource_policy.py +0 -102
  136. hatchet_sdk/v0/clients/rest/models/tenant_step_run_queue_metrics.py +0 -83
  137. hatchet_sdk/v0/clients/rest/models/trigger_workflow_run_request.py +0 -91
  138. hatchet_sdk/v0/clients/rest/models/update_tenant_alert_email_group_request.py +0 -83
  139. hatchet_sdk/v0/clients/rest/models/update_tenant_invite_request.py +0 -85
  140. hatchet_sdk/v0/clients/rest/models/update_tenant_request.py +0 -137
  141. hatchet_sdk/v0/clients/rest/models/update_worker_request.py +0 -87
  142. hatchet_sdk/v0/clients/rest/models/user.py +0 -126
  143. hatchet_sdk/v0/clients/rest/models/user_change_password_request.py +0 -88
  144. hatchet_sdk/v0/clients/rest/models/user_login_request.py +0 -86
  145. hatchet_sdk/v0/clients/rest/models/user_register_request.py +0 -91
  146. hatchet_sdk/v0/clients/rest/models/user_tenant_memberships_list.py +0 -110
  147. hatchet_sdk/v0/clients/rest/models/user_tenant_public.py +0 -86
  148. hatchet_sdk/v0/clients/rest/models/webhook_worker.py +0 -100
  149. hatchet_sdk/v0/clients/rest/models/webhook_worker_create_request.py +0 -94
  150. hatchet_sdk/v0/clients/rest/models/webhook_worker_create_response.py +0 -98
  151. hatchet_sdk/v0/clients/rest/models/webhook_worker_created.py +0 -102
  152. hatchet_sdk/v0/clients/rest/models/webhook_worker_list_response.py +0 -110
  153. hatchet_sdk/v0/clients/rest/models/webhook_worker_request.py +0 -102
  154. hatchet_sdk/v0/clients/rest/models/webhook_worker_request_list_response.py +0 -104
  155. hatchet_sdk/v0/clients/rest/models/webhook_worker_request_method.py +0 -38
  156. hatchet_sdk/v0/clients/rest/models/worker.py +0 -239
  157. hatchet_sdk/v0/clients/rest/models/worker_label.py +0 -102
  158. hatchet_sdk/v0/clients/rest/models/worker_list.py +0 -110
  159. hatchet_sdk/v0/clients/rest/models/worker_runtime_info.py +0 -103
  160. hatchet_sdk/v0/clients/rest/models/worker_runtime_sdks.py +0 -38
  161. hatchet_sdk/v0/clients/rest/models/worker_type.py +0 -38
  162. hatchet_sdk/v0/clients/rest/models/workflow.py +0 -165
  163. hatchet_sdk/v0/clients/rest/models/workflow_concurrency.py +0 -107
  164. hatchet_sdk/v0/clients/rest/models/workflow_deployment_config.py +0 -136
  165. hatchet_sdk/v0/clients/rest/models/workflow_kind.py +0 -38
  166. hatchet_sdk/v0/clients/rest/models/workflow_list.py +0 -120
  167. hatchet_sdk/v0/clients/rest/models/workflow_metrics.py +0 -97
  168. hatchet_sdk/v0/clients/rest/models/workflow_run.py +0 -188
  169. hatchet_sdk/v0/clients/rest/models/workflow_run_cancel200_response.py +0 -85
  170. hatchet_sdk/v0/clients/rest/models/workflow_run_list.py +0 -110
  171. hatchet_sdk/v0/clients/rest/models/workflow_run_order_by_direction.py +0 -37
  172. hatchet_sdk/v0/clients/rest/models/workflow_run_order_by_field.py +0 -39
  173. hatchet_sdk/v0/clients/rest/models/workflow_run_shape.py +0 -186
  174. hatchet_sdk/v0/clients/rest/models/workflow_run_status.py +0 -42
  175. hatchet_sdk/v0/clients/rest/models/workflow_run_triggered_by.py +0 -112
  176. hatchet_sdk/v0/clients/rest/models/workflow_runs_cancel_request.py +0 -85
  177. hatchet_sdk/v0/clients/rest/models/workflow_runs_metrics.py +0 -94
  178. hatchet_sdk/v0/clients/rest/models/workflow_runs_metrics_counts.py +0 -104
  179. hatchet_sdk/v0/clients/rest/models/workflow_tag.py +0 -84
  180. hatchet_sdk/v0/clients/rest/models/workflow_trigger_cron_ref.py +0 -86
  181. hatchet_sdk/v0/clients/rest/models/workflow_trigger_event_ref.py +0 -86
  182. hatchet_sdk/v0/clients/rest/models/workflow_triggers.py +0 -141
  183. hatchet_sdk/v0/clients/rest/models/workflow_update_request.py +0 -85
  184. hatchet_sdk/v0/clients/rest/models/workflow_version.py +0 -170
  185. hatchet_sdk/v0/clients/rest/models/workflow_version_concurrency.py +0 -114
  186. hatchet_sdk/v0/clients/rest/models/workflow_version_definition.py +0 -85
  187. hatchet_sdk/v0/clients/rest/models/workflow_version_meta.py +0 -123
  188. hatchet_sdk/v0/clients/rest/models/workflow_workers_count.py +0 -95
  189. hatchet_sdk/v0/clients/rest/rest.py +0 -187
  190. hatchet_sdk/v0/clients/rest/tenacity_utils.py +0 -39
  191. hatchet_sdk/v0/clients/rest_client.py +0 -622
  192. hatchet_sdk/v0/clients/run_event_listener.py +0 -260
  193. hatchet_sdk/v0/clients/workflow_listener.py +0 -277
  194. hatchet_sdk/v0/connection.py +0 -63
  195. hatchet_sdk/v0/context/__init__.py +0 -1
  196. hatchet_sdk/v0/context/context.py +0 -446
  197. hatchet_sdk/v0/context/worker_context.py +0 -28
  198. hatchet_sdk/v0/features/cron.py +0 -286
  199. hatchet_sdk/v0/features/scheduled.py +0 -248
  200. hatchet_sdk/v0/hatchet.py +0 -310
  201. hatchet_sdk/v0/labels.py +0 -10
  202. hatchet_sdk/v0/loader.py +0 -244
  203. hatchet_sdk/v0/metadata.py +0 -2
  204. hatchet_sdk/v0/opentelemetry/instrumentor.py +0 -393
  205. hatchet_sdk/v0/rate_limit.py +0 -126
  206. hatchet_sdk/v0/semver.py +0 -30
  207. hatchet_sdk/v0/token.py +0 -27
  208. hatchet_sdk/v0/utils/aio_utils.py +0 -137
  209. hatchet_sdk/v0/utils/backoff.py +0 -9
  210. hatchet_sdk/v0/utils/types.py +0 -8
  211. hatchet_sdk/v0/utils/typing.py +0 -12
  212. hatchet_sdk/v0/v2/callable.py +0 -202
  213. hatchet_sdk/v0/v2/concurrency.py +0 -47
  214. hatchet_sdk/v0/v2/hatchet.py +0 -224
  215. hatchet_sdk/v0/worker/__init__.py +0 -1
  216. hatchet_sdk/v0/worker/action_listener_process.py +0 -294
  217. hatchet_sdk/v0/worker/runner/run_loop_manager.py +0 -112
  218. hatchet_sdk/v0/worker/runner/runner.py +0 -460
  219. hatchet_sdk/v0/worker/runner/utils/capture_logs.py +0 -81
  220. hatchet_sdk/v0/worker/runner/utils/error_with_traceback.py +0 -6
  221. hatchet_sdk/v0/worker/worker.py +0 -391
  222. hatchet_sdk/v0/workflow.py +0 -261
  223. hatchet_sdk/v0/workflow_run.py +0 -59
  224. {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/WHEEL +0 -0
  225. {hatchet_sdk-1.18.1.dist-info → hatchet_sdk-1.19.0.dist-info}/entry_points.txt +0 -0
@@ -1,759 +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 datetime
16
- import decimal
17
- import json
18
- import mimetypes
19
- import os
20
- import re
21
- import tempfile
22
- from enum import Enum
23
- from typing import Dict, List, Optional, Tuple, Union
24
- from urllib.parse import quote
25
-
26
- from dateutil.parser import parse
27
- from pydantic import SecretStr
28
-
29
- import hatchet_sdk.clients.rest.models
30
- from hatchet_sdk.v0.clients.rest import rest
31
- from hatchet_sdk.v0.clients.rest.api_response import ApiResponse
32
- from hatchet_sdk.v0.clients.rest.api_response import T as ApiResponseT
33
- from hatchet_sdk.v0.clients.rest.configuration import Configuration
34
- from hatchet_sdk.v0.clients.rest.exceptions import (
35
- ApiException,
36
- ApiValueError,
37
- BadRequestException,
38
- ForbiddenException,
39
- NotFoundException,
40
- ServiceException,
41
- UnauthorizedException,
42
- )
43
-
44
- RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
45
-
46
-
47
- class ApiClient:
48
- """Generic API client for OpenAPI client library builds.
49
-
50
- OpenAPI generic API client. This client handles the client-
51
- server communication, and is invariant across implementations. Specifics of
52
- the methods and models for each application are generated from the OpenAPI
53
- templates.
54
-
55
- :param configuration: .Configuration object for this client
56
- :param header_name: a header to pass when making calls to the API.
57
- :param header_value: a header value to pass when making calls to
58
- the API.
59
- :param cookie: a cookie to include in the header when making calls
60
- to the API
61
- """
62
-
63
- PRIMITIVE_TYPES = (float, bool, bytes, str, int)
64
- NATIVE_TYPES_MAPPING = {
65
- "int": int,
66
- "long": int, # TODO remove as only py3 is supported?
67
- "float": float,
68
- "str": str,
69
- "bool": bool,
70
- "date": datetime.date,
71
- "datetime": datetime.datetime,
72
- "decimal": decimal.Decimal,
73
- "object": object,
74
- }
75
- _pool = None
76
-
77
- def __init__(
78
- self, configuration=None, header_name=None, header_value=None, cookie=None
79
- ) -> None:
80
- # use default configuration if none is provided
81
- if configuration is None:
82
- configuration = Configuration.get_default()
83
- self.configuration = configuration
84
-
85
- self.rest_client = rest.RESTClientObject(configuration)
86
- self.default_headers = {}
87
- if header_name is not None:
88
- self.default_headers[header_name] = header_value
89
- self.cookie = cookie
90
- # Set default User-Agent.
91
- self.user_agent = "OpenAPI-Generator/1.0.0/python"
92
- self.client_side_validation = configuration.client_side_validation
93
-
94
- async def __aenter__(self):
95
- return self
96
-
97
- async def __aexit__(self, exc_type, exc_value, traceback):
98
- await self.close()
99
-
100
- async def close(self):
101
- await self.rest_client.close()
102
-
103
- @property
104
- def user_agent(self):
105
- """User agent for this API client"""
106
- return self.default_headers["User-Agent"]
107
-
108
- @user_agent.setter
109
- def user_agent(self, value):
110
- self.default_headers["User-Agent"] = value
111
-
112
- def set_default_header(self, header_name, header_value):
113
- self.default_headers[header_name] = header_value
114
-
115
- _default = None
116
-
117
- @classmethod
118
- def get_default(cls):
119
- """Return new instance of ApiClient.
120
-
121
- This method returns newly created, based on default constructor,
122
- object of ApiClient class or returns a copy of default
123
- ApiClient.
124
-
125
- :return: The ApiClient object.
126
- """
127
- if cls._default is None:
128
- cls._default = ApiClient()
129
- return cls._default
130
-
131
- @classmethod
132
- def set_default(cls, default):
133
- """Set default instance of ApiClient.
134
-
135
- It stores default ApiClient.
136
-
137
- :param default: object of ApiClient.
138
- """
139
- cls._default = default
140
-
141
- def param_serialize(
142
- self,
143
- method,
144
- resource_path,
145
- path_params=None,
146
- query_params=None,
147
- header_params=None,
148
- body=None,
149
- post_params=None,
150
- files=None,
151
- auth_settings=None,
152
- collection_formats=None,
153
- _host=None,
154
- _request_auth=None,
155
- ) -> RequestSerialized:
156
- """Builds the HTTP request params needed by the request.
157
- :param method: Method to call.
158
- :param resource_path: Path to method endpoint.
159
- :param path_params: Path parameters in the url.
160
- :param query_params: Query parameters in the url.
161
- :param header_params: Header parameters to be
162
- placed in the request header.
163
- :param body: Request body.
164
- :param post_params dict: Request post form parameters,
165
- for `application/x-www-form-urlencoded`, `multipart/form-data`.
166
- :param auth_settings list: Auth Settings names for the request.
167
- :param files dict: key -> filename, value -> filepath,
168
- for `multipart/form-data`.
169
- :param collection_formats: dict of collection formats for path, query,
170
- header, and post parameters.
171
- :param _request_auth: set to override the auth_settings for an a single
172
- request; this effectively ignores the authentication
173
- in the spec for a single request.
174
- :return: tuple of form (path, http_method, query_params, header_params,
175
- body, post_params, files)
176
- """
177
-
178
- config = self.configuration
179
-
180
- # header parameters
181
- header_params = header_params or {}
182
- header_params.update(self.default_headers)
183
- if self.cookie:
184
- header_params["Cookie"] = self.cookie
185
- if header_params:
186
- header_params = self.sanitize_for_serialization(header_params)
187
- header_params = dict(
188
- self.parameters_to_tuples(header_params, collection_formats)
189
- )
190
-
191
- # path parameters
192
- if path_params:
193
- path_params = self.sanitize_for_serialization(path_params)
194
- path_params = self.parameters_to_tuples(path_params, collection_formats)
195
- for k, v in path_params:
196
- # specified safe chars, encode everything
197
- resource_path = resource_path.replace(
198
- "{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param)
199
- )
200
-
201
- # post parameters
202
- if post_params or files:
203
- post_params = post_params if post_params else []
204
- post_params = self.sanitize_for_serialization(post_params)
205
- post_params = self.parameters_to_tuples(post_params, collection_formats)
206
- if files:
207
- post_params.extend(self.files_parameters(files))
208
-
209
- # auth setting
210
- self.update_params_for_auth(
211
- header_params,
212
- query_params,
213
- auth_settings,
214
- resource_path,
215
- method,
216
- body,
217
- request_auth=_request_auth,
218
- )
219
-
220
- # body
221
- if body:
222
- body = self.sanitize_for_serialization(body)
223
-
224
- # request url
225
- if _host is None or self.configuration.ignore_operation_servers:
226
- url = self.configuration.host + resource_path
227
- else:
228
- # use server/host defined in path or operation instead
229
- url = _host + resource_path
230
-
231
- # query parameters
232
- if query_params:
233
- query_params = self.sanitize_for_serialization(query_params)
234
- url_query = self.parameters_to_url_query(query_params, collection_formats)
235
- url += "?" + url_query
236
-
237
- return method, url, header_params, body, post_params
238
-
239
- async def call_api(
240
- self,
241
- method,
242
- url,
243
- header_params=None,
244
- body=None,
245
- post_params=None,
246
- _request_timeout=None,
247
- ) -> rest.RESTResponse:
248
- """Makes the HTTP request (synchronous)
249
- :param method: Method to call.
250
- :param url: Path to method endpoint.
251
- :param header_params: Header parameters to be
252
- placed in the request header.
253
- :param body: Request body.
254
- :param post_params dict: Request post form parameters,
255
- for `application/x-www-form-urlencoded`, `multipart/form-data`.
256
- :param _request_timeout: timeout setting for this request.
257
- :return: RESTResponse
258
- """
259
-
260
- try:
261
- # perform request and return response
262
- response_data = await self.rest_client.request(
263
- method,
264
- url,
265
- headers=header_params,
266
- body=body,
267
- post_params=post_params,
268
- _request_timeout=_request_timeout,
269
- )
270
-
271
- except ApiException as e:
272
- raise e
273
-
274
- return response_data
275
-
276
- def response_deserialize(
277
- self,
278
- response_data: rest.RESTResponse,
279
- response_types_map: Optional[Dict[str, ApiResponseT]] = None,
280
- ) -> ApiResponse[ApiResponseT]:
281
- """Deserializes response into an object.
282
- :param response_data: RESTResponse object to be deserialized.
283
- :param response_types_map: dict of response types.
284
- :return: ApiResponse
285
- """
286
-
287
- msg = "RESTResponse.read() must be called before passing it to response_deserialize()"
288
- assert response_data.data is not None, msg
289
-
290
- response_type = response_types_map.get(str(response_data.status), None)
291
- if (
292
- not response_type
293
- and isinstance(response_data.status, int)
294
- and 100 <= response_data.status <= 599
295
- ):
296
- # if not found, look for '1XX', '2XX', etc.
297
- response_type = response_types_map.get(
298
- str(response_data.status)[0] + "XX", None
299
- )
300
-
301
- # deserialize response data
302
- response_text = None
303
- return_data = None
304
- try:
305
- if response_type == "bytearray":
306
- return_data = response_data.data
307
- elif response_type == "file":
308
- return_data = self.__deserialize_file(response_data)
309
- elif response_type is not None:
310
- match = None
311
- content_type = response_data.getheader("content-type")
312
- if content_type is not None:
313
- match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
314
- encoding = match.group(1) if match else "utf-8"
315
- response_text = response_data.data.decode(encoding)
316
- return_data = self.deserialize(
317
- response_text, response_type, content_type
318
- )
319
- finally:
320
- if not 200 <= response_data.status <= 299:
321
- raise ApiException.from_response(
322
- http_resp=response_data,
323
- body=response_text,
324
- data=return_data,
325
- )
326
-
327
- return ApiResponse(
328
- status_code=response_data.status,
329
- data=return_data,
330
- headers=response_data.getheaders(),
331
- raw_data=response_data.data,
332
- )
333
-
334
- def sanitize_for_serialization(self, obj):
335
- """Builds a JSON POST object.
336
-
337
- If obj is None, return None.
338
- If obj is SecretStr, return obj.get_secret_value()
339
- If obj is str, int, long, float, bool, return directly.
340
- If obj is datetime.datetime, datetime.date
341
- convert to string in iso8601 format.
342
- If obj is decimal.Decimal return string representation.
343
- If obj is list, sanitize each element in the list.
344
- If obj is dict, return the dict.
345
- If obj is OpenAPI model, return the properties dict.
346
-
347
- :param obj: The data to serialize.
348
- :return: The serialized form of data.
349
- """
350
- if obj is None:
351
- return None
352
- elif isinstance(obj, Enum):
353
- return obj.value
354
- elif isinstance(obj, SecretStr):
355
- return obj.get_secret_value()
356
- elif isinstance(obj, self.PRIMITIVE_TYPES):
357
- return obj
358
- elif isinstance(obj, list):
359
- return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
360
- elif isinstance(obj, tuple):
361
- return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj)
362
- elif isinstance(obj, (datetime.datetime, datetime.date)):
363
- return obj.isoformat()
364
- elif isinstance(obj, decimal.Decimal):
365
- return str(obj)
366
-
367
- elif isinstance(obj, dict):
368
- obj_dict = obj
369
- else:
370
- # Convert model obj to dict except
371
- # attributes `openapi_types`, `attribute_map`
372
- # and attributes which value is not None.
373
- # Convert attribute name to json key in
374
- # model definition for request.
375
- if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")):
376
- obj_dict = obj.to_dict()
377
- else:
378
- obj_dict = obj.__dict__
379
-
380
- return {
381
- key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()
382
- }
383
-
384
- def deserialize(
385
- self, response_text: str, response_type: str, content_type: Optional[str]
386
- ):
387
- """Deserializes response into an object.
388
-
389
- :param response: RESTResponse object to be deserialized.
390
- :param response_type: class literal for
391
- deserialized object, or string of class name.
392
- :param content_type: content type of response.
393
-
394
- :return: deserialized object.
395
- """
396
-
397
- # fetch data from response object
398
- if content_type is None:
399
- try:
400
- data = json.loads(response_text)
401
- except ValueError:
402
- data = response_text
403
- elif re.match(
404
- r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)",
405
- content_type,
406
- re.IGNORECASE,
407
- ):
408
- if response_text == "":
409
- data = ""
410
- else:
411
- data = json.loads(response_text)
412
- elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
413
- data = response_text
414
- else:
415
- raise ApiException(
416
- status=0, reason="Unsupported content type: {0}".format(content_type)
417
- )
418
-
419
- return self.__deserialize(data, response_type)
420
-
421
- def __deserialize(self, data, klass):
422
- """Deserializes dict, list, str into an object.
423
-
424
- :param data: dict, list or str.
425
- :param klass: class literal, or string of class name.
426
-
427
- :return: object.
428
- """
429
- if data is None:
430
- return None
431
-
432
- if isinstance(klass, str):
433
- if klass.startswith("List["):
434
- m = re.match(r"List\[(.*)]", klass)
435
- assert m is not None, "Malformed List type definition"
436
- sub_kls = m.group(1)
437
- return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
438
-
439
- if klass.startswith("Dict["):
440
- m = re.match(r"Dict\[([^,]*), (.*)]", klass)
441
- assert m is not None, "Malformed Dict type definition"
442
- sub_kls = m.group(2)
443
- return {k: self.__deserialize(v, sub_kls) for k, v in data.items()}
444
-
445
- # convert str to class
446
- if klass in self.NATIVE_TYPES_MAPPING:
447
- klass = self.NATIVE_TYPES_MAPPING[klass]
448
- else:
449
- klass = getattr(hatchet_sdk.clients.rest.models, klass)
450
-
451
- if klass in self.PRIMITIVE_TYPES:
452
- return self.__deserialize_primitive(data, klass)
453
- elif klass == object:
454
- return self.__deserialize_object(data)
455
- elif klass == datetime.date:
456
- return self.__deserialize_date(data)
457
- elif klass == datetime.datetime:
458
- return self.__deserialize_datetime(data)
459
- elif klass == decimal.Decimal:
460
- return decimal.Decimal(data)
461
- elif issubclass(klass, Enum):
462
- return self.__deserialize_enum(data, klass)
463
- else:
464
- return self.__deserialize_model(data, klass)
465
-
466
- def parameters_to_tuples(self, params, collection_formats):
467
- """Get parameters as list of tuples, formatting collections.
468
-
469
- :param params: Parameters as dict or list of two-tuples
470
- :param dict collection_formats: Parameter collection formats
471
- :return: Parameters as list of tuples, collections formatted
472
- """
473
- new_params: List[Tuple[str, str]] = []
474
- if collection_formats is None:
475
- collection_formats = {}
476
- for k, v in params.items() if isinstance(params, dict) else params:
477
- if k in collection_formats:
478
- collection_format = collection_formats[k]
479
- if collection_format == "multi":
480
- new_params.extend((k, value) for value in v)
481
- else:
482
- if collection_format == "ssv":
483
- delimiter = " "
484
- elif collection_format == "tsv":
485
- delimiter = "\t"
486
- elif collection_format == "pipes":
487
- delimiter = "|"
488
- else: # csv is the default
489
- delimiter = ","
490
- new_params.append((k, delimiter.join(str(value) for value in v)))
491
- else:
492
- new_params.append((k, v))
493
- return new_params
494
-
495
- def parameters_to_url_query(self, params, collection_formats):
496
- """Get parameters as list of tuples, formatting collections.
497
-
498
- :param params: Parameters as dict or list of two-tuples
499
- :param dict collection_formats: Parameter collection formats
500
- :return: URL query string (e.g. a=Hello%20World&b=123)
501
- """
502
- new_params: List[Tuple[str, str]] = []
503
- if collection_formats is None:
504
- collection_formats = {}
505
- for k, v in params.items() if isinstance(params, dict) else params:
506
- if isinstance(v, bool):
507
- v = str(v).lower()
508
- if isinstance(v, (int, float)):
509
- v = str(v)
510
- if isinstance(v, dict):
511
- v = json.dumps(v)
512
-
513
- if k in collection_formats:
514
- collection_format = collection_formats[k]
515
- if collection_format == "multi":
516
- new_params.extend((k, str(value)) for value in v)
517
- else:
518
- if collection_format == "ssv":
519
- delimiter = " "
520
- elif collection_format == "tsv":
521
- delimiter = "\t"
522
- elif collection_format == "pipes":
523
- delimiter = "|"
524
- else: # csv is the default
525
- delimiter = ","
526
- new_params.append(
527
- (k, delimiter.join(quote(str(value)) for value in v))
528
- )
529
- else:
530
- new_params.append((k, quote(str(v))))
531
-
532
- return "&".join(["=".join(map(str, item)) for item in new_params])
533
-
534
- def files_parameters(
535
- self,
536
- files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]],
537
- ):
538
- """Builds form parameters.
539
-
540
- :param files: File parameters.
541
- :return: Form parameters with files.
542
- """
543
- params = []
544
- for k, v in files.items():
545
- if isinstance(v, str):
546
- with open(v, "rb") as f:
547
- filename = os.path.basename(f.name)
548
- filedata = f.read()
549
- elif isinstance(v, bytes):
550
- filename = k
551
- filedata = v
552
- elif isinstance(v, tuple):
553
- filename, filedata = v
554
- elif isinstance(v, list):
555
- for file_param in v:
556
- params.extend(self.files_parameters({k: file_param}))
557
- continue
558
- else:
559
- raise ValueError("Unsupported file value")
560
- mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"
561
- params.append(tuple([k, tuple([filename, filedata, mimetype])]))
562
- return params
563
-
564
- def select_header_accept(self, accepts: List[str]) -> Optional[str]:
565
- """Returns `Accept` based on an array of accepts provided.
566
-
567
- :param accepts: List of headers.
568
- :return: Accept (e.g. application/json).
569
- """
570
- if not accepts:
571
- return None
572
-
573
- for accept in accepts:
574
- if re.search("json", accept, re.IGNORECASE):
575
- return accept
576
-
577
- return accepts[0]
578
-
579
- def select_header_content_type(self, content_types):
580
- """Returns `Content-Type` based on an array of content_types provided.
581
-
582
- :param content_types: List of content-types.
583
- :return: Content-Type (e.g. application/json).
584
- """
585
- if not content_types:
586
- return None
587
-
588
- for content_type in content_types:
589
- if re.search("json", content_type, re.IGNORECASE):
590
- return content_type
591
-
592
- return content_types[0]
593
-
594
- def update_params_for_auth(
595
- self,
596
- headers,
597
- queries,
598
- auth_settings,
599
- resource_path,
600
- method,
601
- body,
602
- request_auth=None,
603
- ) -> None:
604
- """Updates header and query params based on authentication setting.
605
-
606
- :param headers: Header parameters dict to be updated.
607
- :param queries: Query parameters tuple list to be updated.
608
- :param auth_settings: Authentication setting identifiers list.
609
- :resource_path: A string representation of the HTTP request resource path.
610
- :method: A string representation of the HTTP request method.
611
- :body: A object representing the body of the HTTP request.
612
- The object type is the return value of sanitize_for_serialization().
613
- :param request_auth: if set, the provided settings will
614
- override the token in the configuration.
615
- """
616
- if not auth_settings:
617
- return
618
-
619
- if request_auth:
620
- self._apply_auth_params(
621
- headers, queries, resource_path, method, body, request_auth
622
- )
623
- else:
624
- for auth in auth_settings:
625
- auth_setting = self.configuration.auth_settings().get(auth)
626
- if auth_setting:
627
- self._apply_auth_params(
628
- headers, queries, resource_path, method, body, auth_setting
629
- )
630
-
631
- def _apply_auth_params(
632
- self, headers, queries, resource_path, method, body, auth_setting
633
- ) -> None:
634
- """Updates the request parameters based on a single auth_setting
635
-
636
- :param headers: Header parameters dict to be updated.
637
- :param queries: Query parameters tuple list to be updated.
638
- :resource_path: A string representation of the HTTP request resource path.
639
- :method: A string representation of the HTTP request method.
640
- :body: A object representing the body of the HTTP request.
641
- The object type is the return value of sanitize_for_serialization().
642
- :param auth_setting: auth settings for the endpoint
643
- """
644
- if auth_setting["in"] == "cookie":
645
- headers["Cookie"] = auth_setting["value"]
646
- elif auth_setting["in"] == "header":
647
- if auth_setting["type"] != "http-signature":
648
- headers[auth_setting["key"]] = auth_setting["value"]
649
- elif auth_setting["in"] == "query":
650
- queries.append((auth_setting["key"], auth_setting["value"]))
651
- else:
652
- raise ApiValueError("Authentication token must be in `query` or `header`")
653
-
654
- def __deserialize_file(self, response):
655
- """Deserializes body to file
656
-
657
- Saves response body into a file in a temporary folder,
658
- using the filename from the `Content-Disposition` header if provided.
659
-
660
- handle file downloading
661
- save response body into a tmp file and return the instance
662
-
663
- :param response: RESTResponse.
664
- :return: file path.
665
- """
666
- fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
667
- os.close(fd)
668
- os.remove(path)
669
-
670
- content_disposition = response.getheader("Content-Disposition")
671
- if content_disposition:
672
- m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition)
673
- assert m is not None, "Unexpected 'content-disposition' header value"
674
- filename = m.group(1)
675
- path = os.path.join(os.path.dirname(path), filename)
676
-
677
- with open(path, "wb") as f:
678
- f.write(response.data)
679
-
680
- return path
681
-
682
- def __deserialize_primitive(self, data, klass):
683
- """Deserializes string to primitive type.
684
-
685
- :param data: str.
686
- :param klass: class literal.
687
-
688
- :return: int, long, float, str, bool.
689
- """
690
- try:
691
- return klass(data)
692
- except UnicodeEncodeError:
693
- return str(data)
694
- except TypeError:
695
- return data
696
-
697
- def __deserialize_object(self, value):
698
- """Return an original value.
699
-
700
- :return: object.
701
- """
702
- return value
703
-
704
- def __deserialize_date(self, string):
705
- """Deserializes string to date.
706
-
707
- :param string: str.
708
- :return: date.
709
- """
710
- try:
711
- return parse(string).date()
712
- except ImportError:
713
- return string
714
- except ValueError:
715
- raise rest.ApiException(
716
- status=0, reason="Failed to parse `{0}` as date object".format(string)
717
- )
718
-
719
- def __deserialize_datetime(self, string):
720
- """Deserializes string to datetime.
721
-
722
- The string should be in iso8601 datetime format.
723
-
724
- :param string: str.
725
- :return: datetime.
726
- """
727
- try:
728
- return parse(string)
729
- except ImportError:
730
- return string
731
- except ValueError:
732
- raise rest.ApiException(
733
- status=0,
734
- reason=("Failed to parse `{0}` as datetime object".format(string)),
735
- )
736
-
737
- def __deserialize_enum(self, data, klass):
738
- """Deserializes primitive type to enum.
739
-
740
- :param data: primitive type.
741
- :param klass: class literal.
742
- :return: enum value.
743
- """
744
- try:
745
- return klass(data)
746
- except ValueError:
747
- raise rest.ApiException(
748
- status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass))
749
- )
750
-
751
- def __deserialize_model(self, data, klass):
752
- """Deserializes list or dict to model.
753
-
754
- :param data: dict, list.
755
- :param klass: class literal.
756
- :return: model object.
757
- """
758
-
759
- return klass.from_dict(data)