File

repository/shared/repository.service.ts

Index

Properties
Methods

Constructor

constructor(inventory: InventoryService, inventoryBinary: InventoryBinaryService, operation: OperationService, alert: AlertService, event: EventService, operationRealtime: OperationRealtimeService, eventBinary: EventBinaryService, advancedSoftwareService: AdvancedSoftwareService)
Parameters :
Name Type Optional
inventory InventoryService No
inventoryBinary InventoryBinaryService No
operation OperationService No
alert AlertService No
event EventService No
operationRealtime OperationRealtimeService No
eventBinary EventBinaryService No
advancedSoftwareService AdvancedSoftwareService No

Methods

cleanUp
cleanUp(mosToDelete: IIdentified[])
Parameters :
Name Type Optional
mosToDelete IIdentified[] No
Returns : void
Async create
create(modal: ModalModel, type: RepositoryType)
Parameters :
Name Type Optional
modal ModalModel No
type RepositoryType No
Returns : unknown
Async createFirmwareOrSoftware
createFirmwareOrSoftware(modal: ModalModel, type: RepositoryType)
Parameters :
Name Type Optional
modal ModalModel No
type RepositoryType No
Async createFirmwareUpdateOperation
createFirmwareUpdateOperation(device: IManagedObject, selectedOption: SelectedRepositoryBinary)

Prepares a firmware update operation for given device and the selected repository binary, and sends it to the device.

Parameters :
Name Type Optional Description
device IManagedObject No

The device which the operation should be prepared for and sent to.

selectedOption SelectedRepositoryBinary No

The selected repository binary option.

