Azion client¶
Azion is the main entrypoint to work with Azion’s ReST API.
Azion¶
-
class
azion.client.
Azion
(token=None, session=None)¶ Entrypoint to work with Azion API.
To start using this client, we need a valid token. For this we can use the authorize function:
from azion.api import authorize, login auth = authorize(user, password) azion = login(auth.token)
Now you can use all API resources.
Obtain a fresh token to handle Azion’s API protected calls.
Parameters: - username (str) – username
- password (str) – password
-
create_configuration
(name, origin_address, origin_host_header, cname=None, cname_access_only=False, delivery_protocol='http', digital_certificate=None, origin_protocol_policy='preserve', browser_cache_settings=False, browser_cache_settings_maximum_ttl=0, cdn_cache_settings='honor', cdn_cache_settings_maximum_ttl=0)¶ Create a configuration.
Parameters: - name (str) – human-readable name for the configuration.
- origin_address (str) – origin address that can be an IP or a hostname (FQDN)
- origin_host_header (str) – host header will be sent to the origin.
- cname (list) – a list os strings containing all cnames. Default empty string.
- cname_access_only (bool) – defines whether the content delivery should be done only through cnames. Default to False.
- delivery_protocol (str) – defines the HTTP protocol used to deliver content. Default to http.
- digital_certificate (int) – Digital Certificate ID. Check Digital Certificates for more info.
- origin_protocol_policy (str) – Protocol policy used to connect to the origin.
- browser_cache_settings (bool) – whether the user browser should respect the cache headers sent from the origin. Default to False.
- browser_cache_settings_maximum_ttl (int) – used within browser_cache_settings, defines how many seconds browser cache object will live. Default to 0.
-
create_origin
(configuration_id, name, origin_type, method, host_header, origin_protocol_policy, addresses, connection_timeout, timeout_between_bytes)¶ Create an origin.
-
delete_configuration
(configuration_id)¶ Delete a configuration.
Parameters: configuration_id (int) – Configuration ID.
-
get_configuration
(configuration_id)¶ Retrieve a configuration.
Parameters: configuration_id (int) – configuration id
-
list_configurations
()¶ List configurations.
-
list_origins
(configuration_id)¶ List origins of the given configuration.
Parameters: configuration_id (int) – Configuration ID
-
login
(token)¶ Log the user into Azion’s API.
Parameters: token (str) – Authorization token. It can be obtained from token_auth()
-
partial_update_configuration
(configuration_id, name=None, cname=None, cname_access_only=None, delivery_protocol=None, digital_certificate=None, rawlogs=None, active=None)¶ Partially updates a configuration.
One or more fields can be updated, without changing the current values of the other fields of this configuration.
Parameters: - name (str) – human-readable name for the configuration.
- cname (list) – a list os strings containing all cnames. Default empty string.
- cname_access_only (bool) – defines whether the content delivery should be done only through cnames. Default to False.
- delivery_protocol (str) – defines the HTTP protocol used to deliver content. Default to http.
- digital_certificate (int) – Digital Certificate ID. Check Digital Certificates for more info.
- rawlogs (boolean) – Whether this configuration will store logs in the Cloud Storage.
- active (boolean) – Whether this configuration is active.
-
purge_cache_key
(urls, method='delete')¶ Purge content of the given URLs inside the urls list. With this purge endpoint you can pass cache keys.
Parameters: - urls (list) – List of URLs to be purged.
- method (str) – How the content will be purged. Default to ‘delete’.
-
purge_url
(urls, method='delete')¶ Purge content of the given URLs inside the urls list.
Parameters: - urls (list) – List of URLs to be purged.
- method (str) – How the content will be purged. Default to ‘delete’.
-
purge_wildcard
(url, method='delete')¶ Purge content of the given URL. With this purge endpoint you can use a wildcard (*) to remove all objects matching the URL.
Parameters: - url (str) – Wildcard URL to be purged.
- method (str) – How the content will be purged. Default to ‘delete’.
-
replace_configuration
(configuration_id, name=None, cname=None, cname_access_only=None, delivery_protocol=None, digital_certificate=None, rawlogs=None, active=None)¶ Replace a configuration.
One or more fields can be updated. Fields that were not specificed in the request will be replaced for default values. Consider using
partial_update_configuration()
Parameters: - configuration_id (int) – Configuration ID
- name (str) – human-readable name for the configuration.
- cname (list) – a list os strings containing all cnames. Default empty string.
- cname_access_only (bool) – defines whether the content delivery should be done only through cnames. Default to False.
- delivery_protocol (str) – defines the HTTP protocol used to deliver content. Default to http.
- digital_certificate (int) – Digital Certificate ID. Check Digital Certificates for more info.
- rawlogs (boolean) – Whether this configuration will store logs in the Cloud Storage.
- active (boolean) – Whether this configuration is active.