nest_backend - Web API in Python

.gestione - Metodi di utility

Gestione adds many fancy thingamajigs to the flask application, such as a login system and such.

nest_backend.gestione.authenticate(username, password)

Authentication method. It checks if the combination of username+password is a valid match. If not, it returns None. :param username: the user’s email :param password: the user’s password :return: if the credentials are correct, it returns the user. Else, it returns None.

nest_backend.gestione.identity(payload)

Authentication verification method. It checks if the user is in fact registered on the server. It is required by Flask-JWT, and shouldnt be used alone. :param payload: the reqest payload. :return: an User or None. It depends whether the user is actually registered on the platform.

nest_backend.gestione.gen_password(password)

It generates an hashed password. :param password: the password that needs to be hashed. :return: the password’s hash.

nest_backend.gestione.find_user(email)
nest_backend.gestione.admin_or_403(f)
nest_backend.gestione.repository_auth(f)
nest_backend.gestione.json_request_authorizer(json, serializable)
nest_backend.gestione.json_error(msg, code='errorUnknownError')

Returns an error in json format :param code: the code of the error according to the spec. :param msg: the error message. :return: a json formatted string.

nest_backend.gestione.json_success(data)

An happy little function. Its happy because the operation was successful. :param data: the thing you want to be returned :return: a json formatted string

nest_backend.gestione.error_handler(e)
nest_backend.gestione.hashtag_validator(hashtag)

.database - Database

This module imports all the tables and the declarative base

.base - Estensione flask

.tables - Tabelle

This module contains all database classes.

class nest_backend.database.tables.Alert(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

id
name
limit
window_size
evaluation_mode
repository_id
repository
notifications
conditions
to_json()
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.Authorization(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

rid
email
repository
user
to_json()
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.Composed(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

rid
snowflake
repository
tweet
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.Condition(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

id
type
content
repository_id
repository
tweets
alerts
to_json()
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.Contains(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

cid
snowflake
condition
tweet
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.Notification(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

id
ora
alert_id
alert
to_json()
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.Repository(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

id
name
start
end
is_active
is_deleted
evaluation_mode
owner_id
owner
authorizations
tweets
alerts
conditions
to_json()
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.Tweet(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

snowflake
content
location
place
poster
insert_time
post_time
image_url
repositories
conditions
to_json()
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.User(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

email
username
password
isAdmin
owner_of
authorizations
to_json()
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.MadeOf(**kwargs)

Basi: sqlalchemy.orm.decl_api.Model

aid
cid
alert
condition
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class nest_backend.database.tables.ConditionType(value)

Basi: enum.Enum

Vedi Specifica delle Conditions su GitLab .

hashtag = 0
location = 1
time = 2
coordinates = 3
place = 4
user = 5
class nest_backend.database.tables.OperationType(value)

Basi: enum.Enum

An enumeration.

assign = 3
class nest_backend.database.tables.ConditionMode(value)

Basi: enum.Enum

An enumeration.

all_or = 0
all_and = 1

.routes - Percorsi API

Nota

La documentazione dei percorsi API è gestita da Swagger UI, disponibile a /docs una volta che il webserver del backend è avviato.

Si allega una stampa dell’interfaccia swagger: