+ .flatMap(version -> createA1ClientMono(ric, version));
+ }
+
+ A1Client createClient(Ric ric, A1ProtocolType version) throws ServiceException {
+ if (version == A1ProtocolType.STD_V1_1) {
+ assertNoControllerConfig(ric, version);
+ return new StdA1ClientVersion1(ric.getConfig(), this.appConfig.getWebClientConfig());
+ } else if (version == A1ProtocolType.OSC_V1) {
+ assertNoControllerConfig(ric, version);
+ return new OscA1Client(ric.getConfig(), this.appConfig.getWebClientConfig());
+ } else if (version == A1ProtocolType.SDNC_OSC_STD_V1_1 || version == A1ProtocolType.SDNC_OSC_OSC_V1) {
+ return new SdncOscA1Client(version, ric.getConfig(), getControllerConfig(ric));
+ } else if (version == A1ProtocolType.SDNC_ONAP) {
+ return new SdncOnapA1Client(ric.getConfig(), getControllerConfig(ric));
+ } else {
+ logger.error("Unhandled protocol: {}", version);
+ throw new ServiceException("Unhandled protocol");
+ }
+ }
+
+ private ControllerConfig getControllerConfig(Ric ric) throws ServiceException {
+ String controllerName = ric.getConfig().controllerName();
+ if (controllerName.isEmpty()) {
+ ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
+ throw new ServiceException("No controller configured for RIC: " + ric.name());
+ }
+ try {
+ return this.appConfig.getControllerConfig(controllerName);
+ } catch (ServiceException e) {
+ ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
+ throw e;
+ }