@Override public void handlePatch(Operation patch) { NetworkInterfaceState currentState = getState(patch); ResourceUtils.handlePatch(this, patch, currentState, getStateDescription(), NetworkInterfaceState.class, t -> { NetworkInterfaceState patchBody = patch.getBody(NetworkInterfaceState.class); boolean hasStateChanged = false; if (patchBody.endpointLink != null && currentState.endpointLink == null) { currentState.endpointLink = patchBody.endpointLink; hasStateChanged = true; } if (patchBody.securityGroupLinks != null) { if (currentState.securityGroupLinks == null) { currentState.securityGroupLinks = patchBody.securityGroupLinks; hasStateChanged = true; } else { for (String link : patchBody.securityGroupLinks) { if (!currentState.securityGroupLinks.contains(link)) { currentState.securityGroupLinks.add(link); hasStateChanged = true; } } } } return hasStateChanged; }); }
private NetworkInterfaceState validatePut(Operation op) { NetworkInterfaceState state = processInput(op); NetworkInterfaceState currentState = getState(op); ResourceUtils.validatePut(state, currentState); return state; }
@Override public void handlePatch(Operation patch) { NetworkInterfaceState currentState = getState(patch); ResourceUtils.handlePatch(patch, currentState, getStateDescription(), NetworkInterfaceState.class, t -> { NetworkInterfaceState patchBody = patch.getBody(NetworkInterfaceState.class); boolean hasStateChanged = false; if (patchBody.endpointLink != null && currentState.endpointLink == null) { currentState.endpointLink = patchBody.endpointLink; hasStateChanged = true; } if (patchBody.securityGroupLinks != null) { if (currentState.securityGroupLinks == null) { currentState.securityGroupLinks = patchBody.securityGroupLinks; hasStateChanged = true; } else { for (String link : patchBody.securityGroupLinks) { if (!currentState.securityGroupLinks.contains(link)) { currentState.securityGroupLinks.add(link); hasStateChanged = true; } } } } return hasStateChanged; }); }
@Override public void handleGet(Operation get) { NetworkInterfaceState currentState = getState(get); boolean doExpand = get.getUri().getQuery() != null && UriUtils.hasODataExpandParamValue(get.getUri()); if (!doExpand) { get.setBody(currentState).complete(); return; } // retrieve the description and include in an augmented version of our // state. Operation getDesc = Operation .createGet(this, currentState.networkInterfaceDescriptionLink) .setCompletion( (o, e) -> { if (e != null) { get.fail(e); return; } NetworkInterfaceDescription desc = o .getBody(NetworkInterfaceDescription.class); NetworkInterfaceStateWithDescription stateWithDesc = NetworkInterfaceStateWithDescription .create(desc, currentState); get.setBody(stateWithDesc).complete(); }); sendRequest(getDesc); }
@Override public void handleGet(Operation get) { NetworkInterfaceState currentState = getState(get); boolean doExpand = get.getUri().getQuery() != null && UriUtils.hasODataExpandParamValue(get.getUri()); if (!doExpand) { get.setBody(currentState).complete(); return; } // retrieve the description and include in an augmented version of our // state. Operation getDesc = Operation .createGet(this, currentState.networkInterfaceDescriptionLink) .setCompletion( (o, e) -> { if (e != null) { get.fail(e); return; } NetworkInterfaceDescription desc = o .getBody(NetworkInterfaceDescription.class); NetworkInterfaceStateWithDescription stateWithDesc = NetworkInterfaceStateWithDescription .create(desc, currentState); get.setBody(stateWithDesc).complete(); }); sendRequest(getDesc); }