Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenAPI spec #7549

Merged
merged 1 commit into from
Apr 4, 2020
Merged

Add OpenAPI spec #7549

merged 1 commit into from
Apr 4, 2020

Conversation

mik-laj
Copy link
Member

@mik-laj mik-laj commented Feb 26, 2020

I prepared an OpenAPI spec that contains the following elements:

  • endpoints
  • scheme
  • response bodies

Subsequent PR may extend the Open API spec of subsequent elements, e.g. HATEOAS.


Issue link: AIRFLOW-6929

Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Commit message/PR title starts with [AIRFLOW-NNNN]. AIRFLOW-NNNN = JIRA ID*
  • Unit tests coverage for changes (not needed for documentation changes)
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

* For document-only changes commit message can start with [AIRFLOW-XXXX].


In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@mik-laj mik-laj changed the title [AIRFLOW-6929] Add OpenAPI spec [AIRFLOW-6929][DONT-MERGE] Add OpenAPI spec Feb 26, 2020
@mik-laj mik-laj force-pushed the aip-XXXXX-api branch 3 times, most recently from ac2f7d8 to 4f610c3 Compare February 27, 2020 01:01
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Show resolved Hide resolved
@ad-m
Copy link
Contributor

ad-m commented Feb 27, 2020

I like the direction of the changes. I have no comments on the document structure (it is correct), nor on the presented project of the API structure (it is correct in my opinion). The only minor remarks about the standardization of formatting the specification.

openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Outdated Show resolved Hide resolved
openapi.yaml Show resolved Hide resolved
@mik-laj mik-laj force-pushed the aip-XXXXX-api branch 2 times, most recently from 541671f to 1e3e444 Compare February 28, 2020 13:51
@ad-m
Copy link
Contributor

ad-m commented Mar 6, 2020

@mik-laj , the changes look good.

@nuclearpinguin, I don't know the full process of accepting changes to this project. What can we do to go further with this?

@turbaszek
Copy link
Member

@nuclearpinguin, I don't know the full process of accepting changes to this project. What can we do to go further with this?

@ad-m we've got to wait for the outcome of voting on this change (it's going to happen soon).

@ad-m
Copy link
Contributor

ad-m commented Mar 7, 2020

@nuclearpinguin Where will this voting take place? Do you have significant arguments against adopting this changes or are you going to vote in favor of the changes?

@turbaszek
Copy link
Member

@ad-m for arguments and the whole discussion please check this mailing list thread (as well as AIP mentioned there):
https://lists.apache.org/thread.html/r2a0d0fb3d4610432fa52148d7d9e59c7632dd8f2fa61a580430b814c%40%3Cdev.airflow.apache.org%3E

The voting will also take place on Airflow dev mailing list:
https://lists.apache.org/[email protected]

@mik-laj mik-laj changed the title [AIRFLOW-6929][DONT-MERGE] Add OpenAPI spec Add OpenAPI spec Apr 4, 2020
@mik-laj
Copy link
Member Author

mik-laj commented Apr 4, 2020

This PR is part of AIP-32. It was discussed and voted on the mailing list.
https://lists.apache.org/thread.html/rb46b10dbeb96292f612461f1ed79777ef37be24d88d1ce3179c21fab%40%3Cdev.airflow.apache.org%3E
..so I merge it. We can make further changes in separate PRs.

@mik-laj mik-laj removed the dont-merge label Apr 4, 2020
@mik-laj mik-laj merged commit 11f1e0c into apache:master Apr 4, 2020
@mik-laj mik-laj mentioned this pull request Apr 4, 2020
@kaxil kaxil mentioned this pull request Apr 4, 2020
5 tasks
@dlamblin
Copy link
Contributor

dlamblin commented Apr 6, 2020

I ended up dropping a comment on the wrong PR about this… PolideaInternal#653 (comment)
You did fix most every typo, but there's still "Encryption and encryption" one case of "aa", another of "a variables" and "an import errors". Otherwise this file was really handy as a reference and I'm looking into how I can use it for a system that takes spec version 2.

I did have a question about what happened to triggering a DAG by creating a DAG run. Perhaps I am just missing it?

@mik-laj
Copy link
Member Author

mik-laj commented Apr 6, 2020

You did fix most every typo, but there's still "Encryption and encryption" one case of "aa", another of "a variables" and "an import errors".

Can you create PR with your change suggestions? Unfortunately, manually comparing differences is very problematic.

I did have a question about what happened to triggering a DAG by creating a DAG run. Perhaps I am just missing it?

