Main endpoints¶
In this section of the documentation we have the code reference for the main endpoints of cornflow.
Signup endpoint¶
External endpoint for the user to signup
- class cornflow.endpoints.signup.SignUpEndpoint¶
Bases:
BaseMetaResource
Endpoint used to sign up to the cornflow web server.
- post(**kwargs)¶
API (POST) method to sign up to the cornflow webserver
- Returns:
A dictionary with a message (either an error during signup or the generated token for the user session) and an integer with the HTTP status code
- Return type:
Tuple(dict, integer)
- sign_up(**kwargs)¶
The method in charge of performing the sign up of users
- Parameters:
kwargs – the keyword arguments needed to perform the sign up
- Returns:
a dictionary with the newly issued token and the user id, and a status code
- methods: t.ClassVar[t.Collection[str] | None] = {'POST'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
Login endpoint¶
External endpoint for the user to login to the cornflow webserver
- class cornflow.endpoints.login.LoginBaseEndpoint¶
Bases:
BaseMetaResource
Base endpoint to perform a login action from a user
- log_in(**kwargs)¶
This method is in charge of performing the log in of the user
- Parameters:
kwargs – keyword arguments passed for the login, these can be username, password or a token
- Returns:
the response of the login or it raises an error. The correct response is a dict
with the newly issued token and the user id, and a status code of 200 :rtype: dict
- auth_db_authenticate(username, password)¶
Method in charge of performing the authentication against the database
- Parameters:
username (str) – the username of the user to log in
password (str) – the password of the user to log in
- Returns:
the user object or it raises an error if it has not been possible to log in
- Return type:
UserModel
- auth_ldap_authenticate(username, password)¶
Method in charge of performing the authentication against the ldap server
- Parameters:
username (str) – the username of the user to log in
password (str) – the password of the user to log in
- Returns:
the user object or it raises an error if it has not been possible to log in
- Return type:
UserModel
- auth_oid_authenticate(token)¶
Method in charge of performing the log in with the token issued by an Open ID provider
- Parameters:
token (str) – the token that the user has obtained from the Open ID provider
- Returns:
the user object or it raises an error if it has not been possible to log in
- Return type:
UserModel
- cornflow.endpoints.login.check_last_password_change(user)¶
- class cornflow.endpoints.login.LoginEndpoint¶
Bases:
LoginBaseEndpoint
Endpoint used to do the login to the cornflow webserver
- post(**kwargs)¶
API (POST) method to log in in to the web server.
- Returns:
A dictionary with a message (either an error during login or the generated token for the user session) and an integer with the HTTP status code
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'POST'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.login.LoginOpenAuthEndpoint¶
Bases:
LoginBaseEndpoint
- post(**kwargs)¶
- methods: t.ClassVar[t.Collection[str] | None] = {'POST'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
Instance endpoints¶
External endpoints to manage the instances: create new ones, or get all the instances created by the user, or get only one. These endpoints have different access url, but manage the same data entities
- class cornflow.endpoints.instance.InstanceEndpoint¶
Bases:
BaseMetaResource
Endpoint used to create a new instance or get all the instances and their related information
- get(**kwargs)¶
API (GET) method to get all the instances created by the user and its related info It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user
- Returns:
a list of objects with the data and an integer with the HTTP status code
- Return type:
Tuple(dict, integer)
- post(**kwargs)¶
- methods: t.ClassVar[t.Collection[str] | None] = {'GET', 'POST'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.instance.InstanceDetailsEndpointBase¶
Bases:
BaseMetaResource
Endpoint used to get the information of a single instance, edit it or delete it
- get(idx)¶
API method to get an instance created by the user and its related info. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user.
- Parameters:
idx (str) – ID of the instance
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or the data of the instance) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'GET'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.instance.InstanceDetailsEndpoint¶
Bases:
InstanceDetailsEndpointBase
- put(idx, **kwargs)¶
API method to edit an existing instance. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user.
- Parameters:
idx (str) – ID of the instance
- Returns:
A dictionary with a confirmation message and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- delete(idx)¶
API method to delete an existing instance. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user.
- Parameters:
idx (str) – ID of the instance
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or a message) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'DELETE', 'GET', 'PUT'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.instance.InstanceDataEndpoint¶
Bases:
InstanceDetailsEndpointBase
Endpoint used to get the information o fa single instance, edit it or delete it
- get(idx)¶
API method to get an instance data by the user and its related info. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user.
- Parameters:
idx (str) – ID of the instance
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or the data of the instance) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'GET'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.instance.InstanceFileEndpoint¶
Bases:
BaseMetaResource
Endpoint to accept mps files to upload
- post(name, description, minimize=1)¶
- Parameters:
name (str) –
description (str) –
minimize (int) –
- Returns:
a tuple with the created instance and an integer with the status code
- Return type:
Tuple(
InstanceModel
, 201)
- methods: t.ClassVar[t.Collection[str] | None] = {'POST'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- cornflow.endpoints.instance.allowed_file(filename)¶
Execution endpoints¶
External endpoints to manage the executions: create new ones, list all of them, get one in particular or check the status of an ongoing one These endpoints hve different access url, but manage the same data entities
- class cornflow.endpoints.execution.ExecutionEndpoint¶
Bases:
BaseMetaResource
Endpoint used to create a new execution or get all the executions and their information back
- get(**kwargs)¶
API method to get all the executions created by the user and its related info It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user
- Returns:
A dictionary with a message (error if authentication failed or a list with all the executions created by the authenticated user) and a integer with the HTTP status code
- Return type:
Tuple(dict, integer)
- post(**kwargs)¶
API method to create a new execution linked to an already existing instance It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user
- Returns:
A dictionary with a message (error if authentication failed, error if data is not validated or the reference_id for the newly created execution if successful) and a integer wit the HTTP status code
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'GET', 'POST'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.execution.ExecutionRelaunchEndpoint¶
Bases:
BaseMetaResource
- post(idx, **kwargs)¶
API method to re-launch an existing execution It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user
- Returns:
A dictionary with a message (error if authentication failed, error if data is not validated or the reference_id for the newly created execution if successful) and a integer wit the HTTP status code
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'POST'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.execution.ExecutionDetailsEndpointBase¶
Bases:
BaseMetaResource
Endpoint used to get the information of a certain execution. But not the data!
- class cornflow.endpoints.execution.ExecutionDetailsEndpoint¶
Bases:
ExecutionDetailsEndpointBase
- get(idx)¶
API method to get an execution created by the user and its related info. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user.
- Parameters:
idx (str) – ID of the execution.
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or the data of the execution) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- put(idx, **data)¶
Edit an existing execution
- Parameters:
idx (string) – ID of the execution.
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or a message) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- delete(idx)¶
API method to delete an execution created by the user and its related info. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user.
- Parameters:
idx (string) – ID of the execution.
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or a message) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- post(idx)¶
- methods: t.ClassVar[t.Collection[str] | None] = {'DELETE', 'GET', 'POST', 'PUT'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.execution.ExecutionStatusEndpoint¶
Bases:
BaseMetaResource
Endpoint used to get the status of a certain execution that is running in the airflow webserver
- get(idx)¶
API method to get the status of the execution created by the user It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user.
- Parameters:
idx (str) – ID of the execution
- Returns:
A dictionary with a message (error if the execution does not exist or status of the execution) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- put(idx, **data)¶
Edit an existing execution
- Parameters:
idx (string) – ID of the execution.
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or a message) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'GET', 'PUT'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.execution.ExecutionDataEndpoint¶
Bases:
ExecutionDetailsEndpointBase
Endpoint used to get the solution of a certain execution.
- get(idx)¶
- Parameters:
idx (str) – ID of the execution.
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or the data of the execution) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'GET'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.execution.ExecutionLogEndpoint¶
Bases:
ExecutionDetailsEndpointBase
Endpoint used to get the log of a certain execution.
- get(idx)¶
- Parameters:
idx (str) – ID of the execution.
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or the data of the execution) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'GET'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
User endpoint¶
Endpoints for the user profiles
- class cornflow.endpoints.user.UserEndpoint¶
Bases:
BaseMetaResource
Endpoint with a get method which gives back all the info related to the users. Including their instances and executions
- ROLES_WITH_ACCESS = [3]¶
- get()¶
API (GET) method to get all the info from all the users It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by the superuser
- Returns:
A dictionary with the user data and an integer with the HTTP status code
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'GET'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.user.UserDetailsEndpoint¶
Bases:
BaseMetaResource
Endpoint use to get the information of one single user
- ROLES_WITH_ACCESS = [1, 2, 3, 4]¶
- get(user_id)¶
- Parameters:
user_id (int) – User id.
- Returns:
- Return type:
Tuple(dict, integer)
- delete(user_id)¶
- Parameters:
user_id (int) – User id.
- Returns:
- Return type:
Tuple(dict, integer)
- put(user_id, **data)¶
API method to edit an existing user. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user. Only admin and service user can edit other users.
- Parameters:
user_id (int) – id of the user
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or a message) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'DELETE', 'GET', 'PUT'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.user.ToggleUserAdmin¶
Bases:
BaseMetaResource
Endpoint to convert a user into and admin or to revoke admin privileges from a user
- ROLES_WITH_ACCESS = [3]¶
- put(user_id, make_admin)¶
API method to make admin or take out privileges. It requires authentication to be passed in the form of a token that has to be linked to an existing session (login) made by a user. Only an admin can change this.
- Parameters:
user_id (int) – id of the user
make_admin – 0 if the user is not going to be made admin, 1 if the user has to be made admin
- Returns:
A dictionary with a message (error if authentication failed, or the execution does not exist or a message) and an integer with the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'PUT'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.
- class cornflow.endpoints.user.RecoverPassword¶
Bases:
BaseMetaResource
Endpoint to recover the password
- put(**kwargs)¶
API method to send an email to the user if they forgot to password. Sends a temporary password and updates the database. :param kwargs: a dictionary containing the email address :return: A dictionary with a message (error if the email address is not in the database) and an integer with
the HTTP status code.
- Return type:
Tuple(dict, integer)
- methods: t.ClassVar[t.Collection[str] | None] = {'PUT'}¶
The methods this view is registered for. Uses the same default (
["GET", "HEAD", "OPTIONS"]
) asroute
andadd_url_rule
by default.