2  * ============LICENSE_START=======================================================
 
   3  * DCAEGEN2-SERVICES-SDK
 
   4  * ================================================================================
 
   5  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  22 package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers;
 
  24 import com.google.gson.JsonObject;
 
  25 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
 
  26 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableEnvProperties;
 
  27 import reactor.core.publisher.Mono;
 
  30  * Complete CloudConfiguration HTTPClient API.
 
  32  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 11/16/18
 
  36 public final class CloudConfigurationClient implements CloudConfigurationProvider {
 
  38     private final CloudConfigurationProvider cloudConfigurationProvider;
 
  41      * Default constructor for CloudConfigurationClient, set CloudConfigurationProvider cloudConfigurationProvider
 
  42      * property by calling: {@link ReactiveCloudConfigurationProvider}.
 
  43      * Calls other constructor in this class {@link #CloudConfigurationClient(CloudConfigurationProvider)}.
 
  45     public CloudConfigurationClient() {
 
  46         this(new ReactiveCloudConfigurationProvider());
 
  50      * Constructor for CloudConfigurationClient, set loudConfigurationProvider cloudConfigurationProvider property
 
  51      * by passing them in constructor {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}
 
  52      * implementation client.
 
  54      * @param cloudConfigurationProvider - client provider for calling ConfigBindingService
 
  56     public CloudConfigurationClient(
 
  57         CloudConfigurationProvider cloudConfigurationProvider) {
 
  58         this.cloudConfigurationProvider = cloudConfigurationProvider;
 
  62      * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}
 
  64      * @param consulHost - Hostname/IPAddress of consul Database
 
  65      * @param consulPort - Port number of consul Database
 
  66      * @param cbsName - ConfigBindingService url
 
  67      * @param appName - ApplicationName for each config will be returned
 
  70     public Mono<JsonObject> callForServiceConfigurationReactive(String consulHost, int consulPort, String cbsName,
 
  72         return cloudConfigurationProvider.callForServiceConfigurationReactive(
 
  73             ImmutableEnvProperties.builder().consulHost(consulHost)
 
  74                 .consulPort(consulPort).cbsName(cbsName)
 
  75                 .appName(appName).build());
 
  79      * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}.
 
  81      * @param envProperties - Object holds consulPort, consulURL, configBindingSeriveName, applicationName which have
 
  82      * been defined in dcaegen2 cloud environment.
 
  85     public Mono<JsonObject> callForServiceConfigurationReactive(EnvProperties envProperties) {
 
  86         return cloudConfigurationProvider.callForServiceConfigurationReactive(envProperties);
 
  90      * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}.
 
  92      * @param consulHost - Hostname/IPAddress of consul Database
 
  93      * @param consulPort - Port number of consul Database
 
  94      * @param cbsName - ConfigBindingService url
 
  95      * @param appName - ApplicationName for each config will be returned
 
  98     public JsonObject callForServiceConfiguration(String consulHost, int consulPort, String cbsName, String appName) {
 
  99         return cloudConfigurationProvider.callForServiceConfigurationReactive(
 
 100             ImmutableEnvProperties.builder().consulHost(consulHost)
 
 101                 .consulPort(consulPort).cbsName(cbsName)
 
 102                 .appName(appName).build()).block();
 
 106      * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}.
 
 108      * @param envProperties - Object holds consulPort, consulURL, configBindingSeriveName, applicationName which have
 
 111     public JsonObject callForServiceConfiguration(EnvProperties envProperties) {
 
 112         return cloudConfigurationProvider.callForServiceConfigurationReactive(envProperties).block();