2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actor.vfc;
23 import java.util.concurrent.CompletableFuture;
24 import javax.ws.rs.client.Entity;
25 import javax.ws.rs.core.MediaType;
26 import org.apache.commons.lang3.tuple.Pair;
27 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
28 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
29 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
30 import org.onap.policy.vfc.VfcRequest;
32 public class Restart extends VfcOperation {
33 public static final String NAME = "VF Module Create";
35 public Restart(ControlLoopOperationParams params, HttpConfig config) {
36 super(params, config);
40 protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
42 // starting a whole new attempt - reset the count
45 Pair<String, VfcRequest> pair = makeRequest();
46 Entity<VfcRequest> entity = Entity.entity(pair.getRight(), MediaType.APPLICATION_JSON);
47 String path = getPath() + pair.getLeft();
48 String url = getClient().getBaseUrl() + path;
50 return handleResponse(outcome, url, callback -> getClient().post(callback, path, entity, null));
56 * @return a pair containing the request URL and the new request
58 protected Pair<String, VfcRequest> makeRequest() {
60 VfcRequest request = super.constructVfcRequest();
61 String requestUrl = "/ns/" + request.getNsInstanceId() + "/heal";
62 return Pair.of(requestUrl, request);