balena-sdk
Version:
The Balena JavaScript SDK
200 lines (199 loc) • 9.4 kB
TypeScript
import type { InjectedDependenciesParam } from '..';
import type { Service, ServiceEnvironmentVariable } from '../types/models';
import type { ODataOptionsWithoutCount } 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<import("pinejs-client-core").OptionsToResponse<{
created_at: import("@balena/sbvr-types").Types["Date Time"]["Read"];
application: {
__id: import("..").Application["Read"]["id"];
} | [import("..").Application["Read"]];
service_name: import("@balena/sbvr-types").Types["Short Text"]["Read"];
id: import("@balena/sbvr-types").Types["Integer"]["Read"];
application__has__service_name__has__label_name?: Array<import("..").ServiceLabel["Read"]>;
service__has__label_name?: Array<import("..").ServiceLabel["Read"]>;
service_label?: Array<import("..").ServiceLabel["Read"]>;
application__has__service_name__has__name?: Array<ServiceEnvironmentVariable["Read"]>;
service__has__name?: Array<ServiceEnvironmentVariable["Read"]>;
service_environment_variable?: Array<ServiceEnvironmentVariable["Read"]>;
device__installs__application__has__service_name?: Array<import("..").ServiceInstall["Read"]>;
device__installs__service?: Array<import("..").ServiceInstall["Read"]>;
service_install?: Array<import("..").ServiceInstall["Read"]>;
is_built_by__image?: Array<import("..").Image["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: (parentParam: string | number | import("../../typings/utils").Dictionary<unknown>, options?: 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"]];
}> | undefined) => Promise<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
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"]];
}, "name" | "id" | "value" | "created_at" | "application__has__service_name" | "service">[]>>;
/**
* @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<NoInfer<import("pinejs-client-core/node_modules/@balena/abstract-sql-to-typescript", { with: { "resolution-mode": "import" } }).PickDeferred<{
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"]];
}, "name" | "id" | "value" | "created_at" | "application__has__service_name" | "service">[]>>;
/**
* @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 | import("../../typings/utils").Dictionary<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 | import("../../typings/utils").Dictionary<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 | import("../../typings/utils").Dictionary<unknown>, key: string) => Promise<void>;
};
};
export default getServiceModel;