2 * ============LICENSE_START====================================
3 * DCAEGEN2-SERVICES-SDK
4 * =========================================================
5 * Copyright (C) 2019 Nokia. 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=====================================
21 package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model;
23 import org.immutables.value.Value;
24 import org.jetbrains.annotations.Nullable;
27 * Immutable object which helps with construction of cloudRequestObject for specified Client. For usage take a look in
28 * CloudConfigurationClient.class
30 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 11/16/18
31 * @version 1.0.0 can be passed to ReactiveCloudConfigurationProvider, can be constructed out of
32 * org.onap.dcaegen2.services.sdk library.
35 @Value.Immutable(prehash = true)
36 public interface CbsClientConfiguration {
39 * Name of environment variable containing Config Binding Service network hostname.
41 String ENV_CBS_HOSTNAME = "CONFIG_BINDING_SERVICE";
44 * Name of environment variable containing Config Binding Service network port.
46 String ENV_CBS_PORT = "CONFIG_BINDING_SERVICE_SERVICE_PORT";
49 * Name of environment variable containing current application name.
51 String ENV_APP_NAME = "HOSTNAME";
54 * Name of environment variable containing Consul host name.
56 * @deprecated CBS lookup in Consul service should not be needed,
57 * instead {@link #ENV_CBS_HOSTNAME} should be used directly.
60 String ENV_CONSUL_HOST = "CONSUL_HOST";
63 * Name of environment variable containing Config Binding Service <em>service name</em> as registered in Consul
66 * @deprecated CBS lookup in Consul service should not be needed,
67 * instead {@link #ENV_CBS_HOSTNAME} should be used directly.
70 String ENV_CBS_NAME = "CONFIG_BINDING_SERVICE";
85 default String consulHost() {
86 return "consul-server";
91 default Integer consulPort() {
97 default String cbsName() {
98 return "config-binding-service";
102 * Creates CbsClientConfiguration from system environment variables.
104 * @return an instance of CbsClientConfiguration
105 * @throws NullPointerException when at least one of required parameters is missing
107 static CbsClientConfiguration fromEnvironment() {
108 return ImmutableCbsClientConfiguration.builder()
109 .consulHost(System.getenv(ENV_CONSUL_HOST))
110 .hostname(System.getenv(ENV_CBS_HOSTNAME))
111 .port(Integer.valueOf(System.getenv(ENV_CBS_PORT)))
112 .appName(System.getenv(ENV_APP_NAME))