The LabStats object

The LabStats API “Starter Session”. Start here to get anywhere in the API

exception labstats_api.labstats.KeyNotGivenError

Thrown when no API key is given

class labstats_api.labstats.LabStats(api_url, api_key, session=None)

A LabStats API session.

The LabStats object is the “starter” object for using LabStats API. Most API operations will start from here.

See the LabStats REST API Documentation for more information on REST API calls. See Usage for information on using LabStats API.

Parameters:
  • api_url – URL of your LabStats server’s API. If you have a hosted instance, see API Documentation and Testing. Otherwise, your API URL will be specific to your self-hosted instance.
  • api_key – API authorization key to query the LabStats server with. See API Key Creation for more information.
  • session – A Requests Session object to use for this instance. See Advanced Usage – Requests for more information. If you’re unsure if you need this, you probably don’t. If this option is omitted (or is None), a Session will be created for you.
get_app(application, **kwargs)

Gets a single [Application] from a LabStats account

Parameters:application (labstats_api.models.Application or int) – The application to query for.
Returns:labstats_api.models.Application
Calls:/apps/{id}/
get_app_tags(**kwargs)

Gets a list of all of the application tags from a LabStats account

Returns:list of str
Calls:/apps/tags/
get_apps(type=None, search=None, limit=300, after_id=1, **kwargs)

Gets a list of all the Applications from a LabStats account

Parameters:
  • type – The type of application to receive. Valid values are "catalog", "inventory", or "user_defined".
  • search (str) – A search term used to filter applications
  • limit – See Limit
  • after_id – See The After ID
Returns:

list of labstats_api.models.Application

Calls:

/apps/

Additional parameters to the request can be passed as kwargs

get_group(group, **kwargs)

Gets a single Group from a LabStats account

Parameters:group (models.Group or int) – Group to query for
Returns:models.Group
Calls:/groups/{id}/
get_groups(search=None, contents=None, has_lab_features_enabled=None, capability=None, **kwargs)

Gets a list of all the Groups from a LabStats account

Parameters:
  • search – Search term
  • contents"stations" or "groups"
  • has_lab_features_enabled – Whether lab features are enabled or not
  • capability – Search for a single lab capability
Returns:

list of models.Group

Calls:

/groups/

get_station(station, **kwargs)

Gets a single Station from a LabStats account

Parameters:group (models.Group or int) – Group to query for
Returns:models.Group
Calls:/stations/{id}/
get_station_tag_groups(**kwargs)

Gets a list of Station Tag groups which organize Tags for Stations.

Return type:List of models.StationTagGroup
Calls:/stations/tag_groups
get_station_tags(**kwargs)

Gets all of the Station Tags which organize Stations

Return type:List of str
Calls:/stations/tags
get_stations(status=None, os=None, form_factor=None, has_application=None, limit=200, after_id=1, **kwargs)

Gets a list of all the Stations from a LabStats account.

Parameters:
  • status – Filter based on the state of the machine. Valid values are "powered_on", "offline", "in_use", or None.
  • os – Filter based on the machine’s operating system. Valid values are "windows", "macos", or None.
  • form_factor – Filter based on the machine’s form factor. Valid values are "desktop" or "laptop".
  • has_application (int or models.Application) – Filter based on whether the machine has this application installed.
  • limit – See Limit
  • after_id – See The After ID
get_stations_with_tag(tag, limit=200, after_id=1, **kwargs)

Gets all of the stations that have the given tag.

exception labstats_api.labstats.URLNotGivenError

Thrown when no API URL is given