balena-sdk
Version:
The Balena JavaScript SDK
252 lines (251 loc) • 7.32 kB
TypeScript
import type { InjectedOptionsParam, InjectedDependenciesParam } from '..';
export declare const MIN_SUPERVISOR_APPS_API = "1.8.0-alpha.0";
export declare const MIN_SUPERVISOR_MC_API = "7.0.0";
export declare const CONTAINER_ACTION_ENDPOINT_TIMEOUT = 50000;
export interface SupervisorStatus {
api_port: string;
ip_address: string;
os_version: string;
supervisor_version: string;
update_pending: boolean;
update_failed: boolean;
update_downloaded: boolean;
status?: string | null;
commit?: string | null;
download_progress?: string | null;
}
export declare const getSupervisorApiHelper: (deps: InjectedDependenciesParam, opts: InjectedOptionsParam) => {
/**
* @summary Ping a device
* @name ping
* @public
* @function
* @memberof balena.models.device
*
* @description
* This is useful to signal that the supervisor is alive and responding.
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.ping('7cf02a6');
*
* @example
* balena.models.device.ping(123);
*/
ping: (uuidOrId: string | number) => Promise<void>;
/**
* @summary Identify device
* @name identify
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.identify('7cf02a6');
*
* @example
* balena.models.device.identify(123);
*/
identify: (uuidOrId: string | number) => Promise<void>;
/**
* @summary Restart application on device
* @name restartApplication
* @public
* @function
* @memberof balena.models.device
*
* @description
* This function restarts the Docker container running
* the application on the device, but doesn't reboot
* the device itself.
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.restartApplication('7cf02a6');
*
* @example
* balena.models.device.restartApplication(123);
*/
restartApplication: (uuidOrId: string | number) => Promise<void>;
/**
* @summary Reboot device
* @name reboot
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Object} [options] - options
* @param {Boolean} [options.force=false] - override update lock
* @returns {Promise}
*
* @example
* balena.models.device.reboot('7cf02a6');
*
* @example
* balena.models.device.reboot(123);
*/
reboot: (uuidOrId: string | number, options?: {
force?: boolean;
}) => Promise<void>;
/**
* @summary Shutdown device
* @name shutdown
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Object} [options] - options
* @param {Boolean} [options.force=false] - override update lock
* @returns {Promise}
*
* @example
* balena.models.device.shutdown('7cf02a6');
*
* @example
* balena.models.device.shutdown(123);
*/
shutdown: (uuidOrId: string | number, options: {
force?: boolean;
}) => Promise<void>;
/**
* @summary Purge device
* @name purge
* @public
* @function
* @memberof balena.models.device
*
* @description
* This function clears the user application's `/data` directory.
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.purge('7cf02a6');
*
* @example
* balena.models.device.purge(123);
*/
purge: (uuidOrId: string | number) => Promise<void>;
/**
* @summary Trigger an update check on the supervisor
* @name update
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Object} [options] - options
* @param {Boolean} [options.force=false] - override update lock
* @returns {Promise}
*
* @example
* balena.models.device.update('7cf02a6', {
* force: true
* });
*
* @example
* balena.models.device.update(123, {
* force: true
* });
*/
update(uuidOrId: string | number, options: {
force?: boolean;
}): Promise<void>;
/**
* @summary Get the supervisor state on a device
* @name getSupervisorState
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @returns {Promise}
*
* @example
* balena.models.device.getSupervisorState('7cf02a6').then(function(state) {
* console.log(state);
* });
*
* @example
* balena.models.device.getSupervisorState(123).then(function(state) {
* console.log(state);
* });
*/
getSupervisorState: (uuidOrId: string | number) => Promise<SupervisorStatus>;
/**
* @summary Start a service on a device
* @name startService
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Number} imageId - id of the image to start
* @returns {Promise}
*
* @example
* balena.models.device.startService('7cf02a6', 123).then(function() {
* ...
* });
*
* @example
* balena.models.device.startService(1, 123).then(function() {
* ...
* });
*/
startService: (uuidOrId: string | number, imageId: number) => Promise<void>;
/**
* @summary Stop a service on a device
* @name stopService
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Number} imageId - id of the image to stop
* @returns {Promise}
*
* @example
* balena.models.device.stopService('7cf02a6', 123).then(function() {
* ...
* });
*
* @example
* balena.models.device.stopService(1, 123).then(function() {
* ...
* });
*/
stopService: (uuidOrId: string | number, imageId: number) => Promise<void>;
/**
* @summary Restart a service on a device
* @name restartService
* @public
* @function
* @memberof balena.models.device
*
* @param {String|Number} uuidOrId - device uuid (string) or id (number)
* @param {Number} imageId - id of the image to restart
* @returns {Promise}
*
* @example
* balena.models.device.restartService('7cf02a6', 123).then(function() {
* ...
* });
*
* @example
* balena.models.device.restartService(1, 123).then(function() {
* ...
* });
*/
restartService: (uuidOrId: string | number, imageId: number) => Promise<void>;
};