1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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();
}
}
|