Skip to content

Commit

Permalink
adding trigger_dag_run endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
zachliu committed Feb 2, 2021
1 parent a35f6c7 commit 28382eb
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 14 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Apache Airflow management API.
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):

- API version: 1.0.0
- Package version: 0.2.6
- Package version: 0.3.7
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visit [https://github.com/zachliu](https://github.com/zachliu)

Expand Down Expand Up @@ -110,6 +110,7 @@ Class | Method | HTTP request | Description
*DAGRunApi* | [**delete_dag_run**](docs/DAGRunApi.md#delete_dag_run) | **DELETE** /dags/{dag_id}/dagRuns/{dag_run_id} | Delete a DAG Run
*DAGRunApi* | [**get_dag_run**](docs/DAGRunApi.md#get_dag_run) | **GET** /dags/{dag_id}/dagRuns/{dag_run_id} | Get a DAG Run
*DAGRunApi* | [**get_dag_runs**](docs/DAGRunApi.md#get_dag_runs) | **GET** /dags/{dag_id}/dagRuns | Get all DAG Runs
*DAGRunApi* | [**trigger_dag_run**](docs/DAGRunApi.md#trigger_dag_run) | **POST** /dags/{dag_id}/dagRuns | Trigger a new DAG run
*DAGRunApi* | [**update_dag_run**](docs/DAGRunApi.md#update_dag_run) | **PATCH** /dags/{dag_id}/dagRuns/{dag_run_id} | Update a DAG Run
*EventLogApi* | [**create_event_log**](docs/EventLogApi.md#create_event_log) | **POST** /eventLogs | Create event log
*EventLogApi* | [**delete_event_log_entry**](docs/EventLogApi.md#delete_event_log_entry) | **DELETE** /eventLogs/{event_log_id} | Delete a log entry
Expand All @@ -119,7 +120,7 @@ Class | Method | HTTP request | Description
*ImportErrorApi* | [**delete_import_error**](docs/ImportErrorApi.md#delete_import_error) | **DELETE** /importErrors/{import_error_id} | Delete an import error
*ImportErrorApi* | [**get_import_error**](docs/ImportErrorApi.md#get_import_error) | **GET** /importErrors/{import_error_id} | Get an import errors
*ImportErrorApi* | [**get_import_errors**](docs/ImportErrorApi.md#get_import_errors) | **GET** /importErrors | Get all import errors
*PoolApi* | [**create_pool**](docs/PoolApi.md#create_pool) | **POST** /pools | Create aa pool
*PoolApi* | [**create_pool**](docs/PoolApi.md#create_pool) | **POST** /pools | Create a pool
*PoolApi* | [**delete_pool**](docs/PoolApi.md#delete_pool) | **DELETE** /pools/{pool_id} | Delete a pool
*PoolApi* | [**get_pool**](docs/PoolApi.md#get_pool) | **GET** /pools/{pool_id} | Get a pool
*PoolApi* | [**get_pools**](docs/PoolApi.md#get_pools) | **GET** /pools | Get all pools
Expand Down
165 changes: 165 additions & 0 deletions airflow_python_sdk/api/dag_run_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ def __get_dag_runs(
Keyword Args:
limit (int): The numbers of items to return.. [optional] if omitted the server will use the default value of 100
offset (int): The number of items to skip before starting to collect the result set.. [optional]
execution_date_gte (datetime): The date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), E.G. `2017-07-21T17:32:28Z` . [optional]
execution_date_lte (datetime): The date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), E.G. `2017-07-21T17:32:28Z` . [optional]
start_date_gte (datetime): The date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), E.G. `2017-07-21T17:32:28Z` . [optional]
start_date_lte (datetime): The date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), E.G. `2017-07-21T17:32:28Z` . [optional]
end_date_gte (datetime): The date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), E.G. `2017-07-21T17:32:28Z` . [optional]
end_date_lte (datetime): The date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), E.G. `2017-07-21T17:32:28Z` . [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
Expand Down Expand Up @@ -379,6 +385,12 @@ def __get_dag_runs(
'dag_id',
'limit',
'offset',
'execution_date_gte',
'execution_date_lte',
'start_date_gte',
'start_date_lte',
'end_date_gte',
'end_date_lte',
],
'required': [
'dag_id',
Expand Down Expand Up @@ -412,16 +424,40 @@ def __get_dag_runs(
(int,),
'offset':
(int,),
'execution_date_gte':
(datetime,),
'execution_date_lte':
(datetime,),
'start_date_gte':
(datetime,),
'start_date_lte':
(datetime,),
'end_date_gte':
(datetime,),
'end_date_lte':
(datetime,),
},
'attribute_map': {
'dag_id': 'dag_id',
'limit': 'limit',
'offset': 'offset',
'execution_date_gte': 'execution_date_gte',
'execution_date_lte': 'execution_date_lte',
'start_date_gte': 'start_date_gte',
'start_date_lte': 'start_date_lte',
'end_date_gte': 'end_date_gte',
'end_date_lte': 'end_date_lte',
},
'location_map': {
'dag_id': 'path',
'limit': 'query',
'offset': 'query',
'execution_date_gte': 'query',
'execution_date_lte': 'query',
'start_date_gte': 'query',
'start_date_lte': 'query',
'end_date_gte': 'query',
'end_date_lte': 'query',
},
'collection_format_map': {
}
Expand All @@ -436,6 +472,135 @@ def __get_dag_runs(
callable=__get_dag_runs
)

def __trigger_dag_run(
self,
dag_id,
dag_run,
**kwargs
):
"""Trigger a new DAG run # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.trigger_dag_run(dag_id, dag_run, async_req=True)
>>> result = thread.get()
Args:
dag_id (str): The DAG ID.
dag_run (DAGRun):
Keyword Args:
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
DAGRun
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['dag_id'] = \
dag_id
kwargs['dag_run'] = \
dag_run
return self.call_with_http_info(**kwargs)

self.trigger_dag_run = Endpoint(
settings={
'response_type': (DAGRun,),
'auth': [
'basicAuth'
],
'endpoint_path': '/dags/{dag_id}/dagRuns',
'operation_id': 'trigger_dag_run',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'dag_id',
'dag_run',
],
'required': [
'dag_id',
'dag_run',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'dag_id':
(str,),
'dag_run':
(DAGRun,),
},
'attribute_map': {
'dag_id': 'dag_id',
},
'location_map': {
'dag_id': 'path',
'dag_run': 'body',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [
'application/json'
]
},
api_client=api_client,
callable=__trigger_dag_run
)

def __update_dag_run(
self,
dag_id,
Expand Down
13 changes: 8 additions & 5 deletions airflow_python_sdk/model/dag_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ def openapi_types():
'dag_id': (str,), # noqa: E501
'execution_date': (datetime,), # noqa: E501
'start_date': (datetime,), # noqa: E501
'end_date': (datetime,), # noqa: E501
'end_date': (datetime, none_type,), # noqa: E501
'state': (TaskState,), # noqa: E501
'run_id': (str,), # noqa: E501
'dag_run_id': (str, none_type,), # noqa: E501
'external_trigger': (bool,), # noqa: E501
'conf': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501
}

@cached_property
Expand All @@ -100,8 +101,9 @@ def discriminator():
'start_date': 'start_date', # noqa: E501
'end_date': 'end_date', # noqa: E501
'state': 'state', # noqa: E501
'run_id': 'run_id', # noqa: E501
'dag_run_id': 'dag_run_id', # noqa: E501
'external_trigger': 'external_trigger', # noqa: E501
'conf': 'conf', # noqa: E501
}

_composed_schemas = {}
Expand Down Expand Up @@ -153,10 +155,11 @@ def __init__(self, *args, **kwargs): # noqa: E501
dag_id (str): [optional] # noqa: E501
execution_date (datetime): [optional] # noqa: E501
start_date (datetime): [optional] # noqa: E501
end_date (datetime): [optional] # noqa: E501
end_date (datetime, none_type): [optional] # noqa: E501
state (TaskState): [optional] # noqa: E501
run_id (str): [optional] # noqa: E501
dag_run_id (str, none_type): [optional] # noqa: E501
external_trigger (bool): [optional] if omitted the server will use the default value of True # noqa: E501
conf ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): JSON object describing additional configuration parameters. The value of this field can be set only when creating the object. If you try to modify the field of an existing object, the request fails with an BAD_REQUEST error. . [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down
11 changes: 6 additions & 5 deletions docs/DAGRun.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**dag_id** | **str** | | [optional] [readonly]
**execution_date** | **datetime** | | [optional] [readonly]
**start_date** | **datetime** | | [optional]
**end_date** | **datetime** | | [optional]
**execution_date** | **datetime** | | [optional]
**start_date** | **datetime** | | [optional] [readonly]
**end_date** | **datetime, none_type** | | [optional] [readonly]
**state** | [**TaskState**](TaskState.md) | | [optional]
**run_id** | **str** | | [optional]
**external_trigger** | **bool** | | [optional] if omitted the server will use the default value of True
**dag_run_id** | **str, none_type** | | [optional]
**external_trigger** | **bool** | | [optional] [readonly] if omitted the server will use the default value of True
**conf** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | JSON object describing additional configuration parameters. The value of this field can be set only when creating the object. If you try to modify the field of an existing object, the request fails with an BAD_REQUEST error. | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
Loading

0 comments on commit 28382eb

Please sign in to comment.