balena-sdk
Version:
The Balena JavaScript SDK
172 lines (171 loc) • 7.24 kB
TypeScript
import type { InjectedDependenciesParam } from '..';
import type { Service, ServiceEnvironmentVariable } from '../types/models';
import type { ODataOptionsWithoutCount, OptionsToResponse } from 'pinejs-client-core';
declare const getServiceModel: ({ pine, sdkInstance, }: InjectedDependenciesParam) => {
/**
* @summary Get all services from an application
* @name getAllByApplication
* @public
* @function
* @memberof balena.models.service
*
* @param {String|Number} slugOrUuidOrId - application slug (string), uuid (string) or id (number)
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - services
* @returns {Promise}
*
* @example
* balena.models.service.getAllByApplication('myorganization/myapp').then(function(services) {
* console.log(services);
* });
*
* @example
* balena.models.service.getAllByApplication(123).then(function(services) {
* console.log(services);
* });
*/
getAllByApplication: <T extends ODataOptionsWithoutCount<Service["Read"]>>(slugOrUuidOrId: string | number, options?: T) => Promise<OptionsToResponse<Service["Read"], T, undefined>>;
/**
* @namespace balena.models.service.var
* @memberof balena.models.service
*/
var: {
/**
* @summary Get all variables for a service
* @name getAllByService
* @public
* @function
* @memberof balena.models.service.var
*
* @param {Number|Object} serviceIdOrNaturalKey - service id (number) or appliation-service_name pair
* @param {Object} [options={}] - extra pine options to use
* @fulfil {Object[]} - service variables
* @returns {Promise}
*
* @example
* balena.models.service.var.getAllByService(999999).then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.service.var.getAllByService({ application: 'myorganization/myapp', service_name: 'myservice' }).then(function(vars) {
* console.log(vars);
* });
*/
getAllByService: <O extends ODataOptionsWithoutCount<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
service: {
__id: Service["Read"]["id"];
} | [Service["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"];
application__has__service_name: {
__id: Service["Read"]["id"];
} | [Service["Read"]];
}>>(parentParam: string | number | Record<string, unknown>, options?: O | undefined) => Promise<OptionsToResponse<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
service: {
__id: Service["Read"]["id"];
} | [Service["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"];
application__has__service_name: {
__id: Service["Read"]["id"];
} | [Service["Read"]];
}, O, undefined>>;
/**
* @summary Get all service variables by application
* @name getAllByApplication
* @public
* @function
* @memberof balena.models.service.var
*
* @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.service.var.getAllByApplication('myorganization/myapp').then(function(vars) {
* console.log(vars);
* });
*
* @example
* balena.models.service.var.getAllByApplication(999999).then(function(vars) {
* console.log(vars);
* });
*/
getAllByApplication<T extends ODataOptionsWithoutCount<ServiceEnvironmentVariable["Read"]>>(slugOrUuidOrId: string | number, options?: T): Promise<OptionsToResponse<ServiceEnvironmentVariable["Read"], T, undefined>>;
/**
* @summary Get the value of a specific service variable
* @name get
* @public
* @function
* @memberof balena.models.service.var
*
* @param {Number|Object} serviceIdOrNaturalKey - service id (number) or appliation-service_name pair
* @param {String} key - variable name
* @fulfil {String|undefined} - the variable value (or undefined)
* @returns {Promise}
*
* @example
* balena.models.service.var.get(999999, 'VAR').then(function(value) {
* console.log(value);
* });
*
* @example
* balena.models.service.var.get({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function(value) {
* console.log(value);
* });
*/
get: (parentParam: string | number | Record<string, unknown>, key: string) => Promise<string | undefined>;
/**
* @summary Set the value of a specific service variable
* @name set
* @public
* @function
* @memberof balena.models.service.var
*
* @param {Number|Object} serviceIdOrNaturalKey - service id (number) or appliation-service_name pair
* @param {String} key - variable name
* @param {String} value - variable value
* @returns {Promise}
*
* @example
* balena.models.service.var.set(999999, 'VAR', 'newvalue').then(function() {
* ...
* });
*
* @example
* balena.models.service.var.set({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR', 'newvalue').then(function() {
* ...
* });
*/
set: (parentParam: string | number | Record<string, unknown>, key: string, value: string) => Promise<void>;
/**
* @summary Clear the value of a specific service variable
* @name remove
* @public
* @function
* @memberof balena.models.service.var
*
* @param {Number|Object} serviceIdOrNaturalKey - service id (number) or appliation-service_name pair
* @param {String} key - variable name
* @returns {Promise}
*
* @example
* balena.models.service.var.remove(999999, 'VAR').then(function() {
* ...
* });
*
* @example
* balena.models.service.var.remove({ application: 'myorganization/myapp', service_name: 'myservice' }, 'VAR').then(function() {
* ...
* });
*/
remove: (parentParam: string | number | Record<string, unknown>, key: string) => Promise<void>;
};
};
export default getServiceModel;