Interface MorpheusUpdateDefinitionService

All Superinterfaces:
MorpheusDataQueryService<UpdateDefinition>, MorpheusDataService<UpdateDefinition,UpdateIdentityProjection>, MorpheusIdentityService<UpdateIdentityProjection>

Provides async CRUD access to UpdateDefinition objects within the Morpheus appliance.

Use this service to create, sync, and query update definitions from a plugin provider. Update definitions describe available updates for a resource type (e.g., StorageServerType, ComputeServerType, NetworkServerType) and are scoped via UpdateDefinition.getRefType() and UpdateDefinition.getRefId().

refType vs UpdateOperation refType: The refType/refId on an UpdateDefinition identifies the resource type (e.g., a specific StorageServerType record). The refType/refId on an UpdateOperation identifies the specific resource instance being updated (e.g., a single StorageServer).

Sync pattern: Use code as the stable identity key when matching existing records. A typical sync loop looks like:


 List<UpdateDefinition> adds = new ArrayList<>();
 List<UpdateDefinition> updates = new ArrayList<>();

 // list existing projections scoped to your resource type
 List<UpdateIdentityProjection> existing = morpheusContext.getAsync().getUpdateDefinition()
     .listIdentityProjections(refType, refId).toList().blockingGet();

 for (MyUpdateInfo info : fetchFromSource()) {
     Optional<UpdateIdentityProjection> match = existing.stream()
         .filter(p -> p.getCode().equals(info.getCode())).findFirst();
     if (match.isPresent()) {
         UpdateDefinition ud = morpheusContext.getAsync().getUpdateDefinition()
             .get(match.get().getId()).blockingGet();
         // apply changes, add to updates list
     } else {
         UpdateDefinition ud = new UpdateDefinition();
         ud.setCode(info.getCode());
         ud.setRefType("StorageServerType");
         ud.setRefId(storageServerTypeId);
         // set other fields
         adds.add(ud);
     }
 }
 morpheusContext.getAsync().getUpdateDefinition().bulkCreate(adds).blockingGet();
 morpheusContext.getAsync().getUpdateDefinition().bulkSave(updates).blockingGet();
 
Since:
1.4.0
See Also: