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.api;
23 import org.jetbrains.annotations.NotNull;
24 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest;
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.ImmutableCbsRequest;
27 import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
30 * A factory to various of requests supported by Config Binding Service.
32 * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
35 public final class CbsRequests {
38 * <p>A get-configuration request.</p>
40 * <p>Will bind the configuration for given service and return the bound configuration.</p>
42 * @param diagnosticContext logging diagnostic context (MDC)
43 * @return the CbsRequest ready to be used when calling {@link CbsClient}
45 public static @NotNull CbsRequest getConfiguration(RequestDiagnosticContext diagnosticContext) {
46 return ImmutableCbsRequest.builder()
47 .diagnosticContext(diagnosticContext)
48 .requestPath(serviceName -> "/service_component/" + serviceName)
53 * <p>A get-by-key request.</p>
55 * <p>This will call an endpoint that fetches a generic service_component_name:key out of Consul</p>
57 * @param diagnosticContext logging diagnostic context (MDC)
58 * @return the CbsRequest ready to be used when calling {@link CbsClient}
60 public static @NotNull CbsRequest getByKey(
61 RequestDiagnosticContext diagnosticContext,
63 return ImmutableCbsRequest.builder()
64 .diagnosticContext(diagnosticContext)
65 .requestPath(serviceName -> "/" + key + "/" + serviceName)
70 * <p>A get-all request.</p>
72 * <p>Will bind the configuration for given service and return the bound configuration, policies, and any other
73 * keys that are in Consul</p>
75 * @param diagnosticContext logging diagnostic context (MDC)
76 * @return the CbsRequest ready to be used when calling {@link CbsClient}
78 public static @NotNull CbsRequest getAll(RequestDiagnosticContext diagnosticContext) {
79 return ImmutableCbsRequest.builder()
80 .diagnosticContext(diagnosticContext)
81 .requestPath(serviceName -> "/service_component_all/" + serviceName)