Skip to content

Commit a35f6c7

Browse files
committed
adding updateTaskInstancesState endpoint
1 parent 08611bd commit a35f6c7

File tree

11 files changed

+481
-9
lines changed

11 files changed

+481
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Apache Airflow management API.
44
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project based on [the specs](https://github.com/zachliu/airflow-openapi-specs):
55

66
- API version: 1.0.0
7-
- Package version: 0.1.6
7+
- Package version: 0.2.6
88
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
99
For more information, please visit [https://github.com/zachliu](https://github.com/zachliu)
1010

@@ -106,6 +106,7 @@ Class | Method | HTTP request | Description
106106
*DAGApi* | [**get_task**](docs/DAGApi.md#get_task) | **GET** /dags/{dag_id}/tasks/{task_id} | Get simplified representation of a task.
107107
*DAGApi* | [**get_tasks**](docs/DAGApi.md#get_tasks) | **GET** /dags/{dag_id}/tasks | Get tasks for DAG
108108
*DAGApi* | [**update_dag**](docs/DAGApi.md#update_dag) | **PATCH** /dags/{dag_id} | Update the specific DAG
109+
*DAGApi* | [**update_task_instances_state**](docs/DAGApi.md#update_task_instances_state) | **POST** /dags/{dag_id}/updateTaskInstancesState | Set a state of task instances
109110
*DAGRunApi* | [**delete_dag_run**](docs/DAGRunApi.md#delete_dag_run) | **DELETE** /dags/{dag_id}/dagRuns/{dag_run_id} | Delete a DAG Run
110111
*DAGRunApi* | [**get_dag_run**](docs/DAGRunApi.md#get_dag_run) | **GET** /dags/{dag_id}/dagRuns/{dag_run_id} | Get a DAG Run
111112
*DAGRunApi* | [**get_dag_runs**](docs/DAGRunApi.md#get_dag_runs) | **GET** /dags/{dag_id}/dagRuns | Get all DAG Runs
@@ -190,6 +191,7 @@ Class | Method | HTTP request | Description
190191
- [TaskState](docs/TaskState.md)
191192
- [TimeDelta](docs/TimeDelta.md)
192193
- [TriggerRule](docs/TriggerRule.md)
194+
- [UpdateTaskInstancesState](docs/UpdateTaskInstancesState.md)
193195
- [Variable](docs/Variable.md)
194196
- [VariableAllOf](docs/VariableAllOf.md)
195197
- [VariableCollection](docs/VariableCollection.md)

airflow_python_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""
1212

1313

14-
__version__ = "0.1.6"
14+
__version__ = "0.2.6"
1515

1616
# import ApiClient
1717
from airflow_python_sdk.api_client import ApiClient

airflow_python_sdk/api/dag_api.py

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from airflow_python_sdk.model.task import Task
3232
from airflow_python_sdk.model.task_collection import TaskCollection
3333
from airflow_python_sdk.model.task_instance_reference_collection import TaskInstanceReferenceCollection
34+
from airflow_python_sdk.model.update_task_instances_state import UpdateTaskInstancesState
3435

3536

3637
class DAGApi(object):
@@ -1021,3 +1022,133 @@ def __update_dag(
10211022
api_client=api_client,
10221023
callable=__update_dag
10231024
)
1025+
1026+
def __update_task_instances_state(
1027+
self,
1028+
dag_id,
1029+
update_task_instances_state,
1030+
**kwargs
1031+
):
1032+
"""Set a state of task instances # noqa: E501
1033+
1034+
Updates the state for multiple task instances simultaneously. # noqa: E501
1035+
This method makes a synchronous HTTP request by default. To make an
1036+
asynchronous HTTP request, please pass async_req=True
1037+
1038+
>>> thread = api.update_task_instances_state(dag_id, update_task_instances_state, async_req=True)
1039+
>>> result = thread.get()
1040+
1041+
Args:
1042+
dag_id (str): The DAG ID.
1043+
update_task_instances_state (UpdateTaskInstancesState): Parameters of action
1044+
1045+
Keyword Args:
1046+
_return_http_data_only (bool): response data without head status
1047+
code and headers. Default is True.
1048+
_preload_content (bool): if False, the urllib3.HTTPResponse object
1049+
will be returned without reading/decoding response data.
1050+
Default is True.
1051+
_request_timeout (float/tuple): timeout setting for this request. If one
1052+
number provided, it will be total request timeout. It can also
1053+
be a pair (tuple) of (connection, read) timeouts.
1054+
Default is None.
1055+
_check_input_type (bool): specifies if type checking
1056+
should be done one the data sent to the server.
1057+
Default is True.
1058+
_check_return_type (bool): specifies if type checking
1059+
should be done one the data received from the server.
1060+
Default is True.
1061+
_host_index (int/None): specifies the index of the server
1062+
that we want to use.
1063+
Default is read from the configuration.
1064+
async_req (bool): execute request asynchronously
1065+
1066+
Returns:
1067+
TaskInstanceReferenceCollection
1068+
If the method is called asynchronously, returns the request
1069+
thread.
1070+
"""
1071+
kwargs['async_req'] = kwargs.get(
1072+
'async_req', False
1073+
)
1074+
kwargs['_return_http_data_only'] = kwargs.get(
1075+
'_return_http_data_only', True
1076+
)
1077+
kwargs['_preload_content'] = kwargs.get(
1078+
'_preload_content', True
1079+
)
1080+
kwargs['_request_timeout'] = kwargs.get(
1081+
'_request_timeout', None
1082+
)
1083+
kwargs['_check_input_type'] = kwargs.get(
1084+
'_check_input_type', True
1085+
)
1086+
kwargs['_check_return_type'] = kwargs.get(
1087+
'_check_return_type', True
1088+
)
1089+
kwargs['_host_index'] = kwargs.get('_host_index')
1090+
kwargs['dag_id'] = \
1091+
dag_id
1092+
kwargs['update_task_instances_state'] = \
1093+
update_task_instances_state
1094+
return self.call_with_http_info(**kwargs)
1095+
1096+
self.update_task_instances_state = Endpoint(
1097+
settings={
1098+
'response_type': (TaskInstanceReferenceCollection,),
1099+
'auth': [
1100+
'basicAuth'
1101+
],
1102+
'endpoint_path': '/dags/{dag_id}/updateTaskInstancesState',
1103+
'operation_id': 'update_task_instances_state',
1104+
'http_method': 'POST',
1105+
'servers': None,
1106+
},
1107+
params_map={
1108+
'all': [
1109+
'dag_id',
1110+
'update_task_instances_state',
1111+
],
1112+
'required': [
1113+
'dag_id',
1114+
'update_task_instances_state',
1115+
],
1116+
'nullable': [
1117+
],
1118+
'enum': [
1119+
],
1120+
'validation': [
1121+
]
1122+
},
1123+
root_map={
1124+
'validations': {
1125+
},
1126+
'allowed_values': {
1127+
},
1128+
'openapi_types': {
1129+
'dag_id':
1130+
(str,),
1131+
'update_task_instances_state':
1132+
(UpdateTaskInstancesState,),
1133+
},
1134+
'attribute_map': {
1135+
'dag_id': 'dag_id',
1136+
},
1137+
'location_map': {
1138+
'dag_id': 'path',
1139+
'update_task_instances_state': 'body',
1140+
},
1141+
'collection_format_map': {
1142+
}
1143+
},
1144+
headers_map={
1145+
'accept': [
1146+
'application/json'
1147+
],
1148+
'content_type': [
1149+
'application/json'
1150+
]
1151+
},
1152+
api_client=api_client,
1153+
callable=__update_task_instances_state
1154+
)

airflow_python_sdk/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7777
self.default_headers[header_name] = header_value
7878
self.cookie = cookie
7979
# Set default User-Agent.
80-
self.user_agent = 'OpenAPI-Generator/0.1.6/python'
80+
self.user_agent = 'OpenAPI-Generator/0.2.6/python'
8181

8282
def __enter__(self):
8383
return self

airflow_python_sdk/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def to_debug_report(self):
400400
"OS: {env}\n"\
401401
"Python Version: {pyversion}\n"\
402402
"Version of the API: 1.0.0\n"\
403-
"SDK Package Version: 0.1.6".\
403+
"SDK Package Version: 0.2.6".\
404404
format(env=sys.platform, pyversion=sys.version)
405405

406406
def get_host_settings(self):
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
"""
2+
Airflow API (Stable)
3+
4+
Apache Airflow management API. # noqa: E501
5+
6+
The version of the OpenAPI document: 1.0.0
7+
8+
Generated by: https://openapi-generator.tech
9+
"""
10+
11+
12+
import re # noqa: F401
13+
import sys # noqa: F401
14+
15+
import nulltype # noqa: F401
16+
17+
from airflow_python_sdk.model_utils import ( # noqa: F401
18+
ApiTypeError,
19+
ModelComposed,
20+
ModelNormal,
21+
ModelSimple,
22+
cached_property,
23+
change_keys_js_to_python,
24+
convert_js_args_to_python_args,
25+
date,
26+
datetime,
27+
file_type,
28+
none_type,
29+
validate_get_composed_info,
30+
)
31+
32+
33+
class UpdateTaskInstancesState(ModelNormal):
34+
"""NOTE: This class is auto generated by OpenAPI Generator.
35+
Ref: https://openapi-generator.tech
36+
37+
Do not edit the class manually.
38+
39+
Attributes:
40+
allowed_values (dict): The key is the tuple path to the attribute
41+
and the for var_name this is (var_name,). The value is a dict
42+
with a capitalized key describing the allowed value and an allowed
43+
value. These dicts store the allowed enum values.
44+
attribute_map (dict): The key is attribute name
45+
and the value is json key in definition.
46+
discriminator_value_class_map (dict): A dict to go from the discriminator
47+
variable value to the discriminator class name.
48+
validations (dict): The key is the tuple path to the attribute
49+
and the for var_name this is (var_name,). The value is a dict
50+
that stores validations for max_length, min_length, max_items,
51+
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
52+
inclusive_minimum, and regex.
53+
additional_properties_type (tuple): A tuple of classes accepted
54+
as additional properties values.
55+
"""
56+
57+
allowed_values = {
58+
('new_state',): {
59+
'SUCCESS': "success",
60+
'FAILED': "failed",
61+
},
62+
}
63+
64+
validations = {
65+
}
66+
67+
additional_properties_type = None
68+
69+
_nullable = False
70+
71+
@cached_property
72+
def openapi_types():
73+
"""
74+
This must be a method because a model may have properties that are
75+
of type self, this must run after the class is loaded
76+
77+
Returns
78+
openapi_types (dict): The key is attribute name
79+
and the value is attribute type.
80+
"""
81+
return {
82+
'dry_run': (bool,), # noqa: E501
83+
'execution_date': (str,), # noqa: E501
84+
'include_downstream': (bool,), # noqa: E501
85+
'include_future': (bool,), # noqa: E501
86+
'include_past': (bool,), # noqa: E501
87+
'include_upstream': (bool,), # noqa: E501
88+
'new_state': (str,), # noqa: E501
89+
'task_id': (str,), # noqa: E501
90+
}
91+
92+
@cached_property
93+
def discriminator():
94+
return None
95+
96+
97+
attribute_map = {
98+
'dry_run': 'dry_run', # noqa: E501
99+
'execution_date': 'execution_date', # noqa: E501
100+
'include_downstream': 'include_downstream', # noqa: E501
101+
'include_future': 'include_future', # noqa: E501
102+
'include_past': 'include_past', # noqa: E501
103+
'include_upstream': 'include_upstream', # noqa: E501
104+
'new_state': 'new_state', # noqa: E501
105+
'task_id': 'task_id', # noqa: E501
106+
}
107+
108+
_composed_schemas = {}
109+
110+
required_properties = set([
111+
'_data_store',
112+
'_check_type',
113+
'_spec_property_naming',
114+
'_path_to_item',
115+
'_configuration',
116+
'_visited_composed_classes',
117+
])
118+
119+
@convert_js_args_to_python_args
120+
def __init__(self, *args, **kwargs): # noqa: E501
121+
"""UpdateTaskInstancesState - a model defined in OpenAPI
122+
123+
Keyword Args:
124+
_check_type (bool): if True, values for parameters in openapi_types
125+
will be type checked and a TypeError will be
126+
raised if the wrong type is input.
127+
Defaults to True
128+
_path_to_item (tuple/list): This is a list of keys or values to
129+
drill down to the model in received_data
130+
when deserializing a response
131+
_spec_property_naming (bool): True if the variable names in the input data
132+
are serialized names, as specified in the OpenAPI document.
133+
False if the variable names in the input data
134+
are pythonic names, e.g. snake case (default)
135+
_configuration (Configuration): the instance to use when
136+
deserializing a file_type parameter.
137+
If passed, type conversion is attempted
138+
If omitted no type conversion is done.
139+
_visited_composed_classes (tuple): This stores a tuple of
140+
classes that we have traveled through so that
141+
if we see that class again we will not use its
142+
discriminator again.
143+
When traveling through a discriminator, the
144+
composed schema that is
145+
is traveled through is added to this set.
146+
For example if Animal has a discriminator
147+
petType and we pass in "Dog", and the class Dog
148+
allOf includes Animal, we move through Animal
149+
once using the discriminator, and pick Dog.
150+
Then in Dog, we will make an instance of the
151+
Animal class but this time we won't travel
152+
through its discriminator because we passed in
153+
_visited_composed_classes = (Animal,)
154+
dry_run (bool): If set, don't actually run this operation. The response will contain a list of task instances planned to be affected, but won't be modified in any way. . [optional] if omitted the server will use the default value of True # noqa: E501
155+
execution_date (str): The execution date.. [optional] # noqa: E501
156+
include_downstream (bool): If set to true, downstream tasks are also affected.. [optional] # noqa: E501
157+
include_future (bool): If set to True, also tasks from future DAG Runs are affected.. [optional] # noqa: E501
158+
include_past (bool): If set to True, also tasks from past DAG Runs are affected.. [optional] # noqa: E501
159+
include_upstream (bool): If set to true, upstream tasks are also affected.. [optional] # noqa: E501
160+
new_state (str): Expected new state.. [optional] # noqa: E501
161+
task_id (str): The task ID.. [optional] # noqa: E501
162+
"""
163+
164+
_check_type = kwargs.pop('_check_type', True)
165+
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
166+
_path_to_item = kwargs.pop('_path_to_item', ())
167+
_configuration = kwargs.pop('_configuration', None)
168+
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
169+
170+
if args:
171+
raise ApiTypeError(
172+
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
173+
args,
174+
self.__class__.__name__,
175+
),
176+
path_to_item=_path_to_item,
177+
valid_classes=(self.__class__,),
178+
)
179+
180+
self._data_store = {}
181+
self._check_type = _check_type
182+
self._spec_property_naming = _spec_property_naming
183+
self._path_to_item = _path_to_item
184+
self._configuration = _configuration
185+
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
186+
187+
for var_name, var_value in kwargs.items():
188+
if var_name not in self.attribute_map and \
189+
self._configuration is not None and \
190+
self._configuration.discard_unknown_keys and \
191+
self.additional_properties_type is None:
192+
# discard variable.
193+
continue
194+
setattr(self, var_name, var_value)

airflow_python_sdk/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from airflow_python_sdk.model.task_state import TaskState
5656
from airflow_python_sdk.model.time_delta import TimeDelta
5757
from airflow_python_sdk.model.trigger_rule import TriggerRule
58+
from airflow_python_sdk.model.update_task_instances_state import UpdateTaskInstancesState
5859
from airflow_python_sdk.model.variable import Variable
5960
from airflow_python_sdk.model.variable_all_of import VariableAllOf
6061
from airflow_python_sdk.model.variable_collection import VariableCollection

0 commit comments

Comments
 (0)