hatchet-sdk 1.9.0__py3-none-any.whl → 1.10.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 (42) hide show
  1. hatchet_sdk/client.py +2 -0
  2. hatchet_sdk/clients/admin.py +2 -6
  3. hatchet_sdk/clients/dispatcher/action_listener.py +20 -1
  4. hatchet_sdk/clients/events.py +58 -8
  5. hatchet_sdk/clients/rest/__init__.py +11 -0
  6. hatchet_sdk/clients/rest/api/__init__.py +1 -0
  7. hatchet_sdk/clients/rest/api/event_api.py +335 -0
  8. hatchet_sdk/clients/rest/api/filter_api.py +1305 -0
  9. hatchet_sdk/clients/rest/api/task_api.py +51 -0
  10. hatchet_sdk/clients/rest/api/workflow_runs_api.py +34 -0
  11. hatchet_sdk/clients/rest/models/__init__.py +10 -0
  12. hatchet_sdk/clients/rest/models/create_event_request.py +16 -2
  13. hatchet_sdk/clients/rest/models/v1_create_filter_request.py +99 -0
  14. hatchet_sdk/clients/rest/models/v1_event.py +142 -0
  15. hatchet_sdk/clients/rest/models/v1_event_list.py +110 -0
  16. hatchet_sdk/clients/rest/models/v1_event_workflow_run_summary.py +101 -0
  17. hatchet_sdk/clients/rest/models/v1_filter.py +127 -0
  18. hatchet_sdk/clients/rest/models/v1_filter_list.py +110 -0
  19. hatchet_sdk/clients/rest/models/v1_log_line.py +21 -2
  20. hatchet_sdk/clients/rest/models/v1_task_event.py +12 -0
  21. hatchet_sdk/clients/rest/models/v1_task_summary.py +12 -0
  22. hatchet_sdk/clients/rest/models/v1_task_timing.py +19 -0
  23. hatchet_sdk/clients/rest/models/workflow.py +5 -0
  24. hatchet_sdk/config.py +29 -0
  25. hatchet_sdk/context/context.py +9 -0
  26. hatchet_sdk/contracts/dispatcher_pb2.py +56 -56
  27. hatchet_sdk/contracts/dispatcher_pb2.pyi +6 -2
  28. hatchet_sdk/contracts/events_pb2.py +20 -20
  29. hatchet_sdk/contracts/events_pb2.pyi +14 -6
  30. hatchet_sdk/features/cron.py +1 -1
  31. hatchet_sdk/features/filters.py +181 -0
  32. hatchet_sdk/features/runs.py +7 -1
  33. hatchet_sdk/features/scheduled.py +1 -1
  34. hatchet_sdk/features/workflows.py +1 -1
  35. hatchet_sdk/hatchet.py +82 -71
  36. hatchet_sdk/runnables/standalone.py +6 -0
  37. hatchet_sdk/runnables/workflow.py +29 -2
  38. hatchet_sdk/worker/worker.py +1 -1
  39. {hatchet_sdk-1.9.0.dist-info → hatchet_sdk-1.10.0.dist-info}/METADATA +1 -1
  40. {hatchet_sdk-1.9.0.dist-info → hatchet_sdk-1.10.0.dist-info}/RECORD +42 -34
  41. {hatchet_sdk-1.9.0.dist-info → hatchet_sdk-1.10.0.dist-info}/WHEEL +0 -0
  42. {hatchet_sdk-1.9.0.dist-info → hatchet_sdk-1.10.0.dist-info}/entry_points.txt +0 -0
@@ -954,6 +954,9 @@ class TaskApi:
954
954
  str,
955
955
  Field(min_length=36, strict=True, max_length=36, description="The task id"),
956
956
  ],
