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.so.client.aai.AAIObjectType;
28 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Service;
35 public class AaiServiceProviderImpl implements AaiServiceProvider {
37 private static final Logger logger = LoggerFactory.getLogger(AaiServiceProviderImpl.class);
38 private final AaiClientProvider aaiClientProvider;
41 public AaiServiceProviderImpl(final AaiClientProvider aaiClientProvider) {
42 this.aaiClientProvider = aaiClientProvider;
46 public GenericVnf invokeGetGenericVnf(final String vnfId) {
47 return aaiClientProvider.getAaiClient()
48 .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId))
50 logger.debug("No vnf found in AAI with ID: {}", vnfId);
56 public EsrVnfmList invokeGetVnfms() {
57 return aaiClientProvider.getAaiClient()
58 .get(EsrVnfmList.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM_LIST)).orElseGet(() -> {
59 logger.debug("No VNFMs in AAI");
65 public EsrVnfm invokeGetVnfm(final String vnfmId) {
66 return aaiClientProvider.getAaiClient()
67 .get(EsrVnfm.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId)).orElseGet(() -> {
68 logger.debug("VNFM not found in AAI");
74 public EsrSystemInfoList invokeGetVnfmEsrSystemInfoList(final String vnfmId) {
75 return aaiClientProvider.getAaiClient()
76 .get(EsrSystemInfoList.class,
77 AAIUriFactory.createResourceUri(AAIObjectType.VNFM_ESR_SYSTEM_INFO_LIST, vnfmId))
79 logger.debug("VNFM ESR system info list not found in AAI");
85 public void invokePutGenericVnf(final GenericVnf vnf) {
86 aaiClientProvider.getAaiClient()
87 .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()), vnf);