@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
325 lines • 11.4 kB
TypeScript
import { IApplicationInstanceLog, IApplicationInstanceLogRequestParams, IApplicationManagedObject } from './IApplicationInstanceDetails';
import { IFetchResponse, IResult, IResultList, Service } from '../core';
import { ITenant } from '../tenant';
import { IUser } from '../user';
import { ApplicationBinaryService } from './ApplicationBinaryService';
import { IApplication } from './IApplication';
import { IApplicationVersionDeleteParams, IApplicationVersion } from './IApplicationVersion';
import { IManifest } from './IManifest';
import { ApplicationAvailability } from './ApplicationAvailability';
export declare class ApplicationService extends Service<IApplication> {
protected baseUrl: string;
protected listUrl: string;
protected propertyName: string;
protected channel: string;
/**
* Creates a new application.
*
* @param {IIdentified} entity Application object.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const newApp = {
* name: 'New application',
* type: 'EXTERNAL',
* key: 'new-app'
* };
*
* (async () => {
* const {data, res} = await applicationService.create(newApp);
* })();
* ```
*/
create(entity: IApplication): Promise<IResult<IApplication>>;
/**
* Clones a given application. The application name, key, and context-path will be
* prefixed with `clone` and if necessary a number.
* @param entity The application to clone.
* @param version If a blueprint, you can define which version to clone. If not provided, it will always clone the latest version.
* @returns The application entity.
*/
clone(entity: IApplication, version?: string): Promise<IResult<IApplication>>;
/**
* Gets the list of existing applications filtered by parameters.
*
* @returns Response wrapped in [[IResultList]]
*
* @param {object} filter Object containing filters for querying applications.
*
* **Example**
* ```typescript
*
* const filter: object = {
* pageSize: 100,
* withTotalPages: true
* };
*
* (async () => {
* const {data, res, paging} = await applicationService.list(filter);
* })();
* ```
*/
list(filter?: object): Promise<IResultList<IApplication>>;
/**
* Gets the list of all application versions.
*
* @param {string|number|IIdentified} entityOrId Entity or Id of the entity.
*
* @param {object} params Additional request parameters.
*
* @returns Returns list of all application versions.
*
* **Example**
* ```typescript
*
* const applicationId: number = 1;
*
* (async () => {
* const {res, data} = await applicationService.listVersions(applicationId);
* })();
* ```
*/
listVersions(entityOrId: string | number | IApplication, params?: object): Promise<IResultList<IApplicationVersion>>;
/**
* Gets the details of selected application.
*
* @param {string|number|IIdentified} entityOrId Entity or Id of the entity.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const applicationId: number = 1;
*
* (async () => {
* const {data, res} = await applicationService.detail(applicationId);
* })();
* ```
*/
detail(entityOrId: string | number | IApplication): Promise<IResult<IApplication>>;
/**
* Updates existing application.
* Make sure that you specifiy the application id within the update object.
*
* @param {IIdentified} entity Application object.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const updateApp = {
* id: 38
* name: 'Updated application'
* };
*
* (async () => {
* const {data, res} = await applicationService.update(updateApp);
* })();
* ```
*/
update(entity: IApplication): Promise<IResult<IApplication>>;
/**
* Removes an application with given id.
*
* @returns Response wrapped in [[IResult]]
*
* @param {string | number | IIdentified} entityOrId entity or id of the application.
*
* **Example**
* ```typescript
*
* const removeApp: object = {
* id: 38
* };
*
* (async () => {
* const {data, res} = await applicationService.delete(removeApp);
* // data will be null
* })();
* ```
*/
delete(entityOrId: string | number | IApplication): Promise<IResult<null>>;
listByName(name: string, params?: object): Promise<IResultList<IApplication>>;
listByTenant(tenantOrName?: string | ITenant, params?: object): Promise<IResultList<IApplication>>;
listByOwner(tenantOrName?: string | ITenant, params?: object): Promise<IResultList<IApplication>>;
listByUser(userOrId?: string | number | IUser, params?: object): Promise<IResultList<IApplication>>;
reactivateArchive(appId: number | string): Promise<IResult<null>>;
binary(application: string | number | IApplication): ApplicationBinaryService;
getHref(application: IApplication): string;
/**
* Checks if current user can access specified application.
*
* @returns Response wrapped in [[IResult]]
*
* @param {string | IApplication} application Application name or contextPath as a
* string or Application object.
*
* **Example**
* ```typescript
*
* const checkApp: object = {
* name: 'myApplication'
* };
*
* (async () => {
* const {data, res} = await applicationService.isAvailable(checkApp);
* })();
* ```
*/
isAvailable(application: string | Partial<IApplication>): Promise<IResult<boolean>>;
/**
* Gets instance details of the specified application (microservice).
*
* @param {string|number|IApplication} entityOrId Entity or Id of the application.
*
* @returns Response wrapped in [[IResultList]]
*
* **Example**
* ```typescript
*
* const applicationId: number = 1;
*
* (async () => {
* const {data, res} = await applicationService.getStatusDetails(applicationId);
* })();
* ```
*/
getStatusDetails(entityOrId: string | number | IApplication): Promise<IResultList<IApplicationManagedObject>>;
/**
* Extracts instance names of the provided IApplicationManagedObject.
*
* @param {IApplicationManagedObject} appStatusDetails Application details managedObject.
*
* @returns instance names
*
* **Example**
* ```typescript
*
* const applicationId: number = 1;
*
* (async () => {
* const {data, res} = await applicationService.getStatusDetails(applicationId);
* const instances = data.map((appMO) => applicationService.getInstanceNames(appMO));
* })();
* ```
*/
getInstanceNames(appStatusDetails: IApplicationManagedObject): string[];
/**
* Get log for a specific application instance.
*
* @param {string|number|IApplication} entityOrId Entity or Id of the application.
*
* @param {string} instanceName instance name of the application.
*
* @param {IApplicationInstanceLogRequestParams} params Object containing parameters for querying the log file.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const applicationId: number = 1;
* const applicationInstanceName: string = 'apama-ctrl-1c-4g-scope-t123456789-deployment-abcdefghij-abcde';
*
* (async () => {
* const {data, res} = await applicationService.getInstanceLog(applicationId, applicationInstanceName);
* })();
* ```
*/
getInstanceLog(entityOrId: string | number | IApplication, instanceName: string, params?: IApplicationInstanceLogRequestParams): Promise<IResult<IApplicationInstanceLog>>;
/**
* Dynamic options are stored on the API in a specific `config: {}` object. They can
* be used to configure the app dynamically.
*
* Note: To avoids conflicts with the default Config, it is recommended
* to use a certain namespace.
* @param entityOrId Entity or Id of the application.
* @param config Configuration to be updated.
* @returns Returns updated configuration.
*/
updateApplicationConfig<T>(entityOrId: string | number | IApplication, config: T): Promise<IApplication & {
config: T;
}>;
/**
* Gets manifest (cumulocity.json file) of a given application.
*
* @param {IApplication} app Application entity.
*
* @param {string} app version
*
* @returns Application manifest object.
*/
getAppManifest(app: IApplication, version?: string): Promise<IManifest>;
/**
* Updates manifest (cumulocity.json file) of a given application.
*
* @param {string|number|IApplication} entityOrId Entity or Id of the application.
*
* @param {any} manifestJSON Application manifest object to be stored.
*
* @returns Application manifest object.
*/
storeAppManifest(entityOrId: string | number | IApplication, manifestJSON: any): Promise<{
res: IFetchResponse;
data: any;
}>;
/**
* Sets tags for specific application package version.
*
* @param {IApplication} app Application entity.
*
* @param {string} version Application package version which tags will be set.
*
* @param {string[]} tags Tags array to set on package version
*
* @returns Application version object.
*/
setPackageVersionTag(app: IApplication, version: string, tags: string[]): Promise<{
res: IFetchResponse;
data: any;
}>;
/**
* Retrieves the manifest of the application behind the given context path.
* @param contextPath
*/
getManifestOfContextPath(contextPath: string): Promise<IResult<Partial<IApplication>>>;
/**
* Removes package version.
*
* @param {IApplication} app Application entity.
*
* @param {IApplicationVersionDeleteParams} params Version or tag indication package to remove.
*
* @returns Request response.
*
* **Example**
* ```typescript
*
* const { res } = await applicationService.deleteVersionPackage(app, {version: '1.0.0'});
*
* const { res } = await applicationService.deleteVersionPackage(app, {tag: 'next'});
*
* ```
*/
deleteVersionPackage(app: IApplication, params: IApplicationVersionDeleteParams): Promise<{
res: IFetchResponse;
data: any;
}>;
/**
* Updates the availability of the given application to the provided value.
*
* @param {string|number|IApplication} entityOrId Entity or Id of the application.
*
* @param {any} availability The new application availability.
*
* @returns Updated application.
*/
updateApplicationAvailability(entityOrId: string | number | IApplication, availability: ApplicationAvailability): Promise<IResult<IApplication>>;
private isMatch;
}
//# sourceMappingURL=ApplicationService.d.ts.map