use of com.vmware.photon.controller.model.resources.SecurityGroupService.SecurityGroupState in project photon-model by vmware.
the class ProvisionSecurityGroupTaskService method patchAdapter.
private void patchAdapter(ProvisionSecurityGroupTaskState taskState, String subTaskLink) {
if (subTaskLink == null) {
createSubTask(taskState, link -> patchAdapter(taskState, link));
return;
}
taskState.securityGroupDescriptionLinks.forEach(sgLink -> sendRequest(Operation.createGet(UriUtils.buildUri(this.getHost(), sgLink)).setCompletion((o, e) -> {
if (e != null) {
// don't fail the task; just update the subtask, which will
// handle the failure if necessary
ResourceOperationResponse subTaskPatchBody = ResourceOperationResponse.fail(sgLink, e);
updateSubTask(subTaskLink, subTaskPatchBody);
return;
}
SecurityGroupState securityGroupState = o.getBody(SecurityGroupState.class);
SecurityGroupInstanceRequest req = toReq(securityGroupState, taskState, sgLink, subTaskLink);
sendRequest(Operation.createPatch(securityGroupState.instanceAdapterReference).setBody(req).setCompletion((oo, ee) -> {
if (ee != null) {
ResourceOperationResponse subTaskPatchBody = ResourceOperationResponse.fail(sgLink, ee);
updateSubTask(subTaskLink, subTaskPatchBody);
}
}));
})));
}
Aggregations