# profitbricks_client

command line tool for the public ProfitBricks API

exception `profitbricks_client.``ClientTooNewException`

  Bases: `exceptions.Exception`

  Raised when the ProfitBricks client is too new in general or for a specified API version.

exception `profitbricks_client.``ClientTooOldException`

  Bases: `exceptions.Exception`

  Raised when the ProfitBricks client is too old in general or for a specified API version.

exception `profitbricks_client.``SupportMatrixMalformedException`

  Bases: `exceptions.Exception`

  Raised when the downloaded support matrix file is malformed and failed to be parsed.

exception `profitbricks_client.``UnknownAPIVersionException`

  Bases: `exceptions.Exception`

  Raised when an unknown API version was requested.

exception `profitbricks_client.``WrongCredentialsException`

  Bases: `exceptions.Exception`

  Raised when an API calls fails due to a wrong username and password.

`profitbricks_client.``clear_cache`()

  Delete all information regarding the client and WSDL by removing the cache directory.

`profitbricks_client.``clear_credentials`(config=None)

  Delete username and password from configuration file and from the keyring.

`profitbricks_client.``get_config`()

  Return a user configuration object.

`profitbricks_client.``get_endpoint`(api_version=None, endpoint=None, config=None, store=True, default='latest')

  Return the endpoint for the WSDL service.

  Parameters:

  - api_version – Specify the version of the API that should be used
  - endpoint – Specify an URL that should be used as endpoint
  - config – configuration object that stores the endpoint URL
  - store – Specify if the selected endpoint should be stored in the configuration.
  - default – Default API version that should be used if no endpoint or version is specified

  If no API version or endpoint is specified, the previously stored endpoint will be returned. If no endpoint was stored (e.g. first script execution), the endpoint for given default API version will be returned.

  If api_version is specified, the endpoint for this API version will be retrieved. If endpoint is specified, this endpoint will be returned. If both api_version and endpoint is specified, the endpoint for the given API version must match the given endpoint. Otherwise an exception will be raised.

  When store_selection is set to True, the returned endpoint will be stored in the configuration file and can be used for the following calls of this function.

`profitbricks_client.``get_password`(username, config=None)

  Return the password for the given username.

  This function tries to get the password from the user’s keyring. The user is asked for the password if the password is not available.

`profitbricks_client.``get_profitbricks_client`(username=None, password=None, api_version=None, endpoint=None, config=None, store_endpoint=True, timeout=180)

  Connect to the API and return a ProfitBricks client object.

  If username is not specified, `get_username()` is used to retrieve the username. If password is not specified, `get_password()` is used for determining the password. api_version, endpoint, and store_endpoint are passed to a `get_endpoint()` call to calculate the endpoint.

  A connection to the ProfitBricks public API is made and ProfitBricks client object is created. All available API calls will become methods of the returned client object.

  An `urllib2.URLError` will be raised when the connection to the API failed. No error will be raised when the credentials are wrong, but method calls will raise a `WrongCredentialsException`.

`profitbricks_client.``get_username`(config=None)

  Return the username.

  The username is read from the configuration file. The user is asked for the username if the username is not available. The username is then stored in the configuration file.

`profitbricks_client.``main`()

  Main function for the command line client.

  The command line arguments are parsed and the corresponding actions are triggered. The function returns 0 on success and a positive, non-zero value on error.