Returns : Promise<IOperation>
createObservedOperation
createObservedOperation(operation: 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.

Parameters :
Name Type Optional Description
operation IOperation No

The operation to create and track.

Returns : Observable<IOperation>
createOrUpdateRepositoryEntry
createOrUpdateRepositoryEntry(modal: ModalModel, type: RepositoryType)
Parameters :
Name Type Optional
modal ModalModel No
type RepositoryType No
createRepositoryBinary
createRepositoryBinary(modal: ModalModel, binaryURL: string, type: RepositoryType, parent: RepositoryCategory)
Parameters :
Name Type Optional
modal ModalModel No
binaryURL string No
type RepositoryType No
parent RepositoryCategory No
Returns : Promise<IResult<FirmwareBinary | SoftwareBinary | FirmwarePatchBinary>>
Async createSoftwareUpdateOperation
createSoftwareUpdateOperation(device: IManagedObject, changes: DeviceSoftwareChange[])

Prepares a software update operation for given device and the list of changes, and sends it to the device.

Parameters :
Name Type Optional Description
device IManagedObject No

The device which the operation should be prepared for and sent to.

changes DeviceSoftwareChange[] No

The list of software changes which should be applied.

Returns : Promise<IOperation>
createTextBasedConfigurationReloadOperation
createTextBasedConfigurationReloadOperation(device: IManagedObject)

Prepares a configuration download operation for given device and its current configuration. Supports c8y_SendConfiguration operation.

Parameters :
Name Type Optional Description
device IManagedObject No

The device for which operation should be prepared.

Returns : IOperation
createTextBasedConfigurationUpdateOperation
createTextBasedConfigurationUpdateOperation(device: IManagedObject, config: string)

Prepares a configuration update operation for the given device. Supports c8y_Configuration operation.

Parameters :
Name Type Optional Description
device IManagedObject No

The device for which operation should be prepared.

config string No

The configuration which will update the existing one.

Returns : IOperation
delete
delete(entity: IIdentified)
Parameters :
Name Type Optional
entity IIdentified No
Returns : Promise<IResult<undefined>>
errorMsg
errorMsg()
Returns : void
Async fetchAllItemsFromList
fetchAllItemsFromList(firstPage)

Fetches all items from the list starting with the provided page.

Parameters :
Name Optional Description
firstPage No

The first page of the list to fetch all items for.

Returns : unknown
getBaseVersionFromMO
getBaseVersionFromMO(mo: RepositoryBinary)
Parameters :
Name Type Optional
mo RepositoryBinary No
Returns : string
getBaseVersionsCount$
getBaseVersionsCount$(entry: IManagedObject)
Parameters :
Name Type Optional
entry IManagedObject No
Returns : Observable<number>
Async getBinary
getBinary(binaryId: IdReference)
Parameters :
Name Type Optional
binaryId IdReference No
Returns : Promise<IFetchResponse>
Async getBinaryFile
getBinaryFile(binaryUrl: string, options: literal type)

Returns a binary object as File.

  • allowExternal - boolean - allows downloading external binary file
Parameters :
Name Type Optional Description
binaryUrl string No

The URL to find binary

options literal type No

The object with additional options:

  • allowExternal - boolean - allows downloading external binary file
Returns : Promise<File>
getBinaryName$
getBinaryName$(binaryUrl: string)
Parameters :
Name Type Optional
binaryUrl string No
Returns : Observable<string>
Async getBinaryText
getBinaryText(binaryUrl: string, options: literal type)

Returns a binary object as text.

  • allowExternal - boolean - allows downloading external binary file
  • noAlerts - boolean - do not display an alert message; defaults to false
Parameters :
Name Type Optional Description
binaryUrl string No

The URL to find binary

options literal type No

The object with additional options:

  • allowExternal - boolean - allows downloading external binary file
  • noAlerts - boolean - do not display an alert message; defaults to false
Returns : Promise<string>
Async getConfigFileOperationList
getConfigFileOperationList(deviceId: string | number, operationType: string)

Gets a list of operations for the given device Id, and operation type.

Parameters :
Name Type Optional Description
deviceId string | number No

The device Id for which the operation should be queried.

operationType string No

Operation type fragment.

Returns : Promise<IOperation[]>
Async getConfigSnapshot
getConfigSnapshot(device: IManagedObject, configurationType: string)

Gets latest uploaded configuration snapshot for the given device, and configuration type.

Parameters :
Name Type Optional Description
device IManagedObject No

The device for which the configuration snapshot was uploaded.

configurationType string No

Selected configuration type.

getConfigurationTypeQuery
getConfigurationTypeQuery(device: IManagedObject, configurationType: string)

Generates an inventory query object which can be used to find configuration repository entries matching the type of provided device and specified configuration type.

Parameters :
Name Type Optional Description
device IManagedObject No

The device for which matching repository entries will be queried with the generated query.

configurationType string No

Configuration type for which matching repository entries will be queried with the generated query.

Returns : object
Async getDeviceSoftwareChangesFromOperation
getDeviceSoftwareChangesFromOperation(operation: IOperation, device: IManagedObject)

Extracts the list of device software changes from given operation in the context of given device.

Parameters :
Name Type Optional Description
operation IOperation No

The operation from which the list should be extracted.

device IManagedObject No

The target device of the operation.

Returns : Promise<DeviceSoftwareChange[]>
getDeviceSoftwareList
getDeviceSoftwareList(device: IManagedObject)

Gets the list of software installed in the device in the uniform format. Supports c8y_SoftwareList and c8y_Software fragments.

Parameters :
Name Type Optional Description
device IManagedObject No

The device whose software list should be returned.

Returns : DeviceSoftware[]
getDeviceTypeQuery
getDeviceTypeQuery(repositoryType: RepositoryType, device: IManagedObject)

Generates an inventory query object which can be used to find repository entries of specified type matching the type of provided device.

Parameters :
Name Type Optional Description
repositoryType RepositoryType No

The type of repository entries which will be queried with the generated query.

device IManagedObject No

The device for which matching repository entries will be queried with the generated query.

Returns : object
getDownloadConfigurationFileOperation
getDownloadConfigurationFileOperation(device: IManagedObject, configurationType: string, configSnapshot: ConfigurationSnapshot, isLegacy: boolean)

Prepares a configuration file download operation for given device and configuration type.

Parameters :
Name Type Optional Default value Description
device IManagedObject No

The device for which operation should be prepared.

configurationType string No

Selected configuration type.

configSnapshot ConfigurationSnapshot No
isLegacy boolean No false

A legacy operation is created without a configurationType.

Returns : IOperation
getFirmwareUpdateOperation
getFirmwareUpdateOperation(device: IManagedObject, selectedOption: SelectedRepositoryBinary)

Prepares a firmware update operation for given device and selected version. Supports c8y_Firmware operation.

Parameters :
Name Type Optional Description
device IManagedObject No

The device for which operation should be prepared.

selectedOption SelectedRepositoryBinary No

Selected firmware version.

Returns : IOperation
Async getFirstMatchingOperation
getFirstMatchingOperation(filtersList: any[])

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.

Parameters :
Name Type Optional Description
filtersList any[] No

The list of filters for the queries.

Returns : Promise<IOperation>
Async getLastConfigUpdateOperation
getLastConfigUpdateOperation(deviceId: string | number)

Gets the last configuration update operation for given device. Looks for c8y_Configuration and c8y_SendConfiguration operations.

Parameters :
Name Type Optional Description
deviceId string | number No

The ID of the device to find an operation for.

Returns : Promise<IOperation>
Async getLastFirmwareUpdateOperation
getLastFirmwareUpdateOperation(deviceId: string | number)

Gets the last firmware update operation for given device. Looks for c8y_Firmware operations.

Parameters :
Name Type Optional Description
deviceId string | number No

The ID of the device to find an operation for.

Returns : Promise<IOperation>
Async getLastSoftwareUpdateOperation
getLastSoftwareUpdateOperation(deviceId: string | number)

Gets the last software update operation for given device. Looks for c8y_SoftwareUpdate, c8y_SoftwareList, or c8y_Software operations.

Parameters :
Name Type Optional Description
deviceId string | number No

The ID of the device to find an operation for.

Returns : Promise<IOperation>
Async getLatestConfigurationEvent
getLatestConfigurationEvent(deviceId: string | number, type: string)

Gets a single event with latest creationTime for the given device Id and event type.

Parameters :
Name Type Optional Description
deviceId string | number No

The device Id for which the events should be queried.

type string No

Event type.

Returns : Promise<IEvent | undefined>
Async getLatestMatchingOperation
getLatestMatchingOperation(filtersList: any[])

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.

Parameters :
Name Type Optional Description
filtersList any[] No

The list of filters for the queries.

Returns : Promise<IOperation>
Async getLegacyConfigSnapshot
getLegacyConfigSnapshot(deviceId)
Parameters :
Name Optional
deviceId No
Returns : unknown
getPatchVersionsCount$
getPatchVersionsCount$(entry: IManagedObject, baseVersion: FirmwareBinary)
Parameters :
Name Type Optional
entry IManagedObject No
baseVersion FirmwareBinary No
Returns : Observable<number>
getRepositoryBinaryMoByVersion
as it doesn't support 'missing url' case
getRepositoryBinaryMoByVersion(deviceRepositoryFragment: DeviceFirmware | DeviceSoftware, type: RepositoryType, undefined: literal type)

Gets base or patch version managed object.

  • skipLegacy - boolean - Exclude legacy entries.
  • filters - object - Filter object.
Parameters :
Name Type Optional Default value Description
deviceRepositoryFragment DeviceFirmware | DeviceSoftware No

Device repository fragment.

type RepositoryType No

Top level repository entry type.

literal type No {}
Returns : Promise<IManagedObject>
getRepositoryEntryMO$
getRepositoryEntryMO$(mo: IManagedObject)

Gets top level repository entry managed object for base or patch version.

Parameters :
Name Type Optional Description
mo IManagedObject No

Base or patch version managed object with parents.

Returns : Observable<IManagedObject | undefined>
Async getSnapshotsFromRepository
getSnapshotsFromRepository(device, configurationType)

Gets all available snapshots from the repository for the given device.

Parameters :
Name Optional Description
device No

The device for which the snapshots should be prepared.

configurationType No

Selected configuration type.

Returns : unknown
getSoftwareTypeQuery
getSoftwareTypeQuery(device: IManagedObject, query?: object)

Generates an inventory query object which can be used to find repository entries matching the predefined software types provided in the device.

Parameters :
Name Type Optional Description
device IManagedObject No

The device for which matching repository entries will be queried with the generated query.

query object Yes

The query to which the software types filters will be attached. Default value is an object containg repository type software.

Returns : object
Async getSoftwareUpdateOperation
getSoftwareUpdateOperation(device: IManagedObject, changes: DeviceSoftwareChange[])

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.

Parameters :
Name Type Optional Description
device IManagedObject No

The device for which operation should be prepared.

changes DeviceSoftwareChange[] No

The list of software changes which should be applied.

Returns : Promise<IOperation>
getUploadConfigurationFileOperation
getUploadConfigurationFileOperation(device: IManagedObject, configurationType: string, isLegacy: boolean)

Prepares a configuration file upload operation for given device and configuration type.

Parameters :
Name Type Optional Default value Description
device IManagedObject No

The device for which operation should be prepared.

configurationType string No

Selected configuration type.

isLegacy boolean No false

A legacy operation is created without a configurationType.

Returns : IOperation
isLegacyEntry
isLegacyEntry(entry: Partial)
Parameters :
Name Type Optional
entry Partial<IManagedObject> No
Returns : boolean
isPatch
isPatch(mo: RepositoryBinary)
Parameters :
Name Type Optional
mo RepositoryBinary No
Returns : boolean
Async isSoftwareInstalledOnDevice
isSoftwareInstalledOnDevice(deviceId: string | number, software: DeviceSoftware)

Checks if a device already have a given software installed

Parameters :
Name Type Optional Description
deviceId string | number No

Id of the device to be checked

software DeviceSoftware No

The software to be checked

Returns : Promise<boolean>
Async linkBinary
linkBinary(repositoryBinary: FirmwareBinary | SoftwareBinary, binary: IManagedObjectBinary)
Parameters :
Name Type Optional
repositoryBinary FirmwareBinary | SoftwareBinary No
binary IManagedObjectBinary No
Returns : unknown
listAllVersions
listAllVersions(entry: Partial, params: object)

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).