If DAG Run is created and the conditions for the tasks to be started are met, tasks will be started. I added your question to corresponding issue: #8120

@ashb
Copy link
Member

ashb commented Apr 8, 2020

@mik-laj Merging any PR without an approval is very Not Cool. Please don't do that.

in: path
name: dag_id
schema:
type: integer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mik-laj You didn't fix this like you said you did.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created new PR with updated specification: #8721

Here is the commit that makes the change.
cd2be1c

in: path
name: task_id
schema:
type: integer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created new PR with updated specification: #8721

Here is the commit that makes the change.
cd2be1c

in: path
name: pool_id
schema:
type: integer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong too. The identifier that we should use is the pool name, it's unique (i.e. a string) not the never exposed integer id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created new PR with updated specification: #8721

Here is the commit that makes the change.
baa22d7

Can you look if everything is alright?

ashb added a commit to ashb/airflow that referenced this pull request Apr 8, 2020
This reverts commit 11f1e0c.

The OpenAPI spec as added in has problems and needs revisiting (typos,
wrong IDs, wrong types)
ashb added a commit that referenced this pull request Apr 8, 2020
This reverts commit 11f1e0c.

The OpenAPI spec as added in has problems and needs revisiting (typos,
wrong IDs, wrong types)
Copy link
Contributor

@dlamblin dlamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started by trying to identify the minor typos I spotted, but in detail I found a question about trigger dags, clearing tasks, and the values of xcom entries.

$ref: '#/components/responses/PermissionDenied'

post:
summary: Create aa pool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the "aa" typo I would like fixed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

I created new PR with updated specification: #8721

Here is the commit that makes the change.
ce40ff5

Can you look if everything is alright?

type: string
required: true
description: >
The key containing the encrypted path to the file. Encryption and encryption takes place
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you meant to write: Encryption and decryption take place only on the server side.
or: Encryption takes place only on the server side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Here is commit with the change: 47d779e

$ref: '#/components/responses/PermissionDenied'

post:
summary: Create a variables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to only make one variable: Create a variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Here is commit with the change: af260cb

- $ref: '#/components/parameters/VariableID'

get:
summary: Get a variables by id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And: Get a variable by id

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Here is commit with the change: af260cb

- $ref: '#/components/parameters/ImportErrorID'

get:
summary: Get an import errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better as: Get an import error
[assuming ImportErrorIDs are unique]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks
Here is commit: 69e769d

'403':
$ref: '#/components/responses/PermissionDenied'

/dags/{dag_id}/taskInstances/{task_id}/{execution_date}/xcomValues/{key}:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the xcom table uses ['dag_id', 'task_id', 'key', 'execution_date'] as the primary key, the task and dag ids are the string names of those entities.

Copy link
Member Author

@mik-laj mik-laj May 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to build hierarchical URLs to make these APIs easier to use. How would you like these API URLs to look?


patch:
summary: Update a pool
operationId: upadtePool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operationId: updatePool

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Here is commit: b661d0c


post:
summary: Create an XCom entry
operationId: updateXComValues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be createXComEntry

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated spec. Here is commit: 26e0d22

description:
This endpoint support reading resources across multiple Task Instances by specifying a
"-" as a `dag_id`, `task_id` and `execution_date`.
operationId: getXComValues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the value [is/should be] just one field of the returned by XcomCollectionItem these operationIds under this path which end in Value(s) get a little confusing. Maybe we could rename them like: getXComEntries? The same can be said about the summary and description mentioning just the values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated spec. Here is commit: 26e0d22

XComCollectionItem:
# Divided into two schemas for sensitive data protection
type: object
properties:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XComCollectionItem appears to be missing a value property.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional, because value can be very big. This information is available in the details of the specific resource.


patch:
summary: Update a connection entry
operationId: patchConnection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name the operationId: updateConnection. This is the only patch operation that is not named update something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OperationID will change in the future due to integration with connexion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is commit: f40f400

@mik-laj mik-laj mentioned this pull request May 5, 2020
5 tasks
mik-laj added a commit to PolideaInternal/airflow that referenced this pull request May 5, 2020
@mik-laj
Copy link
Member Author

mik-laj commented May 5, 2020

Hello,
I created a new PR with updated specification:
#8721
Best regards,
Kamil

