adp.core.backup.BackupClient

class adp.core.backup.BackupClient(url: str, credential: TokenCredential)

BackupClient is a client for the Backup API. It can retrieve, create and monitor backups

__init__(url: str, credential: TokenCredential)

Methods

__init__(url, credential)

build_from_appsettings()

build_from_appsettings returns a BackupClient from the specified adp.core.settings

close()

Closes all adapters and as such the session

create_backup(name, source_path, type)

create_backup creates a backup definition in the API and starts the backup

delete(url, **kwargs)

Sends a DELETE request.

get(url, **kwargs)

Sends a GET request.

get_adapter(url)

Returns the appropriate connection adapter for the given URL.

get_backup(id)

get_backup retrieves a backup for a particular id

get_backups()

get_backups retrieves all backup definitions from the API

get_redirect_target(resp)

Receives a Response.

get_status(id)

get_status for a backup id

get_statusmessage(id)

get_statusmessage retrieves the latest status message for a backup id

head(url, **kwargs)

Sends a HEAD request.

merge_environment_settings(url, proxies, ...)

Check the environment and merge it with some settings.

monitor_backup(id[, poll_interval])

monitor_backup Monitors a backup with a certain id

mount(prefix, adapter)

Registers a connection adapter to a prefix.

options(url, **kwargs)

Sends a OPTIONS request.

patch(url[, data])

Sends a PATCH request.

post(url[, data, json])

Sends a POST request.

prepare_request(request)

Constructs a PreparedRequest for transmission and returns it.

put(url[, data])

Sends a PUT request.

rebuild_auth(prepared_request, response)

When being redirected we may want to strip authentication from the request to avoid leaking credentials.

rebuild_method(prepared_request, response)

When being redirected we may want to change the method of the request based on certain specs or browser behavior.

rebuild_proxies(prepared_request, proxies)

This method re-evaluates the proxy configuration by considering the environment variables.

request(method, url[, params, data, ...])

Constructs a Request, prepares it and sends it.

resolve_redirects(resp, req[, stream, ...])

Receives a Response.

send(request, **kwargs)

Send a given PreparedRequest.

should_strip_auth(old_url, new_url)

Decide whether Authorization header should be removed when redirecting

Attributes

default_headers

Headers included in every request for authorization

headers

A case-insensitive dictionary of headers to be sent on each Request sent from this Session.

auth

Default Authentication tuple or object to attach to Request.

proxies

Dictionary mapping protocol or protocol and host to the URL of the proxy (e.g. {'http': 'foo.bar:3128', 'http://host.name': 'foo.bar:4012'}) to be used on each Request.

hooks

Event-handling hooks.

params

Dictionary of querystring data to attach to each Request.

stream

Stream response content default.

verify

SSL Verification default.

cert

SSL client certificate default, if String, path to ssl client cert file (.pem).

max_redirects

Maximum number of redirects allowed.

trust_env

Trust environment settings for proxy configuration, default authentication and similar.

cookies

A CookieJar containing all currently outstanding cookies set on this session.

classmethod build_from_appsettings()

build_from_appsettings returns a BackupClient from the specified adp.core.settings

create_backup(name: str, source_path: str, type: BackupType) int

create_backup creates a backup definition in the API and starts the backup

Parameters:
Returns:

the Id of the newly created backup

Return type:

int

property default_headers

Headers included in every request for authorization

get_backup(id: int) dict[str, Any]

get_backup retrieves a backup for a particular id

Parameters:

id (int) – The id of the backup

Returns:

the backup object as an dictionary

Return type:

dict

get_backups() List[dict[str, Any]]

get_backups retrieves all backup definitions from the API

Returns:

A list of dictionaries containing the backup definitions

Return type:

List[dict]

get_status(id: int) BackupStatus

get_status for a backup id

Parameters:

id (int) – The id of the backup to get the status from

Returns:

the latest status of the backup

Return type:

BackupStatus

get_statusmessage(id: int) str

get_statusmessage retrieves the latest status message for a backup id

This is equivalent to the console output of AzCopy

Parameters:

id (int) – Id of the backup to retrieve the status for

Returns:

The statusmessage of the backup (console output)

Return type:

str

monitor_backup(id: int, poll_interval: int = 30)

monitor_backup Monitors a backup with a certain id

_extended_summary_

Parameters:
  • id (int) – id to monitor. This ID can be retrieved while creating the job

  • poll_interval (int, optional) – Polling the monitoring job every X seconds. Defaults to 30.

Raises:

BackupError – Whenever an error occured, BackupError will be raised