HaloSession

class cloudpassage.HaloSession(apikey, apisecret, **kwargs)

Create a Halo API connection object.

On instantiation, it will attempt to authenticate against the Halo API using the apikey and apisecret provided, together with any overrides passed in through kwargs.

Parameters:
  • apikey (str) – API key, retrieved from your CloudPassage Halo account
  • apisecret (str) – API key secret, found with your API key in your CloudPassage Halo account
Keyword Arguments:
 
  • api_host (str) – Override the API endpoint hostname. Defaults to api.cloudpassage.com.
  • api_port (str) – Override the API HTTPS port Defaults to 443.
  • proxy_host (str) – Hostname or IP address of proxy
  • proxy_port (str) – Port for proxy. Ignored if proxy_host is not set
  • user_agent (str) – Override for UserAgent string. We set this so that we can see what tools are being used in the field and set our development focus accordingly. To override the default, feel free to pass this kwarg in.
  • integration_string (str) – If set, this will cause the user agent string to include an identifier for the integration being used.
authenticate_client()

This method attempts to set an OAuth token

Call this method and it will use the API key and secret as well as the proxy settings (if used) to authenticate this HaloSession instance.

build_endpoint_prefix()

This constructs everything to the left of the file path in the URL.

build_header()

This constructs the auth header, required for all API interaction.

classmethod build_proxy_struct(host, port)

This builds a structure describing the environment’s HTTP proxy requirements.

It returns a dictionary object that can be passed to the requests module.

classmethod get_auth_token(endpoint, headers)

This method takes endpoint and header info, and returns the oauth token and scope.

Parameters:
  • endpoint (str) – Full URL, including schema.
  • headers (dict) – Dictionary, containing header with encoded credentials.

Example

{“Authorization”: str(“Basic ” + encoded)}