Parameters :
Name Type Optional Default value Description
entry Partial<IManagedObject> No

Top level repository entry.

params object No {}

Additional query params.

Returns : any
listBaseVersionAndPatches
listBaseVersionAndPatches(entry: IManagedObject, baseVersion: IManagedObject, params: object)

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.

Parameters :
Name Type Optional Default value Description
entry IManagedObject No

Top level repository entry.

baseVersion IManagedObject No

Base version.

params object No {}

Additional query params.

Returns : any
listBaseVersions
listBaseVersions(entry: Partial, params: object)

Lists base versions of given top level entry. Versions are ordered by creation time (assuming the earlier created, the older the version).

Parameters :
Name Type Optional Default value Description
entry Partial<IManagedObject> No

Top level repository entry.

params object No {}

Additional query params.

Returns : any
listChildren
listChildren(entry: Partial, filters: object, params: any)
Parameters :
Name Type Optional Default value
entry Partial<IManagedObject> No
filters object No {}
params any No {}
Returns : any
listPatchVersions
listPatchVersions(entry: IManagedObject, baseVersion: FirmwareBinary | string, params: object)

Lists patch versions of given base version under the entry. Versions are ordered by creation time (assuming the earlier created, the older the version).

Parameters :
Name Type Optional Default value Description
entry IManagedObject No

