use of com.vmware.xenon.common.ServiceDocument in project photon-model by vmware.
the class TestAWSSetupUtils method createAWSEndpointStateUsingAllocationTask.
/**
* Create endpoint using EndpointAllocationTaskService.
*/
public static EndpointState createAWSEndpointStateUsingAllocationTask(VerificationHost host, String authLink, String resPoolLink, String accessKey, String secretKey, String endpointName) throws Throwable {
EndpointState endpoint = createEndpointState(authLink, resPoolLink, accessKey, secretKey, endpointName);
EndpointAllocationTaskState startState = createEndpointAllocationRequest(endpoint);
EndpointAllocationTaskState returnState = TestUtils.doPost(host, startState, EndpointAllocationTaskState.class, UriUtils.buildUri(host, EndpointAllocationTaskService.FACTORY_LINK));
EndpointAllocationTaskState completeState = host.waitForFinishedTask(EndpointAllocationTaskState.class, returnState.documentSelfLink);
assertTrue(completeState.taskInfo.stage == TaskState.TaskStage.FINISHED);
Operation response = host.waitForResponse(Operation.createGet(host, completeState.documentSelfLink));
EndpointAllocationTaskState taskState = response.getBody(EndpointAllocationTaskState.class);
assertNotNull(taskState.endpointState);
ServiceDocument endpointState = taskState.endpointState;
assertNotNull(endpointState.documentSelfLink);
response = host.waitForResponse(Operation.createGet(host, endpointState.documentSelfLink));
return response.getBody(EndpointState.class);
}
use of com.vmware.xenon.common.ServiceDocument in project photon-model by vmware.
the class VSphereVirtualMachineEnumerationHelper method deleteVM.
private static void deleteVM(EnumerationProgress enumerationProgress, VmOverlay vmOverlay, VSphereIncrementalEnumerationService service, ServiceDocument oldDocument) {
if (!enumerationProgress.getRequest().preserveMissing) {
Operation.createDelete(PhotonModelUriUtils.createInventoryUri(service.getHost(), oldDocument.documentSelfLink)).setCompletion((o, e) -> {
trackVm(enumerationProgress).handle(o, e);
}).sendWith(service);
} else {
ResourceCleanRequest patch = new ResourceCleanRequest();
patch.resourceLink = oldDocument.documentSelfLink;
Operation.createPatch(service, VSphereUriPaths.RESOURCE_CLEANER).setBody(patch).setCompletion((o, e) -> {
trackVm(enumerationProgress).handle(o, e);
}).sendWith(service);
}
}
use of com.vmware.xenon.common.ServiceDocument in project photon-model by vmware.
the class ResourceDescriptionService method getDocumentTemplate.
@Override
public ServiceDocument getDocumentTemplate() {
ServiceDocument template = super.getDocumentTemplate();
// enable metadata indexing
template.documentDescription.documentIndexingOptions = EnumSet.of(DocumentIndexingOption.INDEX_METADATA);
ServiceUtils.setRetentionLimit(template);
return template;
}
use of com.vmware.xenon.common.ServiceDocument in project photon-model by vmware.
the class ResourceUtils method handleDelete.
public static void handleDelete(Operation op, StatefulService service) {
service.logInfo("Deleting document %s, Operation ID: %d, Referrer: %s", op.getUri().getPath(), op.getId(), op.getRefererAsString());
ServiceDocument currentState = service.getState(op);
// by default set the expiration to one month later.
if (op.hasBody()) {
ServiceDocument opState = op.getBody(ServiceDocument.class);
if (opState.documentExpirationTimeMicros > 0) {
currentState.documentExpirationTimeMicros = opState.documentExpirationTimeMicros;
}
} else {
currentState.documentExpirationTimeMicros = Utils.getNowMicrosUtc() + TimeUnit.DAYS.toMicros(31);
}
op.complete();
}
use of com.vmware.xenon.common.ServiceDocument in project photon-model by vmware.
the class TagService method getDocumentTemplate.
@Override
public ServiceDocument getDocumentTemplate() {
ServiceDocument td = super.getDocumentTemplate();
// enable metadata indexing
td.documentDescription.documentIndexingOptions = EnumSet.of(DocumentIndexingOption.INDEX_METADATA);
ServiceUtils.setRetentionLimit(td);
TagState template = (TagState) td;
template.key = "key-1";
template.value = "value-1";
return template;
}
Aggregations