957
+ attempt: Annotated[
958
+ Optional[StrictInt], Field(description="The attempt number")
959
+ ] = None,
957
960
  _request_timeout: Union[
958
961
  None,
959
962
  Annotated[StrictFloat, Field(gt=0)],
@@ -972,6 +975,8 @@ class TaskApi:
972
975
 
973
976
  :param task: The task id (required)
974
977
  :type task: str
978
+ :param attempt: The attempt number
979
+ :type attempt: int
975
980
  :param _request_timeout: timeout setting for this request. If one
976
981
  number provided, it will be total request
977
982
  timeout. It can also be a pair (tuple) of
@@ -996,6 +1001,7 @@ class TaskApi:
996
1001
 
997
1002
  _param = self._v1_task_get_serialize(
998
1003
  task=task,
1004
+ attempt=attempt,
999
1005
  _request_auth=_request_auth,
1000
1006
  _content_type=_content_type,
1001
1007
  _headers=_headers,
@@ -1025,6 +1031,9 @@ class TaskApi:
1025
1031
  str,
1026
1032
  Field(min_length=36, strict=True, max_length=36, description="The task id"),
1027
1033
  ],
1034
+ attempt: Annotated[
1035
+ Optional[StrictInt], Field(description="The attempt number")
1036
+ ] = None,
1028
1037
  _request_timeout: Union[
1029
1038
  None,
1030
1039
  Annotated[StrictFloat, Field(gt=0)],
@@ -1043,6 +1052,8 @@ class TaskApi:
1043
1052
 
1044
1053
  :param task: The task id (required)
1045
1054
  :type task: str
1055
+ :param attempt: The attempt number
1056
+ :type attempt: int
1046
1057
  :param _request_timeout: timeout setting for this request. If one
1047
1058
  number provided, it will be total request
1048
1059
  timeout. It can also be a pair (tuple) of
@@ -1067,6 +1078,7 @@ class TaskApi:
1067
1078
 
1068
1079
  _param = self._v1_task_get_serialize(
1069
1080
  task=task,
1081
+ attempt=attempt,
1070
1082
  _request_auth=_request_auth,
1071
1083
  _content_type=_content_type,
1072
1084
  _headers=_headers,
@@ -1096,6 +1108,9 @@ class TaskApi:
1096
1108
  str,
1097
1109
  Field(min_length=36, strict=True, max_length=36, description="The task id"),
1098
1110
  ],
1111
+ attempt: Annotated[
1112
+ Optional[StrictInt], Field(description="The attempt number")
1113
+ ] = None,
1099
1114
  _request_timeout: Union[
1100
1115
  None,
1101
1116
  Annotated[StrictFloat, Field(gt=0)],
@@ -1114,6 +1129,8 @@ class TaskApi:
1114
1129
 
1115
1130
  :param task: The task id (required)
1116
1131
  :type task: str
1132
+ :param attempt: The attempt number
1133
+ :type attempt: int
1117
1134
  :param _request_timeout: timeout setting for this request. If one
1118
1135
  number provided, it will be total request
1119
1136
  timeout. It can also be a pair (tuple) of
@@ -1138,6 +1155,7 @@ class TaskApi:
1138
1155
 
1139
1156
  _param = self._v1_task_get_serialize(
1140
1157
  task=task,
1158
+ attempt=attempt,
1141
1159
  _request_auth=_request_auth,
1142
1160
  _content_type=_content_type,
1143
1161
  _headers=_headers,
@@ -1159,6 +1177,7 @@ class TaskApi:
1159
1177
  def _v1_task_get_serialize(
1160
1178
  self,
1161
1179
  task,
1180
+ attempt,
1162
1181
  _request_auth,
1163
1182
  _content_type,
1164
1183
  _headers,
@@ -1182,6 +1201,10 @@ class TaskApi:
1182
1201
  if task is not None:
1183
1202
  _path_params["task"] = task
1184
1203
  # process the query parameters
1204
+ if attempt is not None:
1205
+
1206
+ _query_params.append(("attempt", attempt))
1207
+
1185
1208
  # process the header parameters
1186
1209
  # process the form parameters
1187
1210
  # process the body parameter
@@ -1568,6 +1591,10 @@ class TaskApi:
1568
1591
  Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1569
1592
  Field(description="The parent task's external id"),
1570
1593
  ] = None,
1594
+ triggering_event_external_id: Annotated[
1595
+ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1596
+ Field(description="The id of the event that triggered the task"),
1597
+ ] = None,
1571
1598
  _request_timeout: Union[
1572
1599
  None,
1573
1600
  Annotated[StrictFloat, Field(gt=0)],
@@ -1594,6 +1621,8 @@ class TaskApi:
1594
1621
  :type workflow_ids: List[str]
1595
1622
  :param parent_task_external_id: The parent task's external id
1596
1623
  :type parent_task_external_id: str
1624
+ :param triggering_event_external_id: The id of the event that triggered the task
1625
+ :type triggering_event_external_id: str
1597
1626
  :param _request_timeout: timeout setting for this request. If one
1598
1627
  number provided, it will be total request
1599
1628
  timeout. It can also be a pair (tuple) of
@@ -1622,6 +1651,7 @@ class TaskApi:
1622
1651
  until=until,
1623
1652
  workflow_ids=workflow_ids,
1624
1653
  parent_task_external_id=parent_task_external_id,
1654
+ triggering_event_external_id=triggering_event_external_id,
1625
1655
  _request_auth=_request_auth,
1626
1656
  _content_type=_content_type,
1627
1657
  _headers=_headers,
@@ -1668,6 +1698,10 @@ class TaskApi:
1668
1698
  Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1669
1699
  Field(description="The parent task's external id"),
1670
1700
  ] = None,
1701
+ triggering_event_external_id: Annotated[
1702
+ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1703
+ Field(description="The id of the event that triggered the task"),
1704
+ ] = None,
1671
1705
  _request_timeout: Union[
1672
1706
  None,
1673
1707
  Annotated[StrictFloat, Field(gt=0)],
@@ -1694,6 +1728,8 @@ class TaskApi:
1694
1728
  :type workflow_ids: List[str]
1695
1729
  :param parent_task_external_id: The parent task's external id
1696
1730
  :type parent_task_external_id: str
1731
+ :param triggering_event_external_id: The id of the event that triggered the task
1732
+ :type triggering_event_external_id: str
1697
1733
  :param _request_timeout: timeout setting for this request. If one
1698
1734
  number provided, it will be total request
1699
1735
  timeout. It can also be a pair (tuple) of
@@ -1722,6 +1758,7 @@ class TaskApi:
1722
1758
  until=until,
1723
1759
  workflow_ids=workflow_ids,
1724
1760
  parent_task_external_id=parent_task_external_id,
1761
+ triggering_event_external_id=triggering_event_external_id,
1725
1762
  _request_auth=_request_auth,
1726
1763
  _content_type=_content_type,
1727
1764
  _headers=_headers,
@@ -1768,6 +1805,10 @@ class TaskApi:
1768
1805
  Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1769
1806
  Field(description="The parent task's external id"),
1770
1807
  ] = None,
1808
+ triggering_event_external_id: Annotated[
1809
+ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1810
+ Field(description="The id of the event that triggered the task"),
1811
+ ] = None,
1771
1812
  _request_timeout: Union[
1772
1813
  None,
1773
1814
  Annotated[StrictFloat, Field(gt=0)],
@@ -1794,6 +1835,8 @@ class TaskApi:
1794
1835
  :type workflow_ids: List[str]
1795
1836
  :param parent_task_external_id: The parent task's external id
1796
1837
  :type parent_task_external_id: str
1838
+ :param triggering_event_external_id: The id of the event that triggered the task
1839
+ :type triggering_event_external_id: str
1797
1840
  :param _request_timeout: timeout setting for this request. If one
1798
1841
  number provided, it will be total request
1799
1842
  timeout. It can also be a pair (tuple) of
@@ -1822,6 +1865,7 @@ class TaskApi:
1822
1865
  until=until,
1823
1866
  workflow_ids=workflow_ids,
1824
1867
  parent_task_external_id=parent_task_external_id,
1868
+ triggering_event_external_id=triggering_event_external_id,
1825
1869
  _request_auth=_request_auth,
1826
1870
  _content_type=_content_type,
1827
1871
  _headers=_headers,
@@ -1846,6 +1890,7 @@ class TaskApi:
1846
1890
  until,
1847
1891
  workflow_ids,
1848
1892
  parent_task_external_id,
1893
+ triggering_event_external_id,
1849
1894
  _request_auth,
1850
1895
  _content_type,
1851
1896
  _headers,
@@ -1901,6 +1946,12 @@ class TaskApi:
1901
1946
 
1902
1947
  _query_params.append(("parent_task_external_id", parent_task_external_id))
1903
1948
 
1949
+ if triggering_event_external_id is not None:
1950
+
1951
+ _query_params.append(
1952
+ ("triggering_event_external_id", triggering_event_external_id)
1953
+ )
1954
+
1904
1955
  # process the header parameters
1905
1956
  # process the form parameters
1906
1957
  # process the body parameter
@@ -1258,6 +1258,12 @@ class WorkflowRunsApi:
1258
1258
  Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1259
1259
  Field(description="The parent task external id to filter by"),
1260
1260
  ] = None,
1261
+ triggering_event_external_id: Annotated[
1262
+ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1263
+ Field(
1264
+ description="The external id of the event that triggered the workflow run"
1265
+ ),
1266
+ ] = None,
1261
1267
  _request_timeout: Union[
1262
1268
  None,
1263
1269
  Annotated[StrictFloat, Field(gt=0)],
@@ -1296,6 +1302,8 @@ class WorkflowRunsApi:
1296
1302
  :type worker_id: str
1297
1303
  :param parent_task_external_id: The parent task external id to filter by
1298
1304
  :type parent_task_external_id: str
1305
+ :param triggering_event_external_id: The external id of the event that triggered the workflow run
1306
+ :type triggering_event_external_id: str
1299
1307
  :param _request_timeout: timeout setting for this request. If one
1300
1308
  number provided, it will be total request
1301
1309
  timeout. It can also be a pair (tuple) of
@@ -1330,6 +1338,7 @@ class WorkflowRunsApi:
1330
1338
  workflow_ids=workflow_ids,
1331
1339
  worker_id=worker_id,
1332
1340
  parent_task_external_id=parent_task_external_id,
1341
+ triggering_event_external_id=triggering_event_external_id,
1333
1342
  _request_auth=_request_auth,
1334
1343
  _content_type=_content_type,
1335
1344
  _headers=_headers,
@@ -1396,6 +1405,12 @@ class WorkflowRunsApi:
1396
1405
  Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1397
1406
  Field(description="The parent task external id to filter by"),
1398
1407
  ] = None,
1408
+ triggering_event_external_id: Annotated[
1409
+ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1410
+ Field(
1411
+ description="The external id of the event that triggered the workflow run"
1412
+ ),
1413
+ ] = None,
1399
1414
  _request_timeout: Union[
1400
1415
  None,
1401
1416
  Annotated[StrictFloat, Field(gt=0)],
@@ -1434,6 +1449,8 @@ class WorkflowRunsApi:
1434
1449
  :type worker_id: str
1435
1450
  :param parent_task_external_id: The parent task external id to filter by
1436
1451
  :type parent_task_external_id: str
1452
+ :param triggering_event_external_id: The external id of the event that triggered the workflow run
1453
+ :type triggering_event_external_id: str
1437
1454
  :param _request_timeout: timeout setting for this request. If one
1438
1455
  number provided, it will be total request
1439
1456
  timeout. It can also be a pair (tuple) of
@@ -1468,6 +1485,7 @@ class WorkflowRunsApi:
1468
1485
  workflow_ids=workflow_ids,
1469
1486
  worker_id=worker_id,
1470
1487
  parent_task_external_id=parent_task_external_id,
1488
+ triggering_event_external_id=triggering_event_external_id,
1471
1489
  _request_auth=_request_auth,
1472
1490
  _content_type=_content_type,
1473
1491
  _headers=_headers,
@@ -1534,6 +1552,12 @@ class WorkflowRunsApi:
1534
1552
  Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1535
1553
  Field(description="The parent task external id to filter by"),
1536
1554
  ] = None,
1555
+ triggering_event_external_id: Annotated[
1556
+ Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]],
1557
+ Field(
1558
+ description="The external id of the event that triggered the workflow run"
1559
+ ),
1560
+ ] = None,
1537
1561
  _request_timeout: Union[
1538
1562
  None,
1539
1563
  Annotated[StrictFloat, Field(gt=0)],
@@ -1572,6 +1596,8 @@ class WorkflowRunsApi:
1572
1596
  :type worker_id: str
1573
1597
  :param parent_task_external_id: The parent task external id to filter by
1574
1598
  :type parent_task_external_id: str
1599
+ :param triggering_event_external_id: The external id of the event that triggered the workflow run
1600
+ :type triggering_event_external_id: str
1575
1601
  :param _request_timeout: timeout setting for this request. If one
1576
1602
  number provided, it will be total request
1577
1603
  timeout. It can also be a pair (tuple) of
@@ -1606,6 +1632,7 @@ class WorkflowRunsApi:
1606
1632
  workflow_ids=workflow_ids,
1607
1633
  worker_id=worker_id,
1608
1634
  parent_task_external_id=parent_task_external_id,
1635
+ triggering_event_external_id=triggering_event_external_id,
1609
1636
  _request_auth=_request_auth,
1610
1637
  _content_type=_content_type,
1611
1638
  _headers=_headers,
@@ -1636,6 +1663,7 @@ class WorkflowRunsApi:
1636
1663
  workflow_ids,
1637
1664
  worker_id,
1638
1665
  parent_task_external_id,
1666
+ triggering_event_external_id,
1639
1667
  _request_auth,
1640
1668
  _content_type,
1641
1669
  _headers,
@@ -1717,6 +1745,12 @@ class WorkflowRunsApi:
1717
1745
 
1718
1746
  _query_params.append(("parent_task_external_id", parent_task_external_id))
1719
1747
 
1748
+ if triggering_event_external_id is not None:
1749
+
1750
+ _query_params.append(
1751
+ ("triggering_event_external_id", triggering_event_external_id)
1752
+ )
1753
+
1720
1754
  # process the header parameters
1721
1755
  # process the form parameters
1722
1756
  # process the body parameter
@@ -194,7 +194,17 @@ from hatchet_sdk.clients.rest.models.user_tenant_memberships_list import (
194
194
  )
195
195
  from hatchet_sdk.clients.rest.models.user_tenant_public import UserTenantPublic
196
196
  from hatchet_sdk.clients.rest.models.v1_cancel_task_request import V1CancelTaskRequest
197
+ from hatchet_sdk.clients.rest.models.v1_create_filter_request import (
198
+ V1CreateFilterRequest,
199
+ )
197
200
  from hatchet_sdk.clients.rest.models.v1_dag_children import V1DagChildren
201
+ from hatchet_sdk.clients.rest.models.v1_event import V1Event
202
+ from hatchet_sdk.clients.rest.models.v1_event_list import V1EventList
203
+ from hatchet_sdk.clients.rest.models.v1_event_workflow_run_summary import (
204
+ V1EventWorkflowRunSummary,
205
+ )
206
+ from hatchet_sdk.clients.rest.models.v1_filter import V1Filter
207
+ from hatchet_sdk.clients.rest.models.v1_filter_list import V1FilterList
198
208
  from hatchet_sdk.clients.rest.models.v1_log_line import V1LogLine
199
209
  from hatchet_sdk.clients.rest.models.v1_log_line_level import V1LogLineLevel
200
210
  from hatchet_sdk.clients.rest.models.v1_log_line_list import V1LogLineList
@@ -19,7 +19,7 @@ import pprint
19
19
  import re # noqa: F401
20
20
  from typing import Any, ClassVar, Dict, List, Optional, Set
21
21
 
22
- from pydantic import BaseModel, ConfigDict, Field, StrictStr
22
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
23
23
  from typing_extensions import Self
24
24
 
25
25
 
@@ -35,7 +35,19 @@ class CreateEventRequest(BaseModel):
35
35
  description="Additional metadata for the event.",
36
36
  alias="additionalMetadata",
37
37
  )
38
- __properties: ClassVar[List[str]] = ["key", "data", "additionalMetadata"]
38
+ priority: Optional[StrictInt] = Field(
39
+ default=None, description="The priority of the event."
40
+ )
41
+ scope: Optional[StrictStr] = Field(
42
+ default=None, description="The scope for event filtering."
43
+ )
44
+ __properties: ClassVar[List[str]] = [
45
+ "key",
46
+ "data",
47
+ "additionalMetadata",
48
+ "priority",
49
+ "scope",
50
+ ]
39
51
 
40
52
  model_config = ConfigDict(
41
53
  populate_by_name=True,
@@ -90,6 +102,8 @@ class CreateEventRequest(BaseModel):
90
102
  "key": obj.get("key"),
91
103
  "data": obj.get("data"),
92
104
  "additionalMetadata": obj.get("additionalMetadata"),
105
+ "priority": obj.get("priority"),
106
+ "scope": obj.get("scope"),
93
107
  }
94
108
  )
95
109
  return _obj
@@ -0,0 +1,99 @@
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
+ from __future__ import annotations
16
+
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from typing import Any, ClassVar, Dict, List, Optional, Set
21
+
22
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
23
+ from typing_extensions import Annotated, Self
24
+
25
+
26
+ class V1CreateFilterRequest(BaseModel):
27
+ """
28
+ V1CreateFilterRequest
29
+ """ # noqa: E501
30
+
31
+ workflow_id: Annotated[str, Field(min_length=36, strict=True, max_length=36)] = (
32
+ Field(description="The workflow id", alias="workflowId")
33
+ )
34
+ expression: StrictStr = Field(description="The expression for the filter")
35
+ scope: StrictStr = Field(
36
+ description="The scope associated with this filter. Used for subsetting candidate filters at evaluation time"
37
+ )
38
+ payload: Optional[Dict[str, Any]] = Field(
39
+ default=None, description="The payload for the filter"
40
+ )
41
+ __properties: ClassVar[List[str]] = ["workflowId", "expression", "scope", "payload"]
42
+
43
+ model_config = ConfigDict(
44
+ populate_by_name=True,
45
+ validate_assignment=True,
46
+ protected_namespaces=(),
47
+ )
48
+
49
+ def to_str(self) -> str:
50
+ """Returns the string representation of the model using alias"""
51
+ return pprint.pformat(self.model_dump(by_alias=True))
52
+
53
+ def to_json(self) -> str:
54
+ """Returns the JSON representation of the model using alias"""
55
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
+ return json.dumps(self.to_dict())
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of V1CreateFilterRequest from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ """
73
+ excluded_fields: Set[str] = set([])
74
+
75
+ _dict = self.model_dump(
76
+ by_alias=True,
77
+ exclude=excluded_fields,
78
+ exclude_none=True,
79
+ )
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of V1CreateFilterRequest from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate(
92
+ {
93
+ "workflowId": obj.get("workflowId"),
94
+ "expression": obj.get("expression"),
95
+ "scope": obj.get("scope"),
96
+ "payload": obj.get("payload"),
97
+ }
98
+ )
99
+ return _obj
@@ -0,0 +1,142 @@
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
+ from __future__ import annotations
16
+
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from typing import Any, ClassVar, Dict, List, Optional, Set
21
+
22
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
23
+ from typing_extensions import Self
24
+
25
+ from hatchet_sdk.clients.rest.models.api_resource_meta import APIResourceMeta
26
+ from hatchet_sdk.clients.rest.models.tenant import Tenant
27
+ from hatchet_sdk.clients.rest.models.v1_event_workflow_run_summary import (
28
+ V1EventWorkflowRunSummary,
29
+ )
30
+
31
+
32
+ class V1Event(BaseModel):
33
+ """
34
+ V1Event
35
+ """ # noqa: E501
36
+
37
+ metadata: APIResourceMeta
38
+ key: StrictStr = Field(description="The key for the event.")
39
+ tenant: Optional[Tenant] = Field(
40
+ default=None, description="The tenant associated with this event."
41
+ )
42
+ tenant_id: StrictStr = Field(
43
+ description="The ID of the tenant associated with this event.", alias="tenantId"
44
+ )
45
+ workflow_run_summary: V1EventWorkflowRunSummary = Field(
46
+ description="The workflow run summary for this event.",
47
+ alias="workflowRunSummary",
48
+ )
49
+ additional_metadata: Optional[Dict[str, Any]] = Field(
50
+ default=None,
51
+ description="Additional metadata for the event.",
52
+ alias="additionalMetadata",
53
+ )
54
+ __properties: ClassVar[List[str]] = [
55
+ "metadata",
56
+ "key",
57
+ "tenant",
58
+ "tenantId",
59
+ "workflowRunSummary",
60
+ "additionalMetadata",
61
+ ]
62
+
63
+ model_config = ConfigDict(
64
+ populate_by_name=True,
65
+ validate_assignment=True,
66
+ protected_namespaces=(),
67
+ )
68
+
69
+ def to_str(self) -> str:
70
+ """Returns the string representation of the model using alias"""
71
+ return pprint.pformat(self.model_dump(by_alias=True))
72
+
73
+ def to_json(self) -> str:
74
+ """Returns the JSON representation of the model using alias"""
75
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
76
+ return json.dumps(self.to_dict())
77
+
78
+ @classmethod
79
+ def from_json(cls, json_str: str) -> Optional[Self]:
80
+ """Create an instance of V1Event from a JSON string"""
81
+ return cls.from_dict(json.loads(json_str))
82
+
83
+ def to_dict(self) -> Dict[str, Any]:
84
+ """Return the dictionary representation of the model using alias.
85
+
86
+ This has the following differences from calling pydantic's
87
+ `self.model_dump(by_alias=True)`:
88
+
89
+ * `None` is only added to the output dict for nullable fields that
90
+ were set at model initialization. Other fields with value `None`
91
+ are ignored.
92
+ """
93
+ excluded_fields: Set[str] = set([])
94
+
95
+ _dict = self.model_dump(
96
+ by_alias=True,
97
+ exclude=excluded_fields,
98
+ exclude_none=True,
99
+ )
100
+ # override the default output from pydantic by calling `to_dict()` of metadata
101
+ if self.metadata:
102
+ _dict["metadata"] = self.metadata.to_dict()
103
+ # override the default output from pydantic by calling `to_dict()` of tenant
104
+ if self.tenant:
105
+ _dict["tenant"] = self.tenant.to_dict()
106
+ # override the default output from pydantic by calling `to_dict()` of workflow_run_summary
107
+ if self.workflow_run_summary:
108
+ _dict["workflowRunSummary"] = self.workflow_run_summary.to_dict()
109
+ return _dict
110
+
111
+ @classmethod
112
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
113
+ """Create an instance of V1Event from a dict"""
114
+ if obj is None:
115
+ return None
116
+
117
+ if not isinstance(obj, dict):
118
+ return cls.model_validate(obj)
119
+
120
+ _obj = cls.model_validate(
121
+ {
122
+ "metadata": (
123
+ APIResourceMeta.from_dict(obj["metadata"])
124
+ if obj.get("metadata") is not None
125
+ else None
126
+ ),
127
+ "key": obj.get("key"),
128
+ "tenant": (
129
+ Tenant.from_dict(obj["tenant"])
130
+ if obj.get("tenant") is not None
131
+ else None
132
+ ),
133
+ "tenantId": obj.get("tenantId"),
134
+ "workflowRunSummary": (
135
+ V1EventWorkflowRunSummary.from_dict(obj["workflowRunSummary"])
136
+ if obj.get("workflowRunSummary") is not None
137
+ else None
138
+ ),
139
+ "additionalMetadata": obj.get("additionalMetadata"),
140
+ }
141
+ )
142
+ return _obj