2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.vnfmadapter.extclients.aai;
23 import org.onap.aai.domain.yang.EsrSystemInfoList;
24 import org.onap.aai.domain.yang.EsrVnfm;
25 import org.onap.aai.domain.yang.EsrVnfmList;
26 import org.onap.aai.domain.yang.GenericVnf;
27 import org.onap.aai.domain.yang.Tenant;
28 import org.onap.so.client.aai.AAIObjectType;
29 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.stereotype.Service;
36 public class AaiServiceProviderImpl implements AaiServiceProvider {
38 private static final Logger logger = LoggerFactory.getLogger(AaiServiceProviderImpl.class);
39 private final AaiClientProvider aaiClientProvider;
42 public AaiServiceProviderImpl(final AaiClientProvider aaiClientProvider) {
43 this.aaiClientProvider = aaiClientProvider;
47 public GenericVnf invokeGetGenericVnf(final String vnfId) {
48 return aaiClientProvider.getAaiClient()
49 .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
51 logger.debug("No vnf found in AAI with ID: {}", vnfId);
57 public EsrVnfmList invokeGetVnfms() {
58 return aaiClientProvider.getAaiClient()
59 .get(EsrVnfmList.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM_LIST)).orElseGet(() -> {
60 logger.debug("No VNFMs in AAI");
66 public EsrVnfm invokeGetVnfm(final String vnfmId) {
67 return aaiClientProvider.getAaiClient()
68 .get(EsrVnfm.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId)).orElseGet(() -> {
69 logger.debug("VNFM not found in AAI");
75 public EsrSystemInfoList invokeGetVnfmEsrSystemInfoList(final String vnfmId) {
76 return aaiClientProvider.getAaiClient()
77 .get(EsrSystemInfoList.class,
78 AAIUriFactory.createResourceUri(AAIObjectType.VNFM_ESR_SYSTEM_INFO_LIST, vnfmId))
80 logger.debug("VNFM ESR system info list not found in AAI");
86 public void invokePutGenericVnf(final GenericVnf vnf) {
87 aaiClientProvider.getAaiClient()
88 .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()), vnf);
92 public Tenant invokeGetTenant(final String cloudOwner, final String cloudRegion, final String tenantId) {
93 return aaiClientProvider.getAaiClient()
95 AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId))
97 logger.debug("Tenant not found in AAI");
103 public EsrSystemInfoList invokeGetCloudRegionEsrSystemInfoList(final String cloudOwner, final String cloudRegion) {
104 return aaiClientProvider
105 .getAaiClient().get(EsrSystemInfoList.class, AAIUriFactory
106 .createResourceUri(AAIObjectType.CLOUD_ESR_SYSTEM_INFO_LIST, cloudOwner, cloudRegion))
108 logger.debug("Cloud esr system info list not found in AAI");