SQLite¶
Models¶
-
class
dna.utils.
Service
(**kwargs)[source]¶ Represents a service, as well any domains bound to it
- Parameters
name (str) – the name of the service
image (str) – the name of the docker image containing this image
port (str) – the container port running the front-end of this service
domains (list[
Domain
]) – a list of all the domains bound to this service
-
class
dna.utils.
Domain
(**kwargs)[source]¶ Represents a domain, storing the
Service
it’s bound to (if any)- Parameters
url (str) – the domain itself
service (
Service
) – the service connected to this domain
- Variables
service_name – the name of the service the domain is bound to
Warning
Do not set
service_name
manually! It is a foreign key that depends on theservice
, which is the parameter you should set.
-
class
dna.utils.
ApiKey
(**kwargs)[source]¶ Represents an API Key, for the optional Flask REST API utility
- Parameters
key (str) – the randomly-generated API key
ip (str) – the IP address that requested the key
issued_at (int) – the timestamp the key was issued at
expires_in (int) – the number of seconds this key is active
Interface¶
-
class
dna.utils.
SQLite
(rel='/', name='app')[source]¶ Various utilities to interface with SQLite
- Parameters
rel (str) – the relative path to the location to store the database
name (str) – the name of the database file (minus the
.db
extension)
-
create_service
(name, image, port)[source]¶ Create a new service with the given parameters
- Parameters
name (str) – the name of the service
image (str) – the docker image holding the service
port (str) – the container port running the front-end of the
- Returns
the created
Service
-
remove_domain_from_service
(domain, service)[source]¶ Unbind
domain
fromservice
if it is bound to it
-
delete_service
(service)[source]¶ Remove all records related to
service
, including the associatedService
object and any associatedDomain
objects- Parameters
service (str or
Service
) – the (name of the) service to delete
-
get_services
()[source]¶ Get all the services stored in this database
- Returns
a list of
Service
objects
-
get_service_by_name
(name)[source]¶ Get information on the service called
name
- Parameters
name (str) – the name to query on
- Returns
the requested
Service
, if it exists (elseNone
)
-
get_domain_by_url
(url, create=False)[source]¶ Get information on the domain pointing to
url
- Parameters
url (str) – the url to query on
create (bool) – flag to create the domain if it doesn’t exist (defaults to
False
)
- Returns
the requested
Domain
if it exists (elseNone
)
-
get_active_keys
()[source]¶ Get all the active API Keys in this DNA instance
- Returns
a list of
ApiKey
objects
-
get_key_info
(key)[source]¶ Get info for the API key represented by the given key
- Parameters
key (str) – the key to query by
- Returns
the relevant
ApiKey
object if it exists, elseNone
-
new_api_key
(key, ip, expires_in=3600)[source]¶ Create a new API key
- Parameters
key (str) – the randomly-generated key
ip (str) – the IP address that requested the key
expires_in (int) – the number of seconds the key may be used (defaults to
3600
)
- Returns
the new
ApiKey
object