Alpine

class alpine.apiclient.APIClient(host=None, port=None, username=None, password=None, is_secure=False, validate_certs=False, ca_certs=None, token=None, logging_level='WARN')

The main entry point for the Alpine API. Most of the functions require a logged-in user. Begin a session by creating an instance of the APIClient class.

Example:

>>> import alpine as AlpineAPI
>>> session = alpine.APIClient(host, port, username, password)
get_license()

Get the the current license information for Alpine.

Returns:Summary of Alpine license information - expiration, user limits, add-ons, etc.
Return type:dict

Example:

>>> license_info = session.get_license()
get_status()

Returns information about the currently logged-in user. Or, if no user is logged in, returns an empty dict.

Returns:Logged-in user’s metadata.
Return type:dict

Example:

>>> session.get_status()
{u'admin': True,
 u'auth_method': u'internal',
 u'dept': u'Development',
 u'email': u'demoadmin@alpinenow.com',
 u'entity_type': u'user',
 u'first_name': u'Demo',
 u'id': 665,
 u'image': {u'complete_json': True,
  u'entity_type': u'image',
  u'icon': u'/users/665/image?style=icon&1483606634',
  u'original': u'/users/665/image?style=original&1483606634'},
 u'is_deleted': None,
 u'last_name': u'Admin',
 u'ldap_group_id': None,
 u'notes': u'',
 u'roles': [u'admin'],
 u'subscribed_to_emails': True,
 u'tags': [],
 u'title': u'Assistant to the Regional Manager',
 u'user_type': u'analytics_developer',
 u'username': u'demoadmin',
 u'using_default_image': True}
get_version()

Returns the Alpine version.

Returns:Alpine version.
Return type:str

Example:

>>> session.get_version()
'6.2.0.0.1-b8c02ca46'
login(username, password)

Attempts to log in to Alpine with provided username and password. Typically login is handled at session creation time.

Parameters:
  • username (str) – Username to log in with.
  • password (str) – Password to log in with.
Returns:

Logged-in user’s metadata.

Return type:

dict

Example:

>>> user_info = session.login(username, password)
logout()

Attempts to log out the current user.

Returns:Request response.
Return type:requests.models.Response

Example:

>>> session.logout()
<Response [200]>