2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
19 package org.onap.policy.controlloop.actor.cds.properties;
21 import java.util.List;
24 import org.onap.policy.controlloop.actor.cds.GrpcOperation;
25 import org.onap.policy.controlloop.actorserviceprovider.TargetType;
26 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29 import org.springframework.util.CollectionUtils;
32 * GRPC Operation Base Class.
35 public abstract class GrpcOperationProperties {
36 protected static final String AAI_PNF_PREFIX = "pnf.";
41 public static final String AAI_VNF_ID_KEY = "generic-vnf.vnf-id";
44 * AAI Service Instance Identifier.
46 public static final String AAI_SERVICE_INSTANCE_ID_KEY = "service-instance.service-instance-id";
48 private static final Logger logger = LoggerFactory.getLogger(GrpcOperationProperties.class);
51 * Build the appropriate GrpcOperation object depending on the target type.
53 public static GrpcOperationProperties build(ControlLoopOperationParams params) {
54 if (TargetType.PNF.equals(params.getTargetType())) {
55 return new GrpcOperationPnfProperties();
58 // assume VNF processing for backwards compatibility with istanbul
60 if (!TargetType.VNF.equals(params.getTargetType())) {
61 logger.warn("Unexpected target type, build VNF-like operation properties");
64 return CollectionUtils.isEmpty(params.getTargetEntityIds())
65 ? new GrpcOperationTargetVnfProperties()
66 : new GrcpOperationResourceVnfProperties();
70 * Get the property names.
72 public abstract List<String> getPropertyNames();
75 * Convert to the AAI properties.
77 public abstract Map<String, String> convertToAaiProperties(GrpcOperation operation);