composer Package

composer Package

http_client Module

composer.http_client.api_url(api_version, url)[source]

Return the versioned path to the API route

Parameters:
  • api_version (str) – The version of the API to talk to. eg. “0”
  • url (str) – The API route to talk to
Returns:

The full url to use for the route and API version

Return type:

str

composer.http_client.delete_url_json(socket_path, url)[source]

Send a DELETE request to the url and return JSON response

Parameters:
  • socket_path (str) – Path to the Unix socket to use for API communication
  • url (str) – URL to send DELETE to
Returns:

The json response from the server

Return type:

dict

composer.http_client.download_file(socket_path, url, progress=True)[source]

Download a file, saving it to the CWD with the included filename

Parameters:
  • socket_path (str) – Path to the Unix socket to use for API communication
  • url (str) – URL to send POST to
composer.http_client.get_filename(headers)[source]

Get the filename from the response header

Parameters:response (Response) – The urllib3 response object
Raises :RuntimeError if it cannot find a filename in the header
Returns:Filename from content-disposition header
Return type:str
composer.http_client.get_url_json(socket_path, url)[source]

Return the JSON results of a GET request

Parameters:
  • socket_path (str) – Path to the Unix socket to use for API communication
  • url (str) – URL to request
Returns:

The json response from the server

Return type:

dict

composer.http_client.get_url_raw(socket_path, url)[source]

Return the raw results of a GET request

Parameters:
  • socket_path (str) – Path to the Unix socket to use for API communication
  • url (str) – URL to request
Returns:

The raw response from the server

Return type:

str

composer.http_client.post_url(socket_path, url, body)[source]

POST raw data to the URL

Parameters:
  • socket_path (str) – Path to the Unix socket to use for API communication
  • url (str) – URL to send POST to
  • body (str) – The data for the body of the POST
Returns:

The json response from the server

Return type:

dict

composer.http_client.post_url_json(socket_path, url, body)[source]

POST some JSON data to the URL

Parameters:
  • socket_path (str) – Path to the Unix socket to use for API communication
  • url (str) – URL to send POST to
  • body (str) – The data for the body of the POST
Returns:

The json response from the server

Return type:

dict

composer.http_client.post_url_toml(socket_path, url, body)[source]

POST a TOML string to the URL

Parameters:
  • socket_path (str) – Path to the Unix socket to use for API communication
  • url (str) – URL to send POST to
  • body (str) – The data for the body of the POST
Returns:

The json response from the server

Return type:

dict

unix_socket Module

class composer.unix_socket.UnixHTTPConnection(socket_path, timeout=60)[source]

Bases: httplib.HTTPConnection, object

connect()[source]
class composer.unix_socket.UnixHTTPConnectionPool(socket_path, timeout=60)[source]

Bases: urllib3.connectionpool.HTTPConnectionPool

Table Of Contents

Previous topic

src

Next topic

cli Package

This Page