balena-sdk
Version:
The Balena JavaScript SDK
1,268 lines (1,267 loc) • 122 kB
TypeScript
import type { InjectedOptionsParam, InjectedDependenciesParam, CurrentService } from '..';
import type { Device, DeviceServiceEnvironmentVariable, DeviceTag, DeviceHistory, DeviceConfigVariable, DeviceEnvironmentVariable } from '../types/models';
import { DeviceOverallStatus as OverallStatus } from '../types/device-overall-status';
import type * as DeviceState from '../types/device-state';
import type { OsUpdateActionResult } from '../util/device-actions/os-update';
import { type MergePineOptions } from '../util';
import { getCurrentServiceDetailsPineExpand } from '../util/device-service-details';
import { LOCAL_MODE_SUPPORT_PROPERTIES } from '../util/local-mode';
import type { AtLeast, Dictionary } from '../../typings/utils';
import type { DeviceType } from '../types/models';
import type { FilterObj, ODataOptionsWithoutCount, OptionsToResponse } from 'pinejs-client-core';
export * as DeviceState from '../types/device-state';
export type { DeviceOverallStatus as OverallStatus } from '../types/device-overall-status';
export type { SupervisorStatus } from './device.supervisor-api.partial';
export type DeviceMetrics = Pick<Device['Read'], 'memory_usage' | 'memory_total' | 'storage_block_device' | 'storage_usage' | 'storage_total' | 'cpu_usage' | 'cpu_temp' | 'cpu_id' | 'is_undervolted'>;
export interface DateFilters {
fromDate?: Date;
toDate?: Date;
}
declare const getDeviceModel: (deps: InjectedDependenciesParam, opts: InjectedOptionsParam) => {
/**
* @summary Get the target supervisor state on a device
* @name getSupervisorTargetState
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Number} version - (optional) target state version (2 or 3), default to 2
* @returns {Promise}
*
* @example
* balena.models.device.getSupervisorTargetState('7cf02a6').then(function(state) {
* console.log(state);
* });
*
* @example
* balena.models.device.getSupervisorTargetState(123).then(function(state) {
* console.log(state);
* });
*
* @example
* balena.models.device.getSupervisorTargetState(123, 3).then(function(state) {
* console.log(state);
* });
*/
getSupervisorTargetState: (uuidOrId: string | number, version?: 2 | 3) => Promise<DeviceState.DeviceState>;
/**
* @summary Get the target supervisor state on a "generic" device on a fleet
* @name getSupervisorTargetStateForApp
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - fleet uuid (string) or id (number)
* @param {String} release - (optional) release uuid (default tracked)
* @returns {Promise}
*
* @example
* balena.models.device.getSupervisorTargetStateForApp('7cf02a6').then(function(state) {
* console.log(state);
* });
*
* @example
* balena.models.device.getSupervisorTargetStateForApp(123).then(function(state) {
* console.log(state);
* });
*
* @example
* balena.models.device.getSupervisorTargetStateForApp(123, '7cf02a6').then(function(state) {
* console.log(state);
* });
*
*/
getSupervisorTargetStateForApp: (slugOrUuidOrId: string | number, release?: string | number) => Promise<DeviceState.DeviceStateV3>;
/**
* @summary Generate a random key, useful for both uuid and api key.
* @name generateUniqueKey
* @function
* @public
* @memberof balena.models.device
*
* @returns {String} A generated key
*
* @example
* randomKey = balena.models.device.generateUniqueKey();
* // randomKey is a randomly generated key that can be used as either a uuid or an api key
* console.log(randomKey);
*/
generateUniqueKey(): string;
/**
* @summary Register a new device with a Balena application.
* @name register
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} applicationSlugOrUuidOrId - application slug (string), uuid (string) or id (number)
* @param {String} uuid - device uuid
* @param {String} [deviceTypeSlug] - device type slug (string) or alias (string)
*
* @fulfil {Object} Device registration info ({ id: "...", uuid: "...", api_key: "..." })
* @returns {Promise}
*
* @example
* var uuid = balena.models.device.generateUniqueKey();
* balena.models.device.register('myorganization/myapp', uuid).then(function(registrationInfo) {
* console.log(registrationInfo);
* });
*
* @example
* var uuid = balena.models.device.generateUniqueKey();
* balena.models.device.register('myorganization/myapp', uuid, 'raspberry-pi').then(function(registrationInfo) {
* console.log(registrationInfo);
* });
*
* @example
* var uuid = balena.models.device.generateUniqueKey();
* balena.models.device.register(123, uuid).then(function(registrationInfo) {
* console.log(registrationInfo);
* });
*/
register(applicationSlugOrUuidOrId: string | number, uuid: string, deviceTypeSlug?: string): Promise<{
id: number;
uuid: string;
api_key: string;
}>;
/**
* @summary Generate a device key
* @name generateDeviceKey
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} [keyName] - Device key name
* @param {String} [keyDescription] - Description for device key
* @returns {Promise}
*
* @example
* balena.models.device.generateDeviceKey('7cf02a6').then(function(deviceApiKey) {
* console.log(deviceApiKey);
* });
*
* @example
* balena.models.device.generateDeviceKey(123).then(function(deviceApiKey) {
* console.log(deviceApiKey);
* });
*/
generateDeviceKey: (uuidOrId: string | number, keyName?: string, keyDescription?: string, keyExpiryDate?: string) => Promise<string>;
/**
* @summary Check if a device is web accessible with device utls
* @name hasDeviceUrl
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @fulfil {Boolean} - has device url
* @returns {Promise}
*
* @example
* balena.models.device.hasDeviceUrl('7cf02a6').then(function(hasDeviceUrl) {
* if (hasDeviceUrl) {
* console.log('The device has device URL enabled');
* }
* });
*
* @example
* balena.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) {
* if (hasDeviceUrl) {
* console.log('The device has device URL enabled');
* }
* });
*/
hasDeviceUrl: (uuidOrId: string | number) => Promise<boolean>;
/**
* @summary Get a device url
* @name getDeviceUrl
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @fulfil {String} - device url
* @returns {Promise}
*
* @example
* balena.models.device.getDeviceUrl('7cf02a6').then(function(url) {
* console.log(url);
* });
*
* @example
* balena.models.device.getDeviceUrl(123).then(function(url) {
* console.log(url);
* });
*/
getDeviceUrl: (uuidOrId: string | number) => Promise<string>;
/**
* @summary Enable device url for a device
* @name enableDeviceUrl
* @public
* @function
* @memberof balena.models.device
*
* @param {String|String[]|Number|Number[]} uuidOrIdOrArray - device uuid (string) or id (number) or array of full uuids or ids
* @returns {Promise}
*
* @example
* balena.models.device.enableDeviceUrl('7cf02a6');
*
* @example
* balena.models.device.enableDeviceUrl(123);
*/
enableDeviceUrl: (uuidOrIdOrArray: string | string[] | number | number[]) => Promise<void>;
/**
* @summary Disable device url for a device
* @name disableDeviceUrl
* @public
* @function
* @memberof balena.models.device
*
* @param {String|String[]|Number|Number[]} uuidOrIdOrArray - device uuid (string) or id (number) or array of full uuids or ids
* @returns {Promise}
*
* @example
* balena.models.device.disableDeviceUrl('7cf02a6');
*
* @example
* balena.models.device.disableDeviceUrl(123);
*/
disableDeviceUrl: (uuidOrIdOrArray: string | string[] | number | number[]) => Promise<void>;
/**
* @summary Enable local mode
* @name enableLocalMode
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.enableLocalMode('7cf02a6');
*
* @example
* balena.models.device.enableLocalMode(123);
*/
enableLocalMode(uuidOrId: string | number): Promise<void>;
/**
* @summary Disable local mode
* @name disableLocalMode
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.disableLocalMode('7cf02a6');
*
* @example
* balena.models.device.disableLocalMode(123);
*/
disableLocalMode: (uuidOrId: string | number) => Promise<void>;
/**
* @summary Check if local mode is enabled on the device
* @name isInLocalMode
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @fulfil {Boolean} - has device url
* @returns {Promise}
*
* @example
* balena.models.device.isInLocalMode('7cf02a6').then(function(isInLocalMode) {
* if (isInLocalMode) {
* console.log('The device has local mode enabled');
* }
* });
*
* @example
* balena.models.device.isInLocalMode(123).then(function(isInLocalMode) {
* if (isInLocalMode) {
* console.log('The device has local mode enabled');
* }
* });
*/
isInLocalMode: (uuidOrId: string | number) => Promise<boolean>;
/**
* @summary Returns whether local mode is supported along with a message describing the reason why local mode is not supported.
* @name getLocalModeSupport
* @public
* @function
* @memberof balena.models.device
*
* @param {Object} device - A device object
* @returns {Object} Local mode support info ({ supported: true/false, message: "..." })
*
* @example
* balena.models.device.get('7cf02a6').then(function(device) {
* balena.models.device.getLocalModeSupport(device);
* })
*/
getLocalModeSupport: (device: AtLeast<Device["Read"], (typeof LOCAL_MODE_SUPPORT_PROPERTIES)[number]>) => {
supported: boolean;
message: string;
};
/**
* @summary Enable lock override
* @name enableLockOverride
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.enableLockOverride('7cf02a6');
*
* @example
* balena.models.device.enableLockOverride(123);
*/
enableLockOverride: (uuidOrId: string | number) => Promise<void>;
/**
* @summary Disable lock override
* @name disableLockOverride
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.disableLockOverride('7cf02a6');
*
* @example
* balena.models.device.disableLockOverride(123);
*/
disableLockOverride: (uuidOrId: string | number) => Promise<void>;
/**
* @summary Check if a device has the lock override enabled
* @name hasLockOverride
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.hasLockOverride('7cf02a6');
*
* @example
* balena.models.device.hasLockOverride(123);
*/
hasLockOverride: (uuidOrId: string | number) => Promise<boolean>;
/**
* @summary Get the status of a device
* @name getStatus
* @public
* @function
* @memberof balena.models.device
*
* @description
* Convenience method for getting the overall status of a device.
* It's recommended to use `balena.models.device.get()` instead,
* in case that you need to retrieve more device fields than just the status.
*
* @see {@link balena.models.device.get} for an example on selecting the `overall_status` field.
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @fulfil {String} - device status
* @returns {Promise}
*
* @example
* balena.models.device.getStatus('7cf02a6').then(function(status) {
* console.log(status);
* });
*
* @example
* balena.models.device.getStatus(123).then(function(status) {
* console.log(status);
* });
*/
getStatus(uuidOrId: string | number): Promise<string>;
/**
* @summary Get the progress of a device
* @name getProgress
* @public
* @function
* @memberof balena.models.device
*
* @description
* Convenience method for getting the overall progress of a device.
* It's recommended to use `balena.models.device.get()` instead,
* in case that you need to retrieve more device fields than just the progress.
*
* @see {@link balena.models.device.get} for an example on selecting the `overall_progress` field.
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @fulfil {Number|Null} - device progress
* @returns {Promise}
*
* @example
* balena.models.device.getProgress('7cf02a6').then(function(progress) {
* console.log(progress);
* });
*
* @example
* balena.models.device.getProgress(123).then(function(progress) {
* console.log(progress);
* });
*/
getProgress(uuidOrId: string | number): Promise<number | null>;
/**
* @summary Grant support access to a device until a specified time
* @name grantSupportAccess
* @public
* @function
* @memberof balena.models.device
*
* @param {String|String[]|Number|Number[]} uuidOrIdOrArray - device uuid (string) or id (number) or array of full uuids or ids
* @param {Number} expiryTimestamp - a timestamp in ms for when the support access will expire
* @returns {Promise}
*
* @example
* balena.models.device.grantSupportAccess('7cf02a6', Date.now() + 3600 * 1000);
*
* @example
* balena.models.device.grantSupportAccess(123, Date.now() + 3600 * 1000);
*/
grantSupportAccess(uuidOrIdOrArray: string | string[] | number | number[], expiryTimestamp: number): Promise<void>;
/**
* @summary Revoke support access to a device
* @name revokeSupportAccess
* @public
* @function
* @memberof balena.models.device
*
* @param {String|String[]|Number|Number[]} uuidOrIdOrArray - device uuid (string) or id (number) or array of full uuids or ids
* @returns {Promise}
*
* @example
* balena.models.device.revokeSupportAccess('7cf02a6');
*
* @example
* balena.models.device.revokeSupportAccess(123);
*/
revokeSupportAccess: (uuidOrIdOrArray: string | string[] | number | number[]) => Promise<void>;
/**
* @summary Get a string showing when a device was last set as online
* @name lastOnline
* @public
* @function
* @memberof balena.models.device
*
* @description
* If the device has never been online this method returns the string `Connecting...`.
*
* @deprecated Will be dropped in the next major
* @param {Object} device - A device object
* @returns {String}
*
* @example
* balena.models.device.get('7cf02a6').then(function(device) {
* balena.models.device.lastOnline(device);
* })
*/
lastOnline(device: AtLeast<Device["Read"], "last_connectivity_event" | "is_online">): string;
/**
* @summary Get the OS version (version number and variant combined) running on a device
* @name getOsVersion
* @public
* @function
* @memberof balena.models.device
*
* @param {Object} device - A device object
* @returns {?String}
*
* @example
* balena.models.device.get('7cf02a6').then(function(device) {
* console.log(device.os_version); // => 'balenaOS 2.26.0+rev1'
* console.log(device.os_variant); // => 'prod'
* balena.models.device.getOsVersion(device); // => '2.26.0+rev1.prod'
* })
*/
getOsVersion: (device: AtLeast<Device["Read"], "os_variant" | "os_version">) => string;
/**
* @summary Get whether the device is configured to track the current application release
* @name isTrackingApplicationRelease
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @fulfil {Boolean} - is tracking the current application release
* @returns {Promise}
*
* @example
* balena.models.device.isTrackingApplicationRelease('7cf02a6').then(function(isEnabled) {
* console.log(isEnabled);
* });
*/
isTrackingApplicationRelease: (uuidOrId: string | number) => Promise<boolean>;
/**
* @summary Get the hash of the currently tracked release for a specific device
* @name getTargetReleaseHash
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @fulfil {String} - The release hash of the currently tracked release
* @returns {Promise}
*
* @example
* balena.models.device.getTargetReleaseHash('7cf02a6').then(function(release) {
* console.log(release);
* });
*
* @example
* balena.models.device.getTargetReleaseHash('7cf02a6', function(release) {
* console.log(release);
* });
*/
getTargetReleaseHash: (uuidOrId: string | number) => Promise<string | undefined>;
/**
* @summary Set a specific device to run a particular release
* @name pinToRelease
* @public
* @function
* @memberof balena.models.device
*
* @description Configures the device to run a particular release
* and not get updated when the current application release changes.
*
* @param {String|String[]|Number|Number[]} uuidOrIdOrArray - device uuid (string) or id (number) or array of full uuids or ids
* @param {String|Number} fullReleaseHashOrId - the hash of a successful release (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.pinToRelease('7cf02a6', 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() {
* ...
* });
*
* @example
* balena.models.device.pinToRelease(123, 'f7caf4ff80114deeaefb7ab4447ad9c661c50847').then(function() {
* ...
* });
*/
pinToRelease: (uuidOrIdOrArray: string | string[] | number | number[], fullReleaseHashOrId: string | number) => Promise<void>;
/**
* @summary Configure a specific device to track the current application release
* @name trackApplicationRelease
* @public
* @function
* @memberof balena.models.device
*
* @description The device's current release will be updated with each new successfully built release.
*
* @param {String|String[]|Number|Number[]} uuidOrIdOrArray - device uuid (string) or id (number) or array of full uuids or ids
* @returns {Promise}
*
* @example
* balena.models.device.trackApplicationRelease('7cf02a6').then(function() {
* ...
* });
*/
trackApplicationRelease: (uuidOrIdOrArray: string | string[] | number | number[]) => Promise<void>;
/**
* @summary Set a specific device to run a particular supervisor release
* @name setSupervisorRelease
* @public
* @function
* @memberof balena.models.device
*
* @description Configures the device to run a particular supervisor release.
*
* @param {String|String[]|Number|Number[]} uuidOrIdOrArray - device uuid (string) or id (number) or array of full uuids or ids
* @param {String|Number} supervisorVersionOrId - the raw version of a supervisor release (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.setSupervisorRelease('7cf02a6', '10.8.0').then(function() {
* ...
* });
*
* @example
* balena.models.device.setSupervisorRelease(123, '11.4.14').then(function() {
* ...
* });
*/
setSupervisorRelease: (uuidOrIdOrArray: string | string[] | number | number[], supervisorVersionOrId: string | number) => Promise<void>;
/**
* @summary Check whether the provided device can update to the target os version
* @name _checkOsUpdateTarget
* @private
* @function
* @memberof balena.models.device
*
* @description
* Utility method exported for testability
*
* @param {Object} device - A device object
* @param {String} targetOsVersion - semver-compatible version for the target device
* @throws Exception if update isn't supported
* @returns {void}
*/
_checkOsUpdateTarget({ uuid, is_of__device_type, is_online, os_version, os_variant, }: Pick<Device["Read"], "uuid" | "is_online" | "os_version" | "os_variant"> & {
is_of__device_type: [Pick<DeviceType["Read"], "slug">];
}, targetOsVersion: string): void;
/**
* @summary Start an OS update on a device
* @name startOsUpdate
* @public
* @function
* @memberof balena.models.device
*
* @param {String|String[]} uuidOrUuids - full device uuid or array of full uuids
* @param {String} targetOsVersion - semver-compatible version for the target device
* Unsupported (unpublished) version will result in rejection.
* The version **must** be the exact version number, a "prod" variant and greater than the one running on the device.
* To resolve the semver-compatible range use `balena.model.os.getMaxSatisfyingVersion`.
* @param {Object} [options] - options
* @param {Boolean} [options.runDetached] - run the update in detached mode. True by default
* @fulfil {Object} - action response
* @returns {Promise}
*
* @example
* balena.models.device.startOsUpdate('7cf02a687b74206f92cb455969cf8e98', '2.29.2+rev1.prod').then(function(status) {
* console.log(result.status);
* });
*/
startOsUpdate: {
(uuidOrUuids: string, targetOsVersion: string, options?: {
runDetached?: boolean;
}): Promise<OsUpdateActionResult>;
(uuidOrUuids: string[], targetOsVersion: string, options?: {
runDetached?: boolean;
}): Promise<Dictionary<OsUpdateActionResult>>;
};
/**
* @namespace balena.models.device.tags
* @memberof balena.models.device
*/
tags: {
/**
* @summary Get all device tags for an application
* @name getAllByApplication
* @public
* @function
* @memberof balena.models.device.tags
*
* @param {String|Number} slugOrUuidOrId - application slug (string), uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device tags
* @returns {Promise}
*
* @example
* balena.models.device.tags.getAllByApplication('myorganization/myapp').then(function(tags) {
* console.log(tags);
* });
*
* @example
* balena.models.device.tags.getAllByApplication(999999).then(function(tags) {
* console.log(tags);
* });
*/
getAllByApplication<T extends ODataOptionsWithoutCount<DeviceTag["Read"]>>(slugOrUuidOrId: string | number, options?: T): Promise<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
tag_key: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}, "id" | "value" | "device" | "tag_key">[]>>;
/**
* @summary Get all device tags for a device
* @name getAllByDevice
* @public
* @function
* @memberof balena.models.device.tags
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device tags
* @returns {Promise}
*
* @example
* balena.models.device.tags.getAllByDevice('7cf02a6').then(function(tags) {
* console.log(tags);
* });
*
* @example
* balena.models.device.tags.getAllByDevice(123).then(function(tags) {
* console.log(tags);
* });
*/
getAllByDevice: (parentParam: string | number | Dictionary<unknown>, options?: ODataOptionsWithoutCount<{
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
tag_key: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}> | undefined) => Promise<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
tag_key: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}, "id" | "value" | "device" | "tag_key">[]>>;
/**
* @summary Set a device tag
* @name set
* @public
* @function
* @memberof balena.models.device.tags
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} tagKey - tag key
* @param {String|undefined} value - tag value
*
* @returns {Promise}
*
* @example
* balena.models.device.tags.set('7cf02a6', 'EDITOR', 'vim');
*
* @example
* balena.models.device.tags.set(123, 'EDITOR', 'vim');
*/
set: (parentParam: string | number | Dictionary<unknown>, key: string, value: string) => Promise<void>;
/**
* @summary Remove a device tag
* @name remove
* @public
* @function
* @memberof balena.models.device.tags
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} tagKey - tag key
* @returns {Promise}
*
* @example
* balena.models.device.tags.remove('7cf02a6', 'EDITOR');
*/
remove: (parentParam: string | number | Dictionary<unknown>, key: string) => Promise<void>;
};
/**
* @namespace balena.models.device.configVar
* @memberof balena.models.device
*/
configVar: {
/**
* @summary Get all config variables for a device
* @name getAllByDevice
* @public
* @function
* @memberof balena.models.device.configVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device config variables
* @returns {Promise}
*
* @example
* balena.models.device.configVar.getAllByDevice('7cf02a6').then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.device.configVar.getAllByDevice(999999).then(function(vars) {
* console.log(vars);
* });
*/
getAllByDevice: (parentParam: string | number | Dictionary<unknown>, options?: ODataOptionsWithoutCount<{
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}> | undefined) => Promise<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}, "name" | "id" | "value" | "device">[]>>;
/**
* @summary Get all device config variables by application
* @name getAllByApplication
* @public
* @function
* @memberof balena.models.device.configVar
*
* @param {String|Number} slugOrUuidOrId - application slug (string), uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device config variables
* @returns {Promise}
*
* @example
* balena.models.device.configVar.getAllByApplication('myorganization/myapp').then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.device.configVar.getAllByApplication(999999).then(function(vars) {
* console.log(vars);
* });
*/
getAllByApplication<T extends ODataOptionsWithoutCount<DeviceConfigVariable["Read"]>>(slugOrUuidOrId: string | number, options?: T): Promise<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}, "name" | "id" | "value" | "device">[]>>;
/**
* @summary Get the value of a specific config variable
* @name get
* @public
* @function
* @memberof balena.models.device.configVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} key - config variable name
* @fulfil {String|undefined} - the config variable value (or undefined)
* @returns {Promise}
*
* @example
* balena.models.device.configVar.get('7cf02a6', 'BALENA_VAR').then(function(value) {
* console.log(value);
* });
*
* @example
* balena.models.device.configVar.get(999999, 'BALENA_VAR').then(function(value) {
* console.log(value);
* });
*/
get: (parentParam: string | number | Dictionary<unknown>, key: string) => Promise<string | undefined>;
/**
* @summary Set the value of a specific config variable
* @name set
* @public
* @function
* @memberof balena.models.device.configVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} key - config variable name
* @param {String} value - config variable value
* @returns {Promise}
*
* @example
* balena.models.device.configVar.set('7cf02a6', 'BALENA_VAR', 'newvalue').then(function() {
* ...
* });
*
* @example
* balena.models.device.configVar.set(999999, 'BALENA_VAR', 'newvalue').then(function() {
* ...
* });
*/
set: (parentParam: string | number | Dictionary<unknown>, key: string, value: string) => Promise<void>;
/**
* @summary Clear the value of a specific config variable
* @name remove
* @public
* @function
* @memberof balena.models.device.configVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} key - config variable name
* @returns {Promise}
*
* @example
* balena.models.device.configVar.remove('7cf02a6', 'BALENA_VAR').then(function() {
* ...
* });
*
* @example
* balena.models.device.configVar.remove(999999, 'BALENA_VAR').then(function() {
* ...
* });
*/
remove: (parentParam: string | number | Dictionary<unknown>, key: string) => Promise<void>;
};
/**
* @namespace balena.models.device.envVar
* @memberof balena.models.device
*/
envVar: {
/**
* @summary Get all environment variables for a device
* @name getAllByDevice
* @public
* @function
* @memberof balena.models.device.envVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device environment variables
* @returns {Promise}
*
* @example
* balena.models.device.envVar.getAllByDevice('7cf02a6').then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.device.envVar.getAllByDevice(999999).then(function(vars) {
* console.log(vars);
* });
*/
getAllByDevice: (parentParam: string | number | Dictionary<unknown>, options?: ODataOptionsWithoutCount<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}> | undefined) => Promise<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}, "name" | "id" | "value" | "created_at" | "device">[]>>;
/**
* @summary Get all device environment variables by application
* @name getAllByApplication
* @public
* @function
* @memberof balena.models.device.envVar
*
* @param {String|Number} slugOrUuidOrId - application slug (string), uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device environment variables
* @returns {Promise}
*
* @example
* balena.models.device.envVar.getAllByApplication('myorganization/myapp').then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.device.envVar.getAllByApplication(999999).then(function(vars) {
* console.log(vars);
* });
*/
getAllByApplication<T extends ODataOptionsWithoutCount<DeviceEnvironmentVariable["Read"]>>(slugOrUuidOrId: string | number, options?: T): Promise<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
device: {
__id: Device["Read"]["id"];
} | [Device["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
}, "name" | "id" | "value" | "created_at" | "device">[]>>;
/**
* @summary Get the value of a specific environment variable
* @name get
* @public
* @function
* @memberof balena.models.device.envVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} key - environment variable name
* @fulfil {String|undefined} - the environment variable value (or undefined)
* @returns {Promise}
*
* @example
* balena.models.device.envVar.get('7cf02a6', 'VAR').then(function(value) {
* console.log(value);
* });
*
* @example
* balena.models.device.envVar.get(999999, 'VAR').then(function(value) {
* console.log(value);
* });
*/
get: (parentParam: string | number | Dictionary<unknown>, key: string) => Promise<string | undefined>;
/**
* @summary Set the value of a specific environment variable
* @name set
* @public
* @function
* @memberof balena.models.device.envVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} key - environment variable name
* @param {String} value - environment variable value
* @returns {Promise}
*
* @example
* balena.models.device.envVar.set('7cf02a6', 'VAR', 'newvalue').then(function() {
* ...
* });
*
* @example
* balena.models.device.envVar.set(999999, 'VAR', 'newvalue').then(function() {
* ...
* });
*/
set: (parentParam: string | number | Dictionary<unknown>, key: string, value: string) => Promise<void>;
/**
* @summary Clear the value of a specific environment variable
* @name remove
* @public
* @function
* @memberof balena.models.device.envVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String} key - environment variable name
* @returns {Promise}
*
* @example
* balena.models.device.envVar.remove('7cf02a6', 'VAR').then(function() {
* ...
* });
*
* @example
* balena.models.device.envVar.remove(999999, 'VAR').then(function() {
* ...
* });
*/
remove: (parentParam: string | number | Dictionary<unknown>, key: string) => Promise<void>;
};
/**
* @namespace balena.models.device.serviceVar
* @memberof balena.models.device
*/
serviceVar: {
/**
* @summary Get all service variable overrides for a device
* @name getAllByDevice
* @public
* @function
* @memberof balena.models.device.serviceVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - service variables
* @returns {Promise}
*
* @example
* balena.models.device.serviceVar.getAllByDevice('7cf02a6').then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.device.serviceVar.getAllByDevice(999999).then(function(vars) {
* console.log(vars);
* });
*/
getAllByDevice<T extends ODataOptionsWithoutCount<DeviceServiceEnvironmentVariable["Read"]>>(uuidOrId: string | number, options?: T): Promise<NoInfer<OptionsToResponse<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
service_install: {
__id: import("..").ServiceInstall["Read"]["id"];
} | [import("..").ServiceInstall["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
device__installs__application__has__service_name: {
__id: import("..").ServiceInstall["Read"]["id"];
} | [import("..").ServiceInstall["Read"]];
device__installs__service: {
__id: import("..").ServiceInstall["Read"]["id"];
} | [import("..").ServiceInstall["Read"]];
}, MergePineOptions<import("../util").AliasResourceRead, {
$filter: {
service_install: {
$any: {
$alias: string;
$expr: {
si: {
device: number;
};
};
};
};
};
}, T>, undefined>>>;
/**
* @summary Get all device service variable overrides by application
* @name getAllByApplication
* @public
* @function
* @memberof balena.models.device.serviceVar
*
* @param {String|Number} slugOrUuidOrId - application slug (string), uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - service variables
* @returns {Promise}
*
* @example
* balena.models.device.serviceVar.getAllByApplication('myorganization/myapp').then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.device.serviceVar.getAllByApplication(999999).then(function(vars) {
* console.log(vars);
* });
*/
getAllByApplication<T extends ODataOptionsWithoutCount<DeviceServiceEnvironmentVariable["Read"]>>(slugOrUuidOrId: string | number, options?: T): Promise<NoInfer<OptionsToResponse<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
service_install: {
__id: import("..").ServiceInstall["Read"]["id"];
} | [import("..").ServiceInstall["Read"]];
name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
value: import("@balena/sbvr-types").Types["Text"]["Read"];
device__installs__application__has__service_name: {
__id: import("..").ServiceInstall["Read"]["id"];
} | [import("..").ServiceInstall["Read"]];
device__installs__service: {
__id: import("..").ServiceInstall["Read"]["id"];
} | [import("..").ServiceInstall["Read"]];
}, MergePineOptions<import("../util").AliasResourceRead, {
$filter: {
service_install: {
$any: {
$alias: string;
$expr: {
si: {
device: {
$any: {
$alias: string;
$expr: {
d: {
belongs_to__application: number;
};
};
};
};
};
};
};
};
};
$orderby: {
name: "asc";
};
}, T>, undefined>>>;
/**
* @summary Get the overriden value of a service variable on a device
* @name get
* @public
* @function
* @memberof balena.models.device.serviceVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String|Number} serviceNameOrId - service name (string) or id (number)
* @param {String} key - variable name
* @fulfil {String|undefined} - the variable value (or undefined)
* @returns {Promise}
*
* @example
* balena.models.device.serviceVar.get('7cf02a6', 123, 'VAR').then(function(value) {
* console.log(value);
* });
*
* @example
* balena.models.device.serviceVar.get('7cf02a6', 'myservice', 'VAR').then(function(value) {
* console.log(value);
* });
*
* @example
* balena.models.device.serviceVar.get(999999, 123, 'VAR').then(function(value) {
* console.log(value);
* });
*/
get(uuidOrId: string | number, serviceNameOrId: string | number, key: string): Promise<string | undefined>;
/**
* @summary Set the overriden value of a service variable on a device
* @name set
* @public
* @function
* @memberof balena.models.device.serviceVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String|Number} serviceNameOrId - service name (string) or id (number)
* @param {String} key - variable name
* @param {String} value - variable value
* @returns {Promise}
*
* @example
* balena.models.device.serviceVar.set('7cf02a6', 123, 'VAR', 'override').then(function() {
* ...
* });
*
*
* @example
* balena.models.device.serviceVar.set('7cf02a6', 'myservice', 'VAR', 'override').then(function() {
* ...
* });
*
* @example
* balena.models.device.serviceVar.set(999999, 123, 'VAR', 'override').then(function() {
* ...
* });
*/
set(uuidOrId: string | number, serviceNameOrId: string | number, key: string, value: string): Promise<void>;
/**
* @summary Clear the overridden value of a service variable on a device
* @name remove
* @public
* @function
* @memberof balena.models.device.serviceVar
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {String|Number} serviceNameOrId - service name (string) or id (number)
* @param {String} key - variable name
* @returns {Promise}
*
* @example
* balena.models.device.serviceVar.remove('7cf02a6', 123, 'VAR').then(function() {
* ...
* });
*
* @example
* balena.models.device.serviceVar.remove('7cf02a6', 'myservice', 'VAR').then(function() {
* ...
* });
*
* @example
* balena.models.device.serviceVar.remove(999999, 123, 'VAR').then(function() {
* ...
* });
*/
remove(uuidOrId: string | number, serviceNameOrId: string | number, key: string): Promise<void>;
};
/**
* @namespace balena.models.device.history
* @memberof balena.models.device
*/
history: {
/**
* @summary Get all history entries for a device
* @name getAllByDevice
* @public
* @function
* @memberof balena.models.device.history
*
* @param {String|Number} uuidOrId - device uuid (32 / 62 digits string) or id (number)
* @param {Date} [dateFilter.fromDate=subDays(new Date(), 7)] - history entries older or equal to this date - default now() - 7 days
* @param {Date} [dateFilter.toDate] - history entries younger or equal to this date
* @param {Object} [options] - extra pine options to use
* @fulfil {Object[]} - device history
* @returns {Promise}
*
* @example
* balena.models.device.history.getAllByDevice('7cf02a687b74206f92cb455969cf8e98').then(function(entries) {
* console.log(entries);