UNPKG

balena-register-device

Version:
92 lines (91 loc) 3 kB
import { TypedError } from 'typed-error'; interface SendResponse { statusCode: number; body: any; } /** * @summary Creates a Balena Register Device instance * @function * @public * * @returns {Object} Balena Register Device instance { generateUniqueKey: ..., register: ... } */ export declare const getRegisterDevice: ({ request, }: { request: { send: (opts: { method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS"; baseUrl?: string; url: string; refreshToken?: boolean; sendToken?: boolean; body?: any; responseFormat?: "none" | "blob" | "json" | "text"; headers: { [key: string]: string; }; timeout: number; }) => Promise<SendResponse>; }; }) => { /** * @summary Generate a random key, useful for both uuid and api key. * @function * @public * * @returns {String} A generated key * * @example * randomKey = deviceRegister.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 device with Balena * @function * @public * * @param {Object} options - options * @param {Number} [options.userId] - user id * @param {Number} options.applicationId - application id * @param {String} options.uuid - device uuid * @param {String} options.deviceType - device type * @param {String} [options.deviceApiKey] - api key to create for the device * @param {String} options.provisioningApiKey - provisioning api key * @param {String} options.apiEndpoint - api endpoint * @param {String} [options.supervisorVersion] - supervisor version of the device * @param {String} [options.osVersion] - os version of the device * @param {String} [options.osVariant] - os variant of the device * @param {String} [options.macAddress] - mac address of the device * * @example * deviceRegister.register * userId: 199 * applicationId: 10350 * uuid: '...' * deviceType: 'raspberry-pi' * deviceApiKey: '...' * provisioningApiKey: '...' * apiEndpoint: 'https://api.balena-cloud.com' * .then (deviceInfo) -> * console.log(deviceInfo) # { id } */ register(options: { userId?: number; applicationId: number; uuid: string; deviceType: string; deviceApiKey?: string; provisioningApiKey: string; apiEndpoint: string; supervisorVersion?: string; osVersion?: string; osVariant?: string; macAddress?: string; }): Promise<any>; }; export declare class ApiError extends TypedError { response: SendResponse; constructor(message: string | undefined, response: SendResponse); } export {};