Top level repository entry.

baseVersion FirmwareBinary | string No

Base version.

params object No {}

Additional query params.

Returns : any
listRepositoryEntries
listRepositoryEntries(type: RepositoryType, options?: literal type)

Lists repository entries of given type.

Parameters :
Name Type Optional Description
type RepositoryType No

The type of repository entries to list.

options literal type Yes

Extra listing options.

Returns : any
observeOperation
observeOperation(operation: 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.

Parameters :
Name Type Optional Description
operation IOperation No

The operation to be observed.

Returns : Observable<IOperation>
prepareRepositoryBinaryMO
prepareRepositoryBinaryMO(modal: ModalModel, binaryURL: string, type: RepositoryType)
Parameters :
Name Type Optional
modal ModalModel No
binaryURL string No
type RepositoryType No
Async save
save(data: ModalModel, type: RepositoryType, mo: Partial)
Parameters :
Name Type Optional Default value
data ModalModel No
type RepositoryType No
mo Partial<IManagedObject> No {}
Returns : unknown
saveBinary
saveBinary(file: File)
Parameters :
Name Type Optional
file File No
Returns : Promise<IResult<IManagedObjectBinary>>

Properties

Readonly dateFrom
Default value : new Date(0)
Readonly dateTo
Default value : new Date(Date.now() + 86400000)

results matching ""

    No results matching ""