2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2023 Nordix Foundation. 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 com.oransc.rappmanager;
21 import com.oransc.rappmanager.acm.ApiClient;
22 import com.oransc.rappmanager.acm.configuration.ACMConfiguration;
23 import com.oransc.rappmanager.acm.rest.AutomationCompositionDefinitionApiClient;
24 import com.oransc.rappmanager.acm.rest.AutomationCompositionInstanceApiClient;
25 import com.oransc.rappmanager.acm.rest.ParticipantMonitoringApiClient;
26 import com.oransc.rappmanager.sme.configuration.SmeConfiguration;
27 import com.oransc.rappmanager.sme.provider.rest.DefaultApiClient;
28 import lombok.RequiredArgsConstructor;
29 import org.springframework.beans.factory.annotation.Qualifier;
30 import org.springframework.boot.web.client.RestTemplateBuilder;
31 import org.springframework.cache.CacheManager;
32 import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
33 import org.springframework.context.annotation.Bean;
34 import org.springframework.context.annotation.Configuration;
35 import org.springframework.web.client.RestTemplate;
38 @RequiredArgsConstructor
39 public class BeanConfiguration {
41 private final ACMConfiguration acmConfiguration;
42 private final SmeConfiguration smeConfiguration;
45 public RestTemplate restTemplate(RestTemplateBuilder builder) {
46 return builder.build();
50 public ApiClient acmApiClient(RestTemplate restTemplate) {
51 ApiClient apiClient = new ApiClient(restTemplate);
52 apiClient.setUsername(acmConfiguration.getUsername());
53 apiClient.setPassword(acmConfiguration.getPassword());
54 return apiClient.setBasePath(acmConfiguration.getBaseUrl());
57 @Bean("smeProviderApiClient")
58 public com.oransc.rappmanager.sme.provider.ApiClient smeProviderApiClient(RestTemplate restTemplate) {
59 return new com.oransc.rappmanager.sme.provider.ApiClient(restTemplate);
62 @Bean("smePublishServiceApiClient")
63 public com.oransc.rappmanager.sme.publishservice.ApiClient smePublishServiceApiClient(RestTemplate restTemplate) {
64 return new com.oransc.rappmanager.sme.publishservice.ApiClient(restTemplate);
67 @Bean("smeInvokerApiClient")
68 public com.oransc.rappmanager.sme.invoker.ApiClient smeInvokerApiClient(RestTemplate restTemplate) {
69 return new com.oransc.rappmanager.sme.invoker.ApiClient(restTemplate);
73 public ParticipantMonitoringApiClient participantMonitoringApiClient(
74 @Qualifier("acmApiClient") ApiClient apiClient) {
75 return new ParticipantMonitoringApiClient(apiClient);
79 public AutomationCompositionDefinitionApiClient automationCompositionDefinitionApiClient(
80 @Qualifier("acmApiClient") ApiClient apiClient) {
81 return new AutomationCompositionDefinitionApiClient(apiClient);
85 public AutomationCompositionInstanceApiClient automationCompositionInstanceApiClient(
86 @Qualifier("acmApiClient") ApiClient apiClient) {
87 return new AutomationCompositionInstanceApiClient(apiClient);
91 public DefaultApiClient defaultProviderApiClient(
92 @Qualifier("smeProviderApiClient") com.oransc.rappmanager.sme.provider.ApiClient apiClient) {
93 apiClient.setBasePath(smeConfiguration.getBaseUrl() + smeConfiguration.getProviderBasePath());
94 return new DefaultApiClient(apiClient);
98 public com.oransc.rappmanager.sme.publishservice.rest.DefaultApiClient defaultPublishServiceApiClient(
99 @Qualifier("smePublishServiceApiClient") com.oransc.rappmanager.sme.publishservice.ApiClient apiClient) {
100 apiClient.setBasePath(smeConfiguration.getBaseUrl() + smeConfiguration.getPublishApiBasePath());
101 return new com.oransc.rappmanager.sme.publishservice.rest.DefaultApiClient(apiClient);
105 public com.oransc.rappmanager.sme.invoker.rest.DefaultApiClient defaultInvokerApiClient(
106 @Qualifier("smeInvokerApiClient") com.oransc.rappmanager.sme.invoker.ApiClient apiClient) {
107 apiClient.setBasePath(smeConfiguration.getBaseUrl() + smeConfiguration.getInvokerBasePath());
108 return new com.oransc.rappmanager.sme.invoker.rest.DefaultApiClient(apiClient);
112 public CacheManager cacheManager() {
113 return new ConcurrentMapCacheManager();