@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
338 lines • 18.6 kB
TypeScript
import { EventBinaryService, EventService, IdReference, IEvent, IFetchResponse, IIdentified, IManagedObject, IManagedObjectBinary, InventoryBinaryService, InventoryService, IOperation, IResult, IResultList, OperationService } from '@c8y/client';
import { AlertService, GlobalConfigService, OperationRealtimeService, ServiceRegistry } from '@c8y/ngx-components';
import { Observable } from 'rxjs';
import { ConfigurationSnapshot, DeviceFirmware, DeviceSoftware, DeviceSoftwareChange, FirmwareBinary, FirmwarePatchBinary, ModalModel, RepositoryBinary, RepositoryCategory, RepositoryType, SelectedRepositoryBinary, SoftwareBinary } from './repository.model';
import * as i0 from "@angular/core";
export declare class RepositoryService {
private inventory;
private inventoryBinary;
private operation;
private alert;
private event;
private operationRealtime;
private eventBinary;
private serviceRegistry;
private globalConfigService;
readonly dateFrom: Date;
readonly dateTo: Date;
private queriesUtil;
private advancedSoftwareService;
constructor(inventory: InventoryService, inventoryBinary: InventoryBinaryService, operation: OperationService, alert: AlertService, event: EventService, operationRealtime: OperationRealtimeService, eventBinary: EventBinaryService, serviceRegistry: ServiceRegistry, globalConfigService: GlobalConfigService);
/**
* Lists repository entries of given type.
* @param type The type of repository entries to list.
* @param options Extra listing options.
*/
listRepositoryEntries(type: RepositoryType, options?: {
/** Additional query. */
query?: any;
/** (deprecated - to be removed) Only include entries with matching partial names. */
partialName?: string;
/** Include entries with matching partial text in the specified properties. */
partialTextFilter?: {
partialText: string;
properties: string[];
};
/** Exclude legacy entries. */
skipLegacy?: boolean;
/** Exclude default ordering. */
skipDefaultOrder?: boolean;
/** Other request params. */
params?: any;
}): Promise<IResultList<IManagedObject>>;
create(modal: ModalModel, type: RepositoryType, mo?: Partial<IManagedObject>): Promise<RepositoryCategory>;
createRepositoryObject(modal: ModalModel, type: RepositoryType): Promise<RepositoryCategory>;
saveBinary(file: File, global: Partial<IManagedObject>): Promise<IResult<IManagedObjectBinary>>;
createOrUpdateRepositoryEntry(modal: ModalModel, type: RepositoryType): Promise<IResult<RepositoryCategory>>;
createRepositoryBinary(modal: ModalModel, binaryURL: string, type: RepositoryType, parent: RepositoryCategory): Promise<IResult<FirmwareBinary | SoftwareBinary | FirmwarePatchBinary>>;
prepareRepositoryBinaryMO(modal: ModalModel, binaryURL: string, type: RepositoryType): {
[x: string]: any;
type: any;
c8y_Global: any;
};
linkBinary(repositoryBinary: any, binary: IManagedObjectBinary, repositoryEntry?: RepositoryCategory): Promise<IResult<IIdentified>>;
cleanUp(mosToDelete: IIdentified[]): void;
delete(entity: IIdentified): Promise<IResult<null>>;
errorMsg(): void;
getBaseVersionsCount$(entry: IManagedObject): Observable<number>;
getBaseVersionFromMO(mo: RepositoryBinary): string;
isPatch(mo: RepositoryBinary): boolean;
getPatchVersionsCount$(entry: IManagedObject, baseVersion: FirmwareBinary): Observable<number>;
isLegacyEntry(entry: Partial<IManagedObject>): boolean;
/**
* Lists all versions (base and patch ones) of given top level entry.
* Versions are ordered by creation time (assuming the earlier created, the older the version).
* @param entry Top level repository entry.
* @param params Additional query params.
*/
listAllVersions(entry: Partial<IManagedObject>, params?: {}): Promise<IResultList<IManagedObject>>;
/**
* Lists base versions of given top level entry.
* Versions are ordered by creation time (assuming the earlier created, the older the version).
* @param entry Top level repository entry.
* @param params Additional query params.
*/
listBaseVersions(entry: Partial<IManagedObject>, params?: {}): Promise<IResultList<IManagedObject>>;
/**
* Lists patch versions of given base version under the entry.
* Versions are ordered by creation time (assuming the earlier created, the older the version).
* @param entry Top level repository entry.
* @param baseVersion Base version.
* @param params Additional query params.
*/
listPatchVersions(entry: IManagedObject, baseVersion: FirmwareBinary | string, params?: {}): Promise<IResultList<IManagedObject>>;
/**
* Lists patch versions of given base version under the entry including the base version.
* Versions are ordered by creation time (assuming the earlier created, the older the version).
* In terms of legacy base version the entry gets transformed to fit the needed data model.
* @param entry Top level repository entry.
* @param baseVersion Base version.
* @param params Additional query params.
*/
listBaseVersionAndPatches(entry: IManagedObject, baseVersion: IManagedObject, params?: {}): Promise<IResultList<IManagedObject>> | Promise<{
data: ({
c8y_Firmware: {
version: any;
url: any;
};
} & IManagedObject)[];
}>;
listChildren(entry: Partial<IManagedObject>, filters?: {}, params?: any): Promise<IResultList<IManagedObject>>;
/**
* Fetches all items from the list starting with the provided page.
* @param firstPage The first page of the list to fetch all items for.
*/
fetchAllItemsFromList(firstPage: any): Promise<any>;
/**
* Gets top level repository entry managed object for base or patch version.
* @param mo Base or patch version managed object with parents.
*/
getRepositoryEntryMO$(mo: IManagedObject): Observable<IManagedObject | undefined>;
/**
* Gets base or patch version managed object.
* @param deviceRepositoryFragment Device repository fragment.
* @param type Top level repository entry type.
* @param configuration Configuration object with options:
* - **skipLegacy** - `boolean` - Exclude legacy entries.
* - **filters** - `object` - Filter object.
*
* @deprecated as it doesn't support 'missing url' case
*/
getRepositoryBinaryMoByVersion(deviceRepositoryFragment: DeviceFirmware | DeviceSoftware, type: RepositoryType, { skipLegacy, filters }?: {
skipLegacy?: boolean;
filters?: object;
}): Promise<IManagedObject>;
getBinaryName$(binaryUrl: string): Observable<string>;
/**
* Generates an inventory query object which can be used to find
* repository entries of specified type matching the type of provided device.
* @param repositoryType The type of repository entries which will be queried with the generated query.
* @param device The device for which matching repository entries will be queried with the generated query.
*/
getDeviceTypeQuery(repositoryType: RepositoryType, device: IManagedObject): object;
/**
* Generates an inventory query object which can be used to find
* repository entries matching the predefined software types provided in the device.
* @param device The device for which matching repository entries will be queried with the generated query.
* @param query The query to which the software types filters will be attached. Default value is an object containg repository type software.
*/
getSoftwareTypeQuery(device: IManagedObject, query?: object): object;
/**
* Generates an inventory query object which can be used to find configuration repository entries
* matching the type of provided device and specified configuration type.
* @param device The device for which matching repository entries will be queried with the generated query.
* @param configurationType Configuration type for which matching repository entries will be queried with the generated query.
*/
getConfigurationTypeQuery(device: IManagedObject, configurationType: string): object;
/**
* Gets the list of software installed in the device in the uniform format.
* Supports c8y_SoftwareList and c8y_Software fragments.
* @param device The device whose software list should be returned.
*/
getDeviceSoftwareList(device: IManagedObject): DeviceSoftware[];
/**
* Prepares a software update operation for given device and the list of changes, and sends it to the device.
* @param device The device which the operation should be prepared for and sent to.
* @param changes The list of software changes which should be applied.
*/
createSoftwareUpdateOperation(device: IManagedObject, changes: DeviceSoftwareChange[]): Promise<IOperation>;
/**
* Prepares a software update operation for given device and changes.
* Returned operation type depends on device's supported operations.
* Supports c8y_SoftwareUpdate, c8y_SoftwareList, and c8y_Software operations.
* @param device The device for which operation should be prepared.
* @param changes The list of software changes which should be applied.
*/
getSoftwareUpdateOperation(device: IManagedObject, changes: DeviceSoftwareChange[]): Promise<IOperation>;
/**
* Extracts the list of device software changes from given operation in the context of given device.
* @param operation The operation from which the list should be extracted.
* @param device The target device of the operation.
*/
getDeviceSoftwareChangesFromOperation(operation: IOperation, device: IManagedObject): Promise<DeviceSoftwareChange[]>;
/**
* Prepares a firmware update operation for given device and the selected repository binary, and sends it to the device.
* @param device The device which the operation should be prepared for and sent to.
* @param selectedOption The selected repository binary option.
*/
createFirmwareUpdateOperation(device: IManagedObject, selectedOption: SelectedRepositoryBinary): Promise<IOperation>;
/**
* Prepares a firmware update operation for given device and selected version.
* Supports c8y_Firmware operation.
* @param device The device for which operation should be prepared.
* @param selectedOption Selected firmware version.
*/
getFirmwareUpdateOperation(device: IManagedObject, selectedOption: SelectedRepositoryBinary): IOperation;
/**
* Prepares a configuration file upload operation for given device and configuration type.
* @param device The device for which operation should be prepared.
* @param configurationType Selected configuration type.
* @param isLegacy A legacy operation is created without a configurationType.
*/
getUploadConfigurationFileOperation(device: IManagedObject, configurationType: string, isLegacy?: boolean): IOperation;
/**
* Prepares a configuration file download operation for given device and configuration type.
* @param device The device for which operation should be prepared.
* @param configurationType Selected configuration type.
* @param binaryUrl The url of a binary to be downloaded.
* @param isLegacy A legacy operation is created without a configurationType.
*/
getDownloadConfigurationFileOperation(device: IManagedObject, configurationType: string, configSnapshot: ConfigurationSnapshot, isLegacy?: boolean): IOperation;
/**
* Gets the last firmware update operation for given device.
* Looks for c8y_Firmware operations.
* @param deviceId The ID of the device to find an operation for.
*/
getLastFirmwareUpdateOperation(deviceId: string | number): Promise<IOperation>;
/**
* Gets the last software update operation for given device.
* Looks for c8y_SoftwareUpdate, c8y_SoftwareList, or c8y_Software operations.
* @param deviceId The ID of the device to find an operation for.
*/
getLastSoftwareUpdateOperation(deviceId: string | number): Promise<IOperation>;
/**
* Iterates over the list of filters and queries the operations.
* If a query returns at least one operation, the first one will be returned.
* Otherwise the next query will be performed.
* If none of the queries returns any operation, null will be returned.
* @param filtersList The list of filters for the queries.
*/
getFirstMatchingOperation(filtersList: any[]): Promise<IOperation>;
/**
* Iterates over the list of filters and queries the operations.
* It compares the operations retrieved by the queries by 'creationTime'
* and return the latest one.
* If none of the queries returns any operation, null will be returned.
* @param filtersList The list of filters for the queries.
*/
getLatestMatchingOperation(filtersList: any[]): Promise<IOperation>;
/**
* Creates the operation and returns an observable to track its progress.
* Fails the observable when the operation returns FAILED status.
* Completes the observable when the operation returns SUCCESSFUL status.
* @param operation The operation to create and track.
*/
createObservedOperation(operation: IOperation): Observable<IOperation>;
/**
* Returns an observable to track progress of given operation.
* Fails the observable when the operation returns FAILED status.
* Completes the observable when the operation returns SUCCESSFUL status.
* @param operation The operation to be observed.
*/
observeOperation(operation: IOperation): Observable<IOperation>;
/**
* Gets a single event with latest creationTime for the given device Id and event type.
* @param deviceId The device Id for which the events should be queried.
* @param type Event type.
*/
getLatestConfigurationEvent(deviceId: string | number, type: string): Promise<IEvent | undefined>;
/**
* Gets a list of operations for the given device Id, and operation type.
* @param deviceId The device Id for which the operation should be queried.
* @param operationType Operation type fragment.
*/
getConfigFileOperationList(deviceId: string | number, operationType: string): Promise<IOperation[]>;
/**
* Gets latest uploaded configuration snapshot for the given device, and configuration type.
* @param device The device for which the configuration snapshot was uploaded.
* @param configurationType Selected configuration type.
*/
getConfigSnapshot(device: IManagedObject, configurationType: string): Promise<ConfigurationSnapshot | undefined>;
getLegacyConfigSnapshot(deviceId: any): Promise<ConfigurationSnapshot>;
/**
* Returns a binary object as text.
* @param binaryUrl The URL to find binary
* @param options The object with additional options:
* - **allowExternal** - `boolean` - allows downloading external binary file
* - **noAlerts** - `boolean` - do not display an alert message; defaults to `false`
*/
getBinaryText(binaryUrl: string, options: {
allowExternal: boolean;
noAlerts?: boolean;
}): Promise<string>;
/**
* Returns a binary object as File.
* @param binaryUrl The URL to find binary
* @param options The object with additional options:
* - **allowExternal** - `boolean` - allows downloading external binary file
*/
getBinaryFile(binaryUrl: string, options: {
allowExternal: boolean;
}): Promise<File>;
/**
* Gets the last configuration update operation for given device.
* Looks for c8y_Configuration and c8y_SendConfiguration operations.
* @param deviceId The ID of the device to find an operation for.
*/
getLastConfigUpdateOperation(deviceId: string | number): Promise<IOperation>;
/**
* Prepares a configuration download operation for given device and its current configuration.
* Supports c8y_SendConfiguration operation.
* @param device The device for which operation should be prepared.
*/
createTextBasedConfigurationReloadOperation(device: IManagedObject): IOperation;
/**
* Prepares a configuration update operation for the given device.
* Supports c8y_Configuration operation.
* @param device The device for which operation should be prepared.
* @param config The configuration which will update the existing one.
*/
createTextBasedConfigurationUpdateOperation(device: IManagedObject, config: string): IOperation;
getBinary(binaryId: IdReference): Promise<IFetchResponse>;
/**
* Gets all available snapshots from the repository for the given device.
* @param device The device for which the snapshots should be prepared.
* @param configurationType Selected configuration type.
*/
getSnapshotsFromRepository(device: any, configurationType: any): Promise<IManagedObject[]>;
/**
* Checks if a device already have a given software installed
* @param deviceId Id of the device to be checked
* @param software The software to be checked
*/
isSoftwareInstalledOnDevice(deviceId: string | number, software: DeviceSoftware): Promise<boolean>;
/**
* Returns a binary object.
* @param binaryId binary ID
* @param options The object with additional options:
* - **noAlerts** - `boolean` - do not display an alert message; defaults to `false`
*/
private getInternalBinaryResponse;
/**
* Returns a binary object.
* @param binaryUrl The URL to find binary
* @param options The object with additional options:
* - **noAlerts** - `boolean` - do not display an alert message; defaults to `false`
*/
private getExternalBinaryResponse;
private getBaseVersionResultListForLegacyEntry;
private getDeviceSoftwareChangesFromSoftwareListOperation;
private getDeviceSoftwareChangesFromSoftwareOperation;
private getCurrentSoftware;
private softwareListToLegacy;
private getGlobalFragment;
private removeOutdatedBinary;
static ɵfac: i0.ɵɵFactoryDeclaration<RepositoryService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<RepositoryService>;
}
//# sourceMappingURL=repository.service.d.ts.map