2022-04-11 18:38:26 +02:00
|
|
|
# Copyright 2021 Collate
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
from typing import Any, Dict, Optional
|
|
|
|
|
2022-05-02 12:27:20 +02:00
|
|
|
# TODO LOG (just link v1), ENABLE DAG, DISABLE DAG (play pause)
|
2022-04-11 18:38:26 +02:00
|
|
|
APIS_METADATA = [
|
|
|
|
{
|
|
|
|
"name": "deploy_dag",
|
|
|
|
"description": "Deploy a new DAG File to the DAGs directory",
|
|
|
|
"http_method": "POST",
|
|
|
|
"form_enctype": "multipart/form-data",
|
|
|
|
"arguments": [],
|
|
|
|
"post_arguments": [
|
|
|
|
{
|
|
|
|
"name": "workflow_config",
|
2022-04-12 17:06:49 +02:00
|
|
|
"description": "Workflow config to deploy as IngestionPipeline",
|
2022-04-11 18:38:26 +02:00
|
|
|
"form_input_type": "file",
|
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "trigger_dag",
|
|
|
|
"description": "Trigger a DAG",
|
|
|
|
"http_method": "POST",
|
|
|
|
"arguments": [],
|
|
|
|
"post_arguments": [
|
|
|
|
{
|
|
|
|
"name": "workflow_name",
|
|
|
|
"description": "Workflow name to run",
|
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-04-12 17:06:49 +02:00
|
|
|
{
|
|
|
|
"name": "test_connection",
|
|
|
|
"description": "Test a connection",
|
|
|
|
"http_method": "POST",
|
|
|
|
"arguments": [],
|
|
|
|
"post_arguments": [
|
|
|
|
{
|
|
|
|
"name": "service_connection",
|
2022-04-19 09:54:10 -07:00
|
|
|
"description": "TestServiceConnectionRequest config to test",
|
2022-04-12 17:06:49 +02:00
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-04-13 18:08:09 +02:00
|
|
|
{
|
|
|
|
"name": "dag_status",
|
2022-04-20 14:55:33 +02:00
|
|
|
"description": "Get the status of a dag's latest runs",
|
2022-04-13 18:08:09 +02:00
|
|
|
"http_method": "GET",
|
|
|
|
"arguments": [
|
|
|
|
{
|
|
|
|
"name": "dag_id",
|
|
|
|
"description": "The id of the dag",
|
|
|
|
"form_input_type": "text",
|
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-04-14 21:52:13 +02:00
|
|
|
{
|
|
|
|
"name": "delete_dag",
|
|
|
|
"description": "Delete a DAG in the Web Server from Airflow database and filesystem",
|
|
|
|
"http_method": "DELETE",
|
|
|
|
"arguments": [
|
|
|
|
{
|
|
|
|
"name": "dag_id",
|
|
|
|
"description": "The id of the dag to delete",
|
|
|
|
"form_input_type": "text",
|
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-05-26 19:08:56 +02:00
|
|
|
{
|
|
|
|
"name": "last_dag_logs",
|
|
|
|
"description": "Retrieve all logs from the task instances of a last DAG run",
|
|
|
|
"http_method": "GET",
|
|
|
|
"arguments": [
|
|
|
|
{
|
|
|
|
"name": "dag_id",
|
|
|
|
"description": "The id of the dag",
|
|
|
|
"form_input_type": "text",
|
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2022-05-02 12:27:20 +02:00
|
|
|
{
|
|
|
|
"name": "rest_status",
|
|
|
|
"description": "Get the status of Airflow REST status",
|
|
|
|
"http_method": "GET",
|
|
|
|
},
|
2022-04-11 18:38:26 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def get_metadata_api(name: str) -> Optional[Dict[str, Any]]:
|
|
|
|
"""
|
|
|
|
Return the APIS_METADATA dict for a
|
|
|
|
given name
|
|
|
|
"""
|
|
|
|
return next(iter(api for api in APIS_METADATA if api["name"] == name), None)
|