Flask

Logs Client

The logs client exposes the following endpoints:

  • /: an index of all the available logs (doesn’t include fallback logger options)

  • /dna: DNA’s internal log printer (when it hasn’t been overriden)

  • /<service>/docker: docker container logs for the requested service

  • /<service>/nginx: nginx access logs for the requested service

  • /<service>/error: nginx error logs for the requested service

dna.utils.create_logs_client(dna, fallback=None, precheck=<function <lambda>>)[source]

Create a Flask Blueprint to display DNA logs on a website

Since logs are typically not sensitive, the precheck is permissive by default. Please make sure to change this functionality if you don’t want the logs to be publicly accessible.

Parameters
  • dna (DNA) – the dna instance to interface with

  • fallback (func) – an optional fallback function if DNA can’t handle logs such as if you want to display a type of logs that DNA isn’t familiar with (ex. image build logs)

  • precheck (decorator) – an optional decorator that wraps all log endpoints

Returns

a Flask Blueprint that can be registered to a Flask app

API Client

The API client exposes the following endpoints relating to provisioning API keys:

  • /: an index of all active API keys

  • /new_key: create a new API key

  • /manage_key?key=<key>: manage the requested key

  • /revoke_key/<key>: revoke the requested key

The API client exposes the following endpoints that call DNA functions:

  • /pull_image: pull a docker image

  • /build_image: build a docker image

  • /run_deploy: deploy a docker image

  • /propagate_services: refresh the services list on the current DNA instance

  • /get_service_info/<name>: get information about the requested service

  • /add_domain: add a domain to a service

  • /remove_domain: remove a domain from a service

  • /delete_service: delete a service

To see how to format your requests to these endpoints, read the source (pay attention to the calls to data.get)

dna.utils.create_api_client(dna, precheck=None)[source]

Create a Flask Blueprint to expose DNA functions as a REST API

Since these functions control deployment, the precheck is restrictive by default. Please make sure to pass in a decorator that properly validates authenticated users and allows them to use the API key endpoints.

Parameters
  • dna (DNA) – the dna instance to interface with

  • precheck (decorator) – an optional decorator that wraps the API key endpoints

Returns

a Flask Blueprint that can be registered to a Flask app