import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture;
import org.onap.policy.so.SoModelInfo;
import org.onap.policy.so.SoOperationType;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequestDetails;
+import org.onap.policy.so.SoResponse;
/**
* Operation to delete a VF Module. This gets the VF count from the A&AI Custom Query
private static final String PATH_PREFIX = "/";
+ // @formatter:off
+ private static final List<String> PROPERTY_NAMES = List.of(
+ OperationProperties.AAI_MODEL_SERVICE,
+ OperationProperties.AAI_MODEL_VNF,
+ OperationProperties.AAI_MODEL_CLOUD_REGION,
+ OperationProperties.AAI_MODEL_TENANT,
+ OperationProperties.DATA_VF_COUNT);
+ // @formatter:on
+
/**
* Constructs the object.
*
* @param params operation parameters
* @param config configuration for this operation
*/
- public VfModuleDelete(ControlLoopOperationParams params, HttpConfig config) {
- super(params, config);
+ public VfModuleDelete(ControlLoopOperationParams params, HttpPollingConfig config) {
+ super(params, config, PROPERTY_NAMES);
// ensure we have the necessary parameters
validateTarget();
@Override
@SuppressWarnings("unchecked")
protected CompletableFuture<OperationOutcome> startPreprocessorAsync() {
+ if (params.isPreprocessed()) {
+ return null;
+ }
// need the VF count
ControlLoopOperationParams cqParams = params.toBuilder().actor(AaiConstants.ACTOR_NAME)
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
// starting a whole new attempt - reset the count
- resetGetCount();
+ resetPollCount();
Pair<String, SoRequest> pair = makeRequest();
SoRequest request = pair.getRight();
* HttpClient, as the JerseyClient does not support it. This will add the content-type
* and authorization headers, so they should not be included within "headers".
*
- * @param <Q> request type
* @param uri URI suffix, to be appended to the URI prefix
* @param headers headers to be included
* @param contentType content type of the request
* @return a future to await the response. Note: it's untested whether canceling this
* future will actually cancel the underlying HTTP request
*/
- protected <Q> CompletableFuture<Response> delete(String uri, Map<String, Object> headers, String contentType,
+ protected CompletableFuture<Response> delete(String uri, Map<String, Object> headers, String contentType,
String request, InvocationCallback<Response> callback) {
// TODO move to HttpOperation
return builder.header("Authorization", "Basic " + encoded);
}
+
/**
- * Decrements the VF count that's stored in the context.
+ * Decrements the VF count that's stored in the context, if the request was
+ * successful.
*/
@Override
- protected void successfulCompletion() {
- setVfCount(getVfCount() - 1);
+ protected Status detmStatus(Response rawResponse, SoResponse response) {
+ Status status = super.detmStatus(rawResponse, response);
+
+ if (status == Status.SUCCESS) {
+ setVfCount(getVfCount() - 1);
+ }
+
+ return status;
}
/**