mik-laj added a commit to PolideaInternal/airflow that referenced this pull request May 26, 2020
mik-laj added a commit that referenced this pull request Jun 1, 2020
* Add OpenAPI spec (#7549)

* Fix typo in name of pre-commit hook

* Chaange type for DAGID, DAGRunID, TaskID

* Fix typo in summary - POST /pools

* Fix typo in description - FileToken parameter

* Fix typo - singular/plural form - variables

* Make EventLog endpoints read-only

* Use ExcutionDate in DagRuns endpoints

* Use custom action to control task instances

* Typo in  DELETE Task instance

* Remove unused schema - DagStructureCollection

* Fix typo - singular/plural form - import errors

* Add endpoint - POST /dagRuns

* Remove job_id

We do not have endpoints to download jobs, because this is an implementation detail, so this field has big no value.

* Add filters to GET /taskInstances

* Fix typo - upadtePool => updatePool

* Rename "Create a DAG Run" to "Trigger a DAG Run"

* Use Pool name as a parameter

* Add filter to GET /dagRuns

* Remove invalid note ion start_date field

* Uss POST instead of PATCH for custom action

* Remove DELETE /taskInstances endpooint

* Rename Xcom Value to xcom Entry

* Fix typo in XCCOM Entry endpoint

* Change operationID: patchConnection => updaateConnection

* Make execution_date optionall in DAGRun

This field can be filled with the current date when creating the DAG Run

* Unify connection ID

* Use URL with HTTPS and without www.

* Fix typo - at database => in database

* Fix typo = Raange -> Raange

* Fix typo - the specific DAG => a DAG

* Fix typo - getXComVEntry => getXComVEntry

* Unify collection names - xcomEntries

* Move TaskInstance resource under DagRun resource

* Fix typo - change tag - TaskInstance => TaskInstance

Co-authored-by: Ash Berlin-Taylor <[email protected]>

* Use path paramaters for /variables/lookup/ endpoint

* Use consistent names for IDs

* Use new style for filter parameters

* Remove unused path parameter

* Use ~ as a wildcard charaacter

* Add batch endpoints for TaskInstance and DagRuns

* Fix typo - response in trigger dag endpoint

* Fix typo - Qqueue => Queue

* Set dry_run = True in ClearTaskInstance

* Mark all fieldss (expcet state) of DagRun as read-only

* Use __type as a discriminator

* Fix typo - "The Import Error ID." => "The Event Log ID."

* Fix typo - Self referential in EventLogCollection

* Rename fieldss - dttm => when

* remove fields - pool_id

* Fix typo - change request body in PATCH /pools/{pool_name}

* Use DAG Run ID as a primary identifier

* Fix typo - Change type of query to string

* Unify fields names in collections

* Use variable key as a primary id

* Move collection to /variables

* Mark passord as a write only

* Fix typo - updaateConnection => updateConnection

* Change is_paused/is_subdag to boolean

* Fix typo - clearTaskInstaance => clearTaskInstance

* Fix typo - DAAG => DAG

* Fix typo - many => multiple

* Fix typo - missing "a"

* Fix typo - variable by id => variable by key

* Fix typo - updateXComEntries => updateXComEntry

* Fix typo - missing "a"

* Use dag_run_id as a primary ID

* Fix typo - objectss => objects, DAG IDS => DAG IDs

* Allows create DAG Run with custom conf/execution_date/dag_run_id

* Add new trigger rule, fix typo in dag run state

* Add request body to POST/PATCH /dags/{dag_id}

* Rename collection fields - dag_model => dags

* Fix typo - /clearTaskInstanaces -> /clearTaskInstances

* Improve wording - wildcard

* Returns owners as a array

* Return only references in clear task instances

* Remove support for application/x-www-form-urlencoded

* fixup! Use __type as a discriminator

* Add file_token fields

* Move description of variable collections

* Return SUB DAG in DAG structure

* Fix typo - sucess => sucess, Apache Foundation => Apache Software Foundation, Airfow => Apache Airflow

* Improve description of get logs endpoint

* Fix typo - Get all XCom entry => Get all XCom entries

* Add crossreference between /dags/{dag_id}/structure and /dags/{dag_id}

* Remove all form-urllencoded request bodies

* Rename parameter - NoChunking => FullContent

* Improve description of batch endpoints

* Remove request body for GET endpoint

* Use allOf insteaad of oneOf

* Rename key => xcom_key

* Use lowercase letters in query string parameter - Queue -> queue

* Change type of conf to object

* Change allOf into oneOf for ScheduleInterval

Co-authored-by: Ash Berlin-Taylor <[email protected]>
@mik-laj mik-laj added the area:API Airflow's REST/HTTP API label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API area:dev-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants