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.http.configuration.EnvProperties;
26 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.http.configuration.ImmutableEnvProperties;
27 import org.springframework.stereotype.Service;
28 import reactor.core.publisher.Mono;
31 * Complete CloudConfiguration HTTPClient API.
33 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 11/16/18
38 public final class CloudConfigurationClient implements CloudConfigurationProvider {
40 private final CloudConfigurationProvider cloudConfigurationProvider;
43 * Default constructor for CloudConfigurationClient, set CloudConfigurationProvider cloudConfigurationProvider
44 * property by calling: {@link ReactiveCloudConfigurationProvider}.
45 * Calls other constructor in this class {@link #CloudConfigurationClient(CloudConfigurationProvider)}.
47 public CloudConfigurationClient() {
48 this(new ReactiveCloudConfigurationProvider());
52 * Constructor for CloudConfigurationClient, set loudConfigurationProvider cloudConfigurationProvider property
53 * by passing them in constructor {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}
54 * implementation client.
56 * @param cloudConfigurationProvider - client provider for calling ConfigBindingService
58 public CloudConfigurationClient(
59 CloudConfigurationProvider cloudConfigurationProvider) {
60 this.cloudConfigurationProvider = cloudConfigurationProvider;
64 * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}
66 * @param consulHost - Hostname/IPAddress of consul Database
67 * @param consulPort - Port number of consul Database
68 * @param cbsName - ConfigBindingService url
69 * @param appName - ApplicationName for each config will be returned
72 public Mono<JsonObject> callForServiceConfigurationReactive(String consulHost, int consulPort, String cbsName,
74 return cloudConfigurationProvider.callForServiceConfigurationReactive(
75 ImmutableEnvProperties.builder().consulHost(consulHost)
76 .consulPort(consulPort).cbsName(cbsName)
77 .appName(appName).build());
81 * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}.
83 * @param envProperties - Object holds consulPort, consulURL, configBindingSeriveName, applicationName which have
84 * been defined in dcaegen2 cloud environment.
87 public Mono<JsonObject> callForServiceConfigurationReactive(EnvProperties envProperties) {
88 return cloudConfigurationProvider.callForServiceConfigurationReactive(envProperties);
92 * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}.
94 * @param consulHost - Hostname/IPAddress of consul Database
95 * @param consulPort - Port number of consul Database
96 * @param cbsName - ConfigBindingService url
97 * @param appName - ApplicationName for each config will be returned
100 public JsonObject callForServiceConfiguration(String consulHost, int consulPort, String cbsName, String appName) {
101 return cloudConfigurationProvider.callForServiceConfigurationReactive(
102 ImmutableEnvProperties.builder().consulHost(consulHost)
103 .consulPort(consulPort).cbsName(cbsName)
104 .appName(appName).build()).block();
108 * Documentation in {@link org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationProvider}.
110 * @param envProperties - Object holds consulPort, consulURL, configBindingSeriveName, applicationName which have
113 public JsonObject callForServiceConfiguration(EnvProperties envProperties) {
114 return cloudConfigurationProvider.callForServiceConfigurationReactive(envProperties).block();