2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2022 CTC, Inc. and others. All rights reserved.
6 * Modifications Copyright (C) 2023 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.controlloop.actor.so;
24 import jakarta.ws.rs.client.Entity;
25 import jakarta.ws.rs.core.MediaType;
26 import java.util.List;
28 import java.util.concurrent.CompletableFuture;
29 import org.onap.policy.common.endpoints.event.comm.Topic;
30 import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
31 import org.onap.policy.common.utils.coder.CoderException;
32 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
33 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
34 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
35 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
36 import org.onap.policy.so.SoRequestCll;
38 public class ModifyCll extends SoOperation {
39 public static final String NAME = "ModifyCloudLeasedLine";
41 private static final List<String> PROPERTY_NAMES = List.of(
42 OperationProperties.EVENT_PAYLOAD);
45 * Constructs the object.
47 * @param params operation parameters
48 * @param config configuration for this operation
50 public ModifyCll(ControlLoopOperationParams params, HttpPollingConfig config) {
51 super(params, config, PROPERTY_NAMES);
55 protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
57 SoRequestCll soRequest = makeRequest();
59 String path = getPath();
60 String url = getClient().getBaseUrl() + path;
62 String strRequest = prettyPrint(soRequest);
63 logMessage(NetLoggerUtil.EventType.OUT, Topic.CommInfrastructure.REST, url, strRequest);
65 Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
66 Map<String, Object> headers = createSimpleHeaders();
68 return handleResponse(outcome, url, callback -> getClient().put(callback, path, entity, headers));
71 protected SoRequestCll makeRequest() {
73 String payload = getRequiredProperty(OperationProperties.EVENT_PAYLOAD, "event payload");
75 return getCoder().convert(payload, SoRequestCll.class);
76 } catch (CoderException e) {
77 throw new IllegalArgumentException("invalid payload value: " + payload, e);