UNPKG

balena-sdk

Version:
330 lines (329 loc) • 15.5 kB
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<{ id: import("@balena/sbvr-types").Types["Integer"]["Read"]; slug: import("@balena/sbvr-types").Types["Short Text"]["Read"]; name: import("@balena/sbvr-types").Types["Short Text"]["Read"]; is_of__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; logo: import("@balena/sbvr-types").Types["Text"]["Read"] | null; contract: import("@balena/sbvr-types").Types["JSON"]["Read"] | null; belongs_to__device_family: { __id: import("..").DeviceFamily["Read"]["id"]; } | [import("..").DeviceFamily["Read"]] | [] | null; is_private: import("@balena/sbvr-types").Types["Boolean"]["Read"]; is_default_for__application?: Array<import("..").Application["Read"]>; device?: Array<import("..").Device["Read"]>; describes__device?: Array<import("..").Device["Read"]>; describes__public_device?: Array<import("..").PublicDevice["Read"]>; device_type__is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; device_type_alias?: Array<import("..").DeviceTypeAlias["Read"]>; supports__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; is_accessible_privately_by__organization?: Array<import("..").OrganizationHasPrivateAccessToDeviceType["Read"]>; public_device?: Array<import("..").PublicDevice["Read"]>; device_history?: Array<import("..").DeviceHistory["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<NoInfer<OptionsToResponse<{ id: import("@balena/sbvr-types").Types["Integer"]["Read"]; slug: import("@balena/sbvr-types").Types["Short Text"]["Read"]; name: import("@balena/sbvr-types").Types["Short Text"]["Read"]; is_of__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; logo: import("@balena/sbvr-types").Types["Text"]["Read"] | null; contract: import("@balena/sbvr-types").Types["JSON"]["Read"] | null; belongs_to__device_family: { __id: import("..").DeviceFamily["Read"]["id"]; } | [import("..").DeviceFamily["Read"]] | [] | null; is_private: import("@balena/sbvr-types").Types["Boolean"]["Read"]; is_default_for__application?: Array<import("..").Application["Read"]>; device?: Array<import("..").Device["Read"]>; describes__device?: Array<import("..").Device["Read"]>; describes__public_device?: Array<import("..").PublicDevice["Read"]>; device_type__is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; device_type_alias?: Array<import("..").DeviceTypeAlias["Read"]>; supports__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; is_accessible_privately_by__organization?: Array<import("..").OrganizationHasPrivateAccessToDeviceType["Read"]>; public_device?: Array<import("..").PublicDevice["Read"]>; device_history?: Array<import("..").DeviceHistory["Read"]>; }, NonNullable<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<{ id: import("@balena/sbvr-types").Types["Integer"]["Read"]; slug: import("@balena/sbvr-types").Types["Short Text"]["Read"]; name: import("@balena/sbvr-types").Types["Short Text"]["Read"]; is_of__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; logo: import("@balena/sbvr-types").Types["Text"]["Read"] | null; contract: import("@balena/sbvr-types").Types["JSON"]["Read"] | null; belongs_to__device_family: { __id: import("..").DeviceFamily["Read"]["id"]; } | [import("..").DeviceFamily["Read"]] | [] | null; is_private: import("@balena/sbvr-types").Types["Boolean"]["Read"]; is_default_for__application?: Array<import("..").Application["Read"]>; device?: Array<import("..").Device["Read"]>; describes__device?: Array<import("..").Device["Read"]>; describes__public_device?: Array<import("..").PublicDevice["Read"]>; device_type__is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; device_type_alias?: Array<import("..").DeviceTypeAlias["Read"]>; supports__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; is_accessible_privately_by__organization?: Array<import("..").OrganizationHasPrivateAccessToDeviceType["Read"]>; public_device?: Array<import("..").PublicDevice["Read"]>; device_history?: Array<import("..").DeviceHistory["Read"]>; }, import("../util").MergePineOptions<import("../util").AliasResourceRead, { $filter: { is_default_for__application: { $any: { $alias: string; $expr: { idfa: { is_host: true; is_archived: false; owns__release: { $any: { $alias: string; $expr: { r: { status: string; is_final: true; is_invalidated: false; }; }; }; }; }; }; }; }; }; }, 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<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{ id: import("@balena/sbvr-types").Types["Integer"]["Read"]; slug: import("@balena/sbvr-types").Types["Short Text"]["Read"]; name: import("@balena/sbvr-types").Types["Short Text"]["Read"]; is_of__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; logo: import("@balena/sbvr-types").Types["Text"]["Read"] | null; contract: import("@balena/sbvr-types").Types["JSON"]["Read"] | null; belongs_to__device_family: { __id: import("..").DeviceFamily["Read"]["id"]; } | [import("..").DeviceFamily["Read"]] | [] | null; is_private: import("@balena/sbvr-types").Types["Boolean"]["Read"]; is_default_for__application?: Array<import("..").Application["Read"]>; device?: Array<import("..").Device["Read"]>; describes__device?: Array<import("..").Device["Read"]>; describes__public_device?: Array<import("..").PublicDevice["Read"]>; device_type__is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; device_type_alias?: Array<import("..").DeviceTypeAlias["Read"]>; supports__cpu_architecture: { __id: import("..").CpuArchitecture["Read"]["id"]; } | [import("..").CpuArchitecture["Read"]]; is_referenced_by__alias?: Array<import("..").DeviceTypeAlias["Read"]>; is_accessible_privately_by__organization?: Array<import("..").OrganizationHasPrivateAccessToDeviceType["Read"]>; public_device?: Array<import("..").PublicDevice["Read"]>; device_history?: Array<import("..").DeviceHistory["Read"]>; }, "name" | "id" | "is_accessible_privately_by__organization" | "slug" | "is_of__cpu_architecture" | "logo" | "contract" | "belongs_to__device_family" | "is_private" | "is_default_for__application" | "device" | "describes__device" | "describes__public_device" | "device_type__is_referenced_by__alias" | "is_referenced_by__alias" | "device_type_alias" | "supports__cpu_architecture" | "public_device" | "device_history">>; /** * @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 };