v16.0.0

Welcome to the balena python SDK documentation. This document aims to describe all the functions supported by the SDK, as well as showing examples of their expected usage.

Install the Balena SDK:

From Pip:

pip install balena-sdk

From Source (In case, you want to test a development branch):

https://github.com/balena-io/balena-sdk-python

Getting started:

>>> from balena import Balena
>>> balena = Balena()
>>> credentials = {'username':<your email>, 'password':<your password>}
>>> balena.auth.login(**credentials)
...

The Balena object can be configured with a dict of type Settings

balena = Balena({
    "balena_host": "balena-cloud.com",
    "api_version": "v7",
    "device_actions_endpoint_version": "v1",
    "data_directory": "/home/example/.balena",
    "image_cache_time": str(1 * 1000 * 60 * 60 * 24 * 7), # 1 week
    "token_refresh_interval": str(1 * 1000 * 60 * 60),    # 1 hour
    "timeout": str(30 * 1000),                            # request timeout, 30s
    "request_limit": str(300), # the number of requests per request_limit_interval that the SDK should respect, defaults to unlimited.
    "request_limit_interval": str(60), # the timespan that the request_limit should apply to in seconds, defaults to 60s (1 minute).
    "retry_rate_limited_request": False, # awaits and retry once a request is rate limited (429)
})

Notice that if you want to change for the staging environment, you could simply do: balena = Balena({"balena_host": "balena-staging.com"})

However, this will overwrite your balena-cloud settings (stored api keys etc). So we recommend using a different data_directory for each balena-sdk instance, e.g:

In adition, you can also run balena-python-sdk completely in memory, without writing anything to the file system like:

By default the SDK will throw once a request is Rate limited by the API (with a 429 status code). A 429 request will contain a header called "retry-after" which informs how long the client should wait before trying a new request. If you would like the SDK to use this header and wait and automatically retry the request, just do:

If you feel something is missing, not clear or could be improved, please don't hesitate to open an issue in GitHubarrow-up-right, we'll be happy to help.

Table of Contents

Models

This module implements all models for balena python SDK.

Application

This class implements application model for balena python SDK.

Function: create(name, device_type, organization, application_class) ⇒ TypeApplication

Create an application.

Args:

Returns:

Examples:

Function: disable_device_urls(slug_or_uuid_or_id) ⇒ None

Disable device urls for all devices that belong to an application.

Args:

Examples:

Function: enable_device_urls(slug_or_uuid_or_id) ⇒ None

Enable device urls for all devices that belong to an application

Args:

Examples:

Function: generate_provisioning_key(slug_or_uuid_or_id, key_name, description, expiry_date) ⇒ str

Generate a device provisioning key for a specific application.

Args:

Returns:

Examples:

Function: get(slug_or_uuid_or_id, options, context) ⇒ TypeApplication

Get a single application.

Args:

Returns:

Examples:

Function: get_all(options, context) ⇒ List[TypeApplication]

Get all applications

Args:

Returns:

Examples:

Function: get_all_by_organization(org_handle_or_id, options) ⇒ List[TypeApplication]

Get all applications of an organization.

Args:

Returns:

Examples:

Function: get_all_directly_accessible(options) ⇒ List[TypeApplication]

Get all applications directly accessible by the user

Args:

Returns:

Examples:

Function: get_by_name(app_name, options, context) ⇒ TypeApplication

Get a single application using the appname.

Args:

Returns:

Examples:

Function: get_dashboard_url(app_id) ⇒ str

Get Dashboard URL for a specific application.

Args:

Returns:

Examples:

Function: get_directly_accessible(slug_or_uuid_or_id, options) ⇒ TypeApplication

Get a single application directly accessible by the user

Args:

Returns:

Examples:

Function: get_id(slug_or_uuid_or_id) ⇒ int

Given an application slug or uuid or id, returns it numeric id.

Args:

Returns:

Examples:

Function: get_target_release_hash(slug_or_uuid_or_id) ⇒ Optional[str]

Get the hash of the current release for a specific application.

Args:

Returns:

Examples:

Function: get_with_device_service_details(slug_or_uuid_or_id, options) ⇒ TypeApplicationWithDeviceServiceDetails

This method does not map exactly to the underlying model: it runs a larger prebuilt query, and reformats it into an easy to use and understand format. If you want more control, or to see the raw model directly, use application.get(uuidOrId, options) instead.

Args:

Returns:

Examples:

Function: grant_support_access(slug_or_uuid_or_id, expiry_timestamp) ⇒ None

Grant support access to an application until a specified time.

Args:

Examples:

Function: has(slug_or_uuid_or_id) ⇒ bool

Check if an application exists.

Args:

Returns:

Examples:

Function: has_any() ⇒ bool

Check if the user has any applications.

Returns:

Examples:

Function: is_tracking_latest_release(slug_or_uuid_or_id) ⇒ bool

Get whether the application is up to date and is tracking the latest finalized release for updates

Args:

Returns:

Examples:

Function: pin_to_release(slug_or_uuid_or_id, full_release_hash) ⇒ None

Configures the application to run a particular release and not get updated when the latest release changes.

Args:

Examples:

Function: purge(app_id) ⇒ None

Purge devices by application id

Args:

Examples:

Function: reboot(app_id, options) ⇒ None

Reboots devices by application id

Args:

Examples:

Function: remove(slug_or_uuid_or_id) ⇒ None

Remove application.

Args:

Examples:

Function: rename(slug_or_uuid_or_id, new_name) ⇒ None

Rename application.

Args:

Examples:

Function: restart(slug_or_uuid_or_id) ⇒ None

Restart application.

Args:

Examples:

Function: revoke_support_access(slug_or_uuid_or_id) ⇒ None

Revoke support access to an application.

Args:

Examples:

Function: shutdown(app_id, options) ⇒ None

Shutdown devices by application id

Args:

Examples:

Function: track_latest_release(slug_or_uuid_or_id) ⇒ None

Configure a specific application to track the latest available release.

Args:

Examples:

Function: will_track_new_releases(slug_or_uuid_or_id) ⇒ bool

Get whether the application is configured to receive updates whenever a new release is available.

Args:

Returns:

Examples:

ApplicationTag

This class implements application tag model for balena python SDK.

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[BaseTagType]

Get all application tags for an application.

Args:

Returns:

Examples:

Function: remove(slug_or_uuid_or_id, tag_key) ⇒ None

Remove an application tag.

Args:

Examples:

Function: set(slug_or_uuid_or_id, tag_key, value) ⇒ None

Set an application tag (update tag value if it exists).

Args:

Returns:

Examples:

ApplicationConfigVariable

This class implements application config variable model for balena python SDK.

Function: get(slug_or_uuid_or_id, env_var_name) ⇒ Optional[str]

Get application config variable.

Args:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all application config variables by application.

Args:

Returns:

Examples:

Function: remove(slug_or_uuid_or_id, key) ⇒ None

Remove an application config variable.

Args:

Examples:

Function: set(slug_or_uuid_or_id, env_var_name, value) ⇒ None

Set the value of a specific application config variable.

Args:

Examples:

ApplicationEnvVariable

This class implements application environment variable model for balena python SDK.

Function: get(slug_or_uuid_or_id, env_var_name) ⇒ Optional[str]

Get application environment variable.

Args:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all application environment variables by application.

Args:

Returns:

Examples:

Function: remove(slug_or_uuid_or_id, key) ⇒ None

Remove an application environment variable.

Args:

Examples:

Function: set(slug_or_uuid_or_id, env_var_name, value) ⇒ None

Set the value of a specific application environment variable.

Args:

Examples:

BuildEnvVariable

This class implements build environment variable model for balena python SDK.

Function: get(slug_or_uuid_or_id, env_var_name) ⇒ Optional[str]

Get build environment variable.

Args:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all build environment variables by application.

Args:

Returns:

Examples:

Function: remove(slug_or_uuid_or_id, key) ⇒ None

Remove an build environment variable.

Args:

Examples:

Function: set(slug_or_uuid_or_id, env_var_name, value) ⇒ None

Set the value of a specific build environment variable.

Args:

Examples:

ApplicationMembership

This class implements application membership model for balena python SDK.

Function: change_role(membership_id, role_name) ⇒ None

Changes the role of an application member.

Args:

Examples:

Function: create(slug_or_uuid_or_id, username, role_name) ⇒ ApplicationMembershipType

Creates a new membership for an application.

Args:

Returns:

Examples:

Function: get(membership_id, options) ⇒ ApplicationMembershipType

Get a single application membership.

Args:

Returns:

Examples:

Function: get_all(options) ⇒ List[ApplicationMembershipType]

Get all application memberships.

Args:

Returns:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[ApplicationMembershipType]

Get all memberships by application.

Args:

Returns:

Examples:

Function: remove(membership_id) ⇒ None

Remove a membership.

Args:

ApplicationInvite

This class implements application invite model for balena python SDK.

Function: accept(invite_token) ⇒ None

Accepts an invite.

Args:

Examples:

Function: create(slug_or_uuid_or_id, options) ⇒ ApplicationInviteType

Creates a new invite for an application.

Args:

Returns:

Examples:

Function: get_all(options) ⇒ List[ApplicationInviteType]

Get all invites.

Args:

Returns:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[ApplicationInviteType]

Get all invites by application.

Args:

Returns:

Examples:

Function: revoke(invite_id) ⇒ None

Revoke an invite.

Args:

Examples:

Device

This class implements device model for balena python SDK.

Function: deactivate(uuid_or_id_or_ids) ⇒ None

Deactivates a device.

Args:

Examples:

Function: disable_device_url(uuid_or_id_or_ids) ⇒ None

Disable device url for a device.

Args:

Examples:

Function: disable_local_mode(uuid_or_id) ⇒ None

Disable local mode.

Args:

Returns:

Examples:

Function: disable_lock_override(uuid_or_id) ⇒ None

Disable lock override.

Args:

Function: enable_device_url(uuid_or_id_or_ids) ⇒ None

Enable device url for a device.

Args:

Examples:

Function: enable_local_mode(uuid_or_id) ⇒ None

Enable local mode.

Args:

Examples:

Function: enable_lock_override(uuid_or_id) ⇒ None

Enable lock override.

Args:

Function: generate_device_key(uuid_or_id, name, description, expiry_date) ⇒ str

Generate a device key.

Args:

Examples:

Function: generate_uuid() ⇒ str

Generate a random device UUID.

Returns:

Examples:

Function: get(uuid_or_id, options) ⇒ TypeDevice

This method returns a single device by id or uuid.

Args:

Returns:

Examples:

Function: get_all(options) ⇒ List[TypeDevice]

This method returns all devices that the current user can access. In order to have the following computed properties in the result you have to explicitly define them in a $select in the extra options:

  • overall_status

  • overall_progress

  • is_frozen

Args:

Returns:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[TypeDevice]

Get devices by application slug, uuid or id.

Args:

Returns:

Examples:

Function: get_all_by_organization(handle_or_id, options) ⇒ List[TypeDevice]

Get devices by organization slug, uuid or id.

Args:

Returns:

Examples:

Function: get_application_info(uuid_or_id) ⇒ Any

Deprecated Return information about the application running on the device. This function requires supervisor v1.8 or higher.

Args:

Returns:

Examples:

Function: get_application_name(uuid_or_id) ⇒ str

Get application name by device uuid.

Args:

Returns:

Function: get_by_name(name, options) ⇒ List[TypeDevice]

Get devices by device name.

Args:

Returns:

Examples:

Function: get_dashboard_url(uuid) ⇒ None

Get balena Dashboard URL for a specific device.

Args:

Examples:

Function: get_device_url(uuid_or_id) ⇒ str

Get a device url for a device.

Args:

Examples:

Function: get_local_ip_address(uuid_or_id) ⇒ List[str]

Get the local IP addresses of a device.

Args:

Returns:

Function: get_local_mode_support(uuid_or_id) ⇒ LocalModeResponse

Returns whether local mode is supported and a message describing the reason why local mode is not supported.

Args:

Returns:

Examples:

Function: get_mac_address(uuid_or_id) ⇒ List[str]

Get the MAC addresses of a device.

Args:

Returns:

Function: get_metrics(uuid_or_id) ⇒ DeviceMetricsType

Gets the metrics related information for a device.

Args:

Returns:

Function: get_name(uuid_or_id) ⇒ str

Get device name by device uuid.

Args:

Returns:

Function: get_os_update_status(uuid_or_id) ⇒ HUPStatusResponse

Deprecated Get the OS update status of a device.

Args:

Returns:

Examples:

Function: get_status(uuid_or_id) ⇒ str

Get the status of a device.

Args:

Returns:

Examples:

Function: get_supervisor_state(uuid_or_id) ⇒ SupervisorStateType

Get the supervisor state on a device

Args:

Returns:

Examples:

Function: get_supervisor_target_state(uuid_or_id) ⇒ Any

Get the supervisor target state on a device

Args:

Returns:

Examples:

Function: get_supervisor_target_state_for_app(slug_or_uuid_or_id, release) ⇒ Any

Get the supervisor target state on a device

Args:

Returns:

Examples:

Function: get_with_service_details(uuid_or_id, options) ⇒ TypeDeviceWithServices

This method does not map exactly to the underlying model: it runs a larger prebuilt query, and reformats it into an easy to use and understand format. If you want more control, or to see the raw model directly, use device.get(uuidOrId, options) instead.

Args:

Returns:

Examples:

Function: grant_support_access(uuid_or_id_or_ids, expiry_timestamp) ⇒ None

Grant support access to a device until a specified time.

Args:

Examples:

Function: has(uuid_or_id) ⇒ bool

Check if a device exists.

Args:

Returns:

Function: has_device_url(uuid_or_id) ⇒ bool

Check if a device is web accessible with device urls

Args:

Examples:

Function: has_lock_override(uuid_or_id) ⇒ bool

Check if a device has the lock override enabled.

Args:

Returns:

Function: identify(uuid_or_id) ⇒ None

Identify device.

Args:

Examples:

Function: is_in_local_mode(uuid_or_id) ⇒ bool

Check if local mode is enabled on the device.

Args:

Returns:

Examples:

Function: is_online(uuid_or_id) ⇒ bool

Check if a device is online.

Args:

Returns:

Function: is_tracking_application_release(uuid_or_id) ⇒ bool

Get whether the device is configured to track the current application release.

Args:

Returns:

Function: move(uuid_or_id, app_slug_or_uuid_or_id) ⇒ None

Move a device to another application.

Args:

Examples:

Function: pin_to_release(uuid_or_id, full_release_hash_or_id) ⇒ None

Configures the device to run a particular release and not get updated when the current application release changes.

Args:

Examples:

Function: ping(uuid_or_id) ⇒ None

Ping a device. This is useful to signal that the supervisor is alive and responding.

Args:

Examples:

Function: purge(uuid_or_id) ⇒ None

Purge device. This function clears the user application's /data directory.

Args:

Examples:

Function: reboot(uuid_or_id, force) ⇒ None

Reboot the device.

Args:

Examples:

Function: register(application_slug_or_uuid_or_id, uuid, device_type_slug) ⇒ RegisterResponse

Register a new device with a balena application.

Args:

Returns:

Examples:

Function: remove(uuid_or_id_or_ids) ⇒ None

Remove device(s).

Args:

Function: rename(uuid_or_id, new_name) ⇒ None

Renames a device.

Args:

Examples:

Function: restart_application(uuid_or_id) ⇒ None

This function restarts the Docker container running the application on the device, but doesn't reboot the device itself.

Args:

Examples:

Function: restart_service(uuid_or_id, image_id) ⇒ None

Restart a service on device.

Args:

Examples:

Function: revoke_support_access(uuid_or_id_or_ids) ⇒ None

Revoke support access to a device.

Args:

Examples:

Function: set_custom_location(uuid_or_id_or_ids, location) ⇒ None

Set a custom location for a device.

Args:

Examples:

Function: set_note(uuid_or_id_or_ids, note) ⇒ None

Note a device.

Args:

Examples:

Function: set_supervisor_release(uuid_or_id, supervisor_version_or_id) ⇒ None

Set a specific device to run a particular supervisor release.

Args:

Examples:

Function: shutdown(uuid_or_id, force) ⇒ None

Shutdown the device.

Args:

Examples:

Function: start_application(uuid_or_id) ⇒ None

Deprecated Starts a user application container, usually after it has been stopped with stop_application(). This function requires supervisor v1.8 or higher.

Args:

Returns:

Examples:

Function: start_os_update(uuid_or_id, target_os_version) ⇒ HUPStatusResponse

Start an OS update on a device.

If using run_detached option, monitor progress with device.get() -- status, provisioning_state and provisioning_progress entries.

Args:

Returns:

Examples:

Function: start_service(uuid_or_id, image_id) ⇒ None

Start a service on device.

Args:

Examples:

Function: stop_application(uuid_or_id) ⇒ None

Deprecated Temporarily stops a user application container. Application container will not be removed after invoking this function and a reboot or supervisor restart will cause the container to start again. This function requires supervisor v1.8 or higher.

Args:

Returns:

Examples:

Function: stop_service(uuid_or_id, image_id) ⇒ None

Stop a service on device.

Args:

Examples:

Function: track_application_release(uuid_or_id_or_ids) ⇒ None

Configure a specific device to track the current application release.

Args:

Function: unset_custom_location(uuid_or_id_or_ids) ⇒ None

Clear the custom location of a device.

Args:

Examples:

Function: update(uuid_or_id, force) ⇒ None

update the device.

Args:

Examples:

DeviceTag

This class implements device tag model for balena python SDK.

Function: get(uuid_or_id, tag_key) ⇒ Optional[str]

Get a device tag (update tag value if it exists). Note: Notice that when using the device ID rather than UUID, it will avoid one extra API roundtrip.

Args:

Returns:

Examples:

Function: get_all(options) ⇒ List[BaseTagType]

Get all device tags.

Args:

Returns:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[BaseTagType]

Get all device tags for an application.

Args:

Returns:

Examples:

Function: get_all_by_device(uuid_or_id, options) ⇒ List[BaseTagType]

Get all device tags for a device.

Args:

Returns:

Examples:

Function: remove(uuid_or_id, tag_key) ⇒ None

Remove a device tag.

Args:

Examples:

Function: set(uuid_or_id, tag_key, value) ⇒ None

Set a device tag (update tag value if it exists). Note: Notice that when using the device ID rather than UUID, it will avoid one extra API roundtrip.

Args:

Examples:

DeviceConfigVariable

This class implements device config variable model for balena python SDK.

Function: get(uuid_or_id, env_var_name) ⇒ Optional[str]

Get a device config variable.

Args:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all device config variables for an application.

Args:

Returns:

Examples:

Function: get_all_by_device(uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all device config variables belong to a device.

Args:

Returns:

Examples:

Function: remove(uuid_or_id, key) ⇒ None

Remove a device environment variable.

Args:

Examples:

Function: set(uuid_or_id, env_var_name, value) ⇒ None

Set the value of a device config variable. Note that config variables must start with BALENA_ and RESIN_ prefixes.

Args:

Examples:

DeviceEnvVariable

This class implements device environment variable model for balena python SDK.

Function: get(uuid_or_id, env_var_name) ⇒ Optional[str]

Get device environment variable.

Args:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all device environment variables for an application.

Args:

Returns:

Examples:

Function: get_all_by_device(uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all device environment variables.

Args:

Returns:

Examples:

Function: remove(uuid_or_id, key) ⇒ None

Remove a device environment variable.

Args:

Examples:

Function: set(uuid_or_id, env_var_name, value) ⇒ None

Set the value of a specific environment variable.

Args:

Examples:

DeviceServiceEnvVariable

This class implements device service variable model for balena python SDK.

Function: get(uuid_or_id, service_name_or_id, key) ⇒ Optional[str]

Get the overriden value of a service variable on a device

Args:

Returns:

Optional[str]: device service environment variables.

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all device service environment variables belong to an application.

Args:

Returns:

Examples:

Function: get_all_by_device(uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all device environment variables.

Args:

Returns:

Examples:

Function: remove(uuid_or_id, service_name_or_id, key) ⇒ None

Remove a device service environment variable.

Args:

Examples:

Function: set(uuid_or_id, service_name_or_id, key, value) ⇒ None

Set the overriden value of a service variable on a device.

Args:

Examples:

DeviceHistory

This class implements device history model for balena python SDK.

Function: get_all_by_application(slug_or_uuid_or_id, from_date, to_date, options) ⇒ List[DeviceHistoryType]

Get all device history entries for an application.

Args:

Returns:

Examples:

Function: get_all_by_device(uuid_or_id, from_date, to_date, options) ⇒ List[DeviceHistoryType]

Get all device history entries for a device.

Args:

Returns:

Examples:

DeviceType

This class implements user API key model for balena python SDK.

Function: get(id_or_slug, options) ⇒ DeviceTypeType

Get a single device type.

Args:

Returns:

Function: get_all(options) ⇒ List[DeviceTypeType]

Get all device types.

Args:

Returns:

Function: get_all_supported(options) ⇒ None

Get all supported device types.

Args:

Returns:

Function: get_by_slug_or_name(slug_or_name, options) ⇒ DeviceTypeType

Get a single device type by slug or name.

Args:

Returns:

Function: get_name(slug) ⇒ str

Get display name for a device.

Args:

Function: get_slug_by_name(name) ⇒ str

Get device slug.

Args:

ApiKey

This class implements user API key model for balena python SDK.

Function: create(name, description, expiry_date) ⇒ str

This method registers a new api key for the current user with the name given.

Args:

Returns:

Examples:

Function: get_all(options) ⇒ List[APIKeyType]

This function gets all API keys.

Args:

Returns:

Examples:

Function: get_all_named_user_api_keys(options) ⇒ List[APIKeyType]

Get all named user API keys of the current user.

Args:

Examples:

Function: get_device_api_keys_by_device(uuid_or_id, options) ⇒ List[APIKeyType]

Get all API keys for a device.

Args:

Examples:

Function: get_provisioning_api_keys_by_application(slug_or_uuid_or_id, options) ⇒ List[APIKeyType]

Get all provisioning API keys for an application.

Args:

Examples:

Function: revoke(id) ⇒ None

This function revokes an API key.

Args:

Examples:

Function: update(id, api_key_info) ⇒ None

This function updates details of an API key.

Args:

Examples:

Key

This class implements ssh key model for balena python SDK.

Function: create(title, key) ⇒ SSHKeyType

Create a ssh key.

Args:

Returns:

Function: get(id) ⇒ SSHKeyType

Get a single ssh key.

Args:

Returns:

Function: get_all(options) ⇒ List[SSHKeyType]

Get all ssh keys.

Args:

Returns:

Function: remove(id) ⇒ None

Remove a ssh key.

Args:

Organization

This class implements organization model for balena python SDK.

Function: create(name, handle, logo_image) ⇒ OrganizationType

Creates a new organization.

Args:

Returns:

Examples:

Function: get(handle_or_id, options) ⇒ OrganizationType

Get a single organization.

Args:

Returns:

Raises:

Examples:

Function: get_all(options) ⇒ List[OrganizationType]

Get all organizations.

Args:

Returns:

Examples:

Function: remove(handle_or_id) ⇒ None

Remove an organization.

Args:

Examples:

OrganizationMembership

This class implements organization membership model for balena python SDK.

Function: get(membership_id, options) ⇒ OrganizationMembershipType

Get a single organization membership.

Args:

Returns:

Examples:

Function: get_all(options) ⇒ List[OrganizationMembershipType]

Get all organization memberships.

Args:

Returns:

Examples:

Function: get_all_by_organization(handle_or_id, options) ⇒ List[OrganizationMembershipType]

Get all memberships by organization.

Args:

Returns:

Examples:

OrganizationMembershipTag

This class implements organization membership tag model for balena python SDK.

Function: get(membership_id, tag_key) ⇒ Optional[str]

Get an organization membership tag.

Args:

Examples:

Function: get_all(options) ⇒ List[OrganizationMembershipTagType]

Get all organization membership tags.

Args:

Examples:

Function: get_all_by_organization(handle_or_id, options) ⇒ List[OrganizationMembershipTagType]

Get all organization membership tags for an organization.

Args:

Returns:

Examples:

Function: get_all_by_organization_membership(membership_id, options) ⇒ List[OrganizationMembershipTagType]

Get all organization membership tags for a memberships of an organization.

Args:

Returns:

Examples:

Function: remove(membership_id, tag_key) ⇒ None

Remove an organization membership tag.

Args:

Examples:

Function: set(membership_id, tag_key, value) ⇒ None

Set an organization membership tag.

Args:

Examples:

OrganizationInvite

This class implements organization invite model for balena python SDK.

Function: accept(invite_token) ⇒ None

Accepts an invite.

Args:

Function: create(handle_or_id, invitee, role_name, message) ⇒ OrganizationInviteType

Creates a new invite for an organization.

Args:

Returns:

Examples:

Function: get_all(options) ⇒ List[OrganizationInviteType]

Get all invites.

Args:

Returns:

Examples:

Function: get_all_by_organization(handle_or_id, options) ⇒ List[OrganizationInviteType]

Get all invites by organization.

Args:

Returns:

Examples:

Function: revoke(invite_id) ⇒ None

Revoke an invite.

Args:

Examples:

DeviceOs

This class implements device os model for balena python SDK.

Function: download(device_type, version, options) ⇒ None

Get OS download size estimate. Currently only the raw (uncompressed) size is reported.

Args:

Returns:

Example:

Function: get_all_os_versions(device_type, options) ⇒ None

Get all OS versions for the provided device type(s), inlcuding invalidated ones

Args:

Returns:

Function: get_available_os_versions(device_type) ⇒ None

Get the supported OS versions for the provided device type(s)

Args:

Returns:

Function: get_config(slug_or_uuid_or_id, options) ⇒ None

Download application config.json.

Args:

Returns:

Raises:

Function: get_download_size(device_type, version) ⇒ float

Get OS download size estimate. Currently only the raw (uncompressed) size is reported.

Args:

Returns:

Function: get_max_satisfying_version(device_type, version_or_range, os_type) ⇒ Optional[str]

Get OS download size estimate. Currently only the raw (uncompressed) size is reported.

Args:

Returns:

Function: get_supervisor_releases_for_cpu_architecture(cpu_architecture_slug_or_id, options) ⇒ List[ReleaseType]

Returns the Releases of the supervisor for the CPU Architecture

Args:

Returns:

Example: results = balena.models.os.get_supervisor_releases_for_cpu_architecture('aarch64'); results = balena.models.os.get_supervisor_releases_for_cpu_architecture( 'aarch64', { $filter: { raw_version: '12.11.0' } }, );

Function: get_supported_os_update_versions(device_type, current_version) ⇒ None

Get OS supported versions.

Args:

Function: is_architecture_compatible_with(os_architecture, application_architecture) ⇒ None

Returns whether the specified OS architecture is compatible with the target architecture.

Args:

Returns:

Function: is_supported_os_update(device_type, current_version, target_version) ⇒ bool

Returns the supported OS update targets for the provided device type.

Args:

Config

This class implements configuration model for balena python SDK.

Function: get_all() ⇒ ConfigType

Get all configuration.

Returns:

Examples:

Release

This class implements release model for balena python SDK.

Function: create_from_url(slug_or_uuid_or_id, url, flatten_tarball) ⇒ int

Create a new release built from the source in the provided url.

Args:

Returns:

Function: finalize(commit_or_id_or_raw_version) ⇒ None

Finalizes a draft release.

Args:

Function: get(commit_or_id_or_raw_version, options) ⇒ ReleaseType

Get a specific release.

Args:

Returns:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[ReleaseType]

Get all releases from an application.

Args:

Returns:

Function: get_latest_by_application(slug_or_uuid_or_id, options) ⇒ Optional[ReleaseType]

Get the latest successful release for an application.

Args:

Returns:

Function: get_with_image_details(commit_or_id_or_raw_version, image_options, release_options) ⇒ ReleaseWithImageDetailsType

Get a specific release with the details of the images built.

Args:

Returns:

Raises:

Function: set_is_invalidated(commit_or_id_or_raw_version, is_invalidated) ⇒ None

Set the is_invalidated property of a release to True or False.

Args:

Function: set_known_issue_list(commit_or_id_or_raw_version, known_issue_list) ⇒ None

Set a known issue list for a release.

Args:

Function: set_note(commit_or_id_or_raw_version, note) ⇒ None

Set a note for a release.

Args:

Function: set_release_version(commit_or_id, semver) ⇒ None

Set a direct semver for a given release.

Args:

ReleaseTag

This class implements release tag model for balena python SDK.

Function: get(commit_or_id_or_raw_version, tag_key) ⇒ Optional[str]

Get a single release tag.

Args:

Examples:

Function: get_all(options) ⇒ List[BaseTagType]

Get all release tags.

Args:

Returns:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[BaseTagType]

Get all device tags for an application.

Args:

Returns:

Examples:

Function: get_all_by_release(commit_or_id_or_raw_version, options) ⇒ List[BaseTagType]

Get all release tags for a release.

Args:

Returns:

Examples:

Function: remove(commit_or_id_or_raw_version, tag_key) ⇒ None

Remove a release tag.

Args:

Examples:

Function: set(commit_or_id_or_raw_version, tag_key, value) ⇒ None

Set a release tag (update tag value if it exists).

Args:

Examples:

Service

This class implements service model for balena python SDK.

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[ServiceType]

Get all services from an application.

Args:

Returns:

ServiceEnvVariable

This class implements Service environment variable model for balena python SDK.

Function: get(service_id_or_natural_key, key) ⇒ Optional[str]

Get the value of a specific service variable

Args:

Examples:

Function: get_all_by_application(slug_or_uuid_or_id, options) ⇒ List[EnvironmentVariableBase]

Get all service variables by application.

Args:

Returns:

Examples:

Function: get_all_by_service(service_id_or_natural_key, options) ⇒ List[EnvironmentVariableBase]

Get all variables for a service.

Args:

Returns:

Examples:

Function: remove(service_id_or_natural_key, key) ⇒ None

Clear the value of a specific service variable

Args:

Examples:

Function: set(service_id_or_natural_key, key, value) ⇒ None

Set the value of a specific application environment variable.

Args:

Examples:

Image

This class implements image model for balena python SDK.

Function: get(id, options) ⇒ ImageType

Get a specific image.

Args:

Returns:

Function: get_logs(id) ⇒ str

Get the build log from an image.

Args:

Returns:

Auth

This class implements all authentication functions for balena python SDK.

Function: authenticate() ⇒ str

This function authenticates provided credentials information. You should use Auth.login when possible, as it takes care of saving the Auth Token and username as well.

Args:

Returns:

Examples:

Function: get_actor_id() ⇒ int

Get current logged in actor id.

Returns:

Examples:

Function: get_token() ⇒ Optional[str]

This function retrieves Auth Token.

Returns:

Examples:

Function: get_user_info() ⇒ UserInfo

Get current logged in user's info

Returns:

Examples:

Function: is_logged_in() ⇒ bool

This function checks if you're logged in

Returns:

Examples:

Function: login() ⇒ None

This function is used for logging into balena using email and password.

Args:

Examples:

Function: login_with_token(token) ⇒ None

This function is used for logging into balena using Auth Token. Auth Token can be found in Preferences section on balena Dashboard.

Args:

Returns:

Examples:

Function: logout() ⇒ None

This function is used for logging out from balena.

Examples:

Function: register() ⇒ str

This function is used for registering to balena.

Args:

Returns:

Examples:

Function: whoami() ⇒ Union[UserKeyWhoAmIResponse, ApplicationKeyWhoAmIResponse, DeviceKeyWhoAmIResponse, None]

Return current logged in username.

Returns:

Examples:

TwoFactorAuth

This class implements basic 2FA functionalities for balena python SDK.

Function: challenge(code) ⇒ None

Challenge two-factor authentication. If your account has two-factor authentication enabled and logging in using credentials, you need to pass two-factor authentication before being allowed to use other functions.

Args:

Examples:

Function: disable(password) ⇒ str

Disable two factor authentication. Note: Disable will only work when using a token that has 2FA enabled.

Args:

Returns:

Examples:

Function: enable(code) ⇒ str

Enable two factor authentication.

Args:

Returns:

Examples:

Function: get_setup_key() ⇒ str

Retrieves a setup key for enabling two factor authentication. This value should be provided to your 2FA app in order to get a token. This function only works if you disable two-factor authentication or log in using Auth Token from dashboard.

Returns:

Examples:

Function: is_enabled() ⇒ bool

Check if two-factor authentication is enabled.

Returns:

Examples:

Function: is_passed() ⇒ bool

Check if two-factor authentication challenge was passed. If the user does not have 2FA enabled, this will be True.

Returns:

Examples:

Function: verify(code) ⇒ str

Verifies two factor authentication. Note that this method not update the token automatically. You should use balena.twofactor_auth.challenge() when possible, as it takes care of that as well.

Args:

Returns:

Examples:

Logs

This class implements functions that allow processing logs from device.

Function: history(uuid_or_id, count) ⇒ List[Log]

Get device logs history.

Args:

Function: stop() ⇒ None

Will grecefully unsubscribe from all devices and stop the consumer thread.

Function: subscribe(uuid_or_id, callback, error, count) ⇒ None

Subscribe to device logs.

Args:

Function: unsubscribe(uuid_or_id) ⇒ None

Unsubscribe from device logs for a specific device.

Args:

Function: unsubscribe_all() ⇒ None

Unsubscribe all subscribed devices.

Settings

Create a module object.

The name must be a string; the optional doc argument can have any type.

Types

APIKeyInfoType

APIKeyType

ActorType

ApplicationHostedOnApplication

ApplicationInviteType

ApplicationMembershipRoleType

ApplicationMembershipType

ApplicationType

BaseTagType

BasicUserInfoType

CpuArchitectureType

CreditBundleType

DeviceFamilyType

DeviceHistoryType

DeviceManufacturerType

DeviceMetricsType

DeviceTypeAliasType

DeviceTypeType

EnvironmentVariableBase

ImageBasicInfoType

ImageInstallType

ImageType

InviteeType

OrganizationInviteType

OrganizationMembershipRoleType

OrganizationMembershipTagType

OrganizationMembershipType

OrganizationPrivateDeviceTypeAccess

OrganizationType

PineDeferred

PublicDeviceType

PublicOrganizationType

ReleaseImageType

ReleaseType

ReleaseVersion

ReleaseWithImageDetailsType

SSHKeyType

ServiceInstanceType

ServiceType

TeamApplicationAccessType

TeamMembershipType

TeamType

TypeApplication

TypeApplicationWithDeviceServiceDetails

TypeCurrentService

TypeDevice

TypeDeviceWithServices

TypeVar

TypedDict

UserType

WebResource

Last updated

Was this helpful?