balena-sdk
Version:
The Balena JavaScript SDK
200 lines (199 loc) • 7.35 kB
TypeScript
import type { InjectedDependenciesParam } from '..';
import type { DeviceType } from '../types/models';
import type { Contract } from '../types/contract';
import type { ODataOptionsWithoutCount, OptionsToResponse } from 'pinejs-client-core';
declare const getDeviceTypeModel: (deps: InjectedDependenciesParam) => {
/**
* @summary Get a single deviceType
* @name get
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {String|Number} idOrSlug - device type slug (string) or alias (string) or id
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device types
* @returns {Promise}
*
* @description
* This method returns a single device type.
*
* @example
* balena.models.deviceType.get('raspberry-pi').then(function(deviceType) {
* console.log(deviceType);
* });
*
* @example
* balena.models.deviceType.get('raspberrypi').then(function(deviceType) {
* console.log('resolved alias:', deviceType);
* });
*/
get<T extends ODataOptionsWithoutCount<DeviceType["Read"]>>(idOrSlug: number | string, options?: T): Promise<OptionsToResponse<DeviceType["Read"], T, undefined>[number]>;
/**
* @summary Get all deviceTypes
* @name getAll
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device types
* @returns {Promise}
*
* @description
* This method returns all device types.
*
* @example
* balena.models.deviceType.getAll().then(function(deviceTypes) {
* console.log(deviceTypes);
* });
*
* @example
* balena.models.deviceType.getAll({ $select: ['name', 'slug'] }).then(function(deviceTypes) {
* console.log(deviceTypes);
* })
*/
getAll<T extends ODataOptionsWithoutCount<DeviceType["Read"]>>(options?: T): Promise<OptionsToResponse<DeviceType["Read"], T, undefined>>;
/**
* @summary Get all supported deviceTypes
* @name getAllSupported
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - device types
* @returns {Promise}
*
* @description
* This method returns all supported device types.
*
* @example
* balena.models.deviceType.getAllSupported().then(function(deviceTypes) {
* console.log(deviceTypes);
* });
*
* @example
* balena.models.deviceType.getAllSupported({ $select: ['name', 'slug'] }).then(function(deviceTypes) {
* console.log(deviceTypes);
* })
*/
getAllSupported<T extends ODataOptionsWithoutCount<DeviceType["Read"]>>(options?: T): Promise<OptionsToResponse<DeviceType["Read"], T, undefined>>;
/**
* @summary Get a deviceType by slug or name
* @name getBySlugOrName
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {String} slugOrName - deviceType slug
* @fulfil {Object} - device type
* @returns {Promise}
*
* @example
* balena.models.deviceType.getBySlugOrName('raspberry-pi').then(function(deviceType) {
* console.log(deviceType);
* });
*/
getBySlugOrName: <T extends ODataOptionsWithoutCount<DeviceType["Read"]>>(slugOrName: string, options?: T) => Promise<OptionsToResponse<DeviceType["Read"], T, undefined>[number]>;
/**
* @summary Get display name for a device
* @name getName
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {String} deviceTypeSlug - device type slug
* @fulfil {String} - device display name
* @returns {Promise}
*
* @example
* balena.models.deviceType.getName('raspberry-pi').then(function(deviceTypeName) {
* console.log(deviceTypeName);
* // Raspberry Pi
* });
*/
getName: (deviceTypeSlug: string) => Promise<string>;
/**
* @summary Get device slug
* @name getSlugByName
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {String} deviceTypeName - device type name
* @fulfil {String} - device slug name
* @returns {Promise}
*
* @example
* balena.models.deviceType.getSlugByName('Raspberry Pi').then(function(deviceTypeSlug) {
* console.log(deviceTypeSlug);
* // raspberry-pi
* });
*/
getSlugByName: (deviceTypeName: string) => Promise<string>;
/**
* @summary Get a contract with resolved partial templates
* @name getInterpolatedPartials
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {String} deviceTypeSlug - device type slug
* @fulfil {Contract} - device type contract with resolved partials
* @returns {Promise}
*
* @example
* balena.models.deviceType.getInterpolatedPartials('raspberry-pi').then(function(contract) {
* for (const partial in contract.partials) {
* console.log(`${partial}: ${contract.partials[partial]}`);
* }
* // bootDevice: ["Connect power to the Raspberry Pi (v1 / Zero / Zero W)"]
* });
*/
getInterpolatedPartials: (deviceTypeSlug: string) => Promise<Contract>;
/**
* @summary Get instructions for installing a host OS on a given device type
* @name getInstructions
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {String|Object} deviceTypeSlugOrContract - device type slug or contract
* @fulfil {Object | String[]} - step by step instructions for installing the host OS to the device
* @returns {Promise}
*
* @example
* balena.models.deviceType.getInstructions('raspberry-pi').then(function(instructions) {
* for (let instruction of instructions.values()) {
* console.log(instruction);
* }
* // Insert the sdcard to the host machine.
* // Write the BalenaOS file you downloaded to the sdcard. We recommend using <a href="https://etcher.balena.io/">Etcher</a>.
* // Wait for writing of BalenaOS to complete.
* // Remove the sdcard from the host machine.
* // Insert the freshly flashed sdcard into the Raspberry Pi (v1 / Zero / Zero W).
* // Connect power to the Raspberry Pi (v1 / Zero / Zero W) to boot the device.
* });
*/
getInstructions: (deviceTypeSlugOrContract: string | Contract | NonNullable<DeviceType["Read"]["contract"]>) => Promise<Record<"Linux" | "MacOS" | "Windows", string[]> | string[]>;
/**
* @summary Get installation method on a given device type
* @name getInstallMethod
* @public
* @function
* @memberof balena.models.deviceType
*
* @param {String} deviceTypeSlug - device type slug
* @fulfil {String} - the installation method supported for the given device type slug
* @returns {Promise}
*
* @example
* balena.models.deviceType.getInstallMethod('raspberry-pi').then(function(method) {
* console.log(method);
* // externalBoot
* });
*/
getInstallMethod: (deviceTypeSlug: string) => Promise<string | null>;
};
export { getDeviceTypeModel as default };