diff options
Diffstat (limited to 'models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfProperties.java')
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfProperties.java | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfProperties.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfProperties.java new file mode 100644 index 000000000..5fcd30721 --- /dev/null +++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfProperties.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.controlloop.actor.cds.properties; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.policy.controlloop.actor.cds.GrpcOperation; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; + +/** + * VNF with target entities properties. + */ + +@Data +@EqualsAndHashCode(callSuper = true) +public class GrcpOperationResourceVnfProperties extends GrpcOperationProperties { + + // @formatter:off + protected static final List<String> VNF_PROPERTY_NAMES = List.of( + OperationProperties.AAI_RESOURCE_VNF, + OperationProperties.AAI_SERVICE, + OperationProperties.EVENT_ADDITIONAL_PARAMS, + OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES); + // @formatter:on + + @Override + public List<String> getPropertyNames() { + return VNF_PROPERTY_NAMES; + } + + @Override + public Map<String, String> convertToAaiProperties(GrpcOperation operation) { + Map<String, String> result = operation.getProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES); + if (result != null) { + return result; + } + + result = new LinkedHashMap<>(); + result.put(AAI_SERVICE_INSTANCE_ID_KEY, getServiceInstanceId(operation)); + result.put(AAI_VNF_ID_KEY, getVnfId(operation)); + return result; + } + + /** + * Get the service instance id from the required operation property. + */ + public String getServiceInstanceId(GrpcOperation operation) { + var serviceInstance = + (ServiceInstance) operation.getRequiredProperty(OperationProperties.AAI_SERVICE, + "Target service instance"); + return serviceInstance.getServiceInstanceId(); + } + + /** + * Get the vnf id from the required property. + */ + public String getVnfId(GrpcOperation operation) { + var genericVnf = + (GenericVnf) operation.getRequiredProperty(OperationProperties.AAI_RESOURCE_VNF, "Target generic vnf"); + return genericVnf.getVnfId(); + } +} |