/*-
* ========================LICENSE_START=================================
- * ORAN-OSC
+ * O-RAN-SC
* %%
* Copyright (C) 2019 AT&T Intellectual Property and Nokia
* %%
package org.oransc.ric.portal.dashboard.config;
import java.lang.invoke.MethodHandles;
+import java.net.MalformedURLException;
+import java.net.URL;
-import org.oransc.ric.xappmgr.client.api.DefaultApi;
+import org.oransc.ric.xappmgr.client.api.HealthApi;
+import org.oransc.ric.xappmgr.client.api.XappApi;
import org.oransc.ric.xappmgr.client.invoker.ApiClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-import org.springframework.util.Assert;
import org.springframework.web.client.RestTemplate;
/**
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Populated by the autowired constructor
- private final String xappMgrBasepath;
+ private final String xappMgrUrl;
@Autowired
- public XappManagerConfiguration(@Value("${xappmgr.basepath}") final String xappMgrBasepath) {
- Assert.notNull(xappMgrBasepath, "base path must not be null");
- logger.info("Configuring xApp Manager at base path {}", xappMgrBasepath);
- this.xappMgrBasepath = xappMgrBasepath;
+ public XappManagerConfiguration(@Value("${xappmgr.url}") final String url) throws MalformedURLException {
+ logger.info("Configuring xApp Manager at base URL {}", url);
+ new URL(url);
+ this.xappMgrUrl = url;
+ }
+
+ private ApiClient apiClient() {
+ ApiClient apiClient = new ApiClient(new RestTemplate());
+ apiClient.setBasePath(xappMgrUrl);
+ return apiClient;
}
/**
- * @return A DefaultApi with an ApiClient configured from properties
+ * @return A HealthApi with an ApiClient configured from properties
*/
@Bean
- public DefaultApi xappClient() {
- ApiClient apiClient = new ApiClient(new RestTemplate());
- apiClient.setBasePath(xappMgrBasepath);
- return new DefaultApi(apiClient);
+ // The bean (method) name must be globally unique
+ public HealthApi xappMgrHealthApi() {
+ return new HealthApi(apiClient());
}
+ /**
+ * @return An XappApi with an ApiClient configured from properties
+ */
+ @Bean
+ // The bean (method) name must be globally unique
+ public XappApi xappMgrXappApi() {
+ return new XappApi(apiClient());
+ }
}