2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T 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=========================================================
21 package org.openecomp.sdc.common.http.config;
23 import org.openecomp.sdc.common.http.client.api.ComparableHttpRequestRetryHandler;
27 public class HttpClientConfig {
29 private BasicAuthorization basicAuthorization;
30 private ClientCertificate clientCertificate;
31 private ComparableHttpRequestRetryHandler retryHandler;
32 private Timeouts timeouts = Timeouts.DEFAULT;
33 private Map<String, String> headers;
34 private int numOfRetries;
36 public HttpClientConfig() {
39 public HttpClientConfig(Timeouts timeouts) {
40 setTimeouts(timeouts);
43 public HttpClientConfig(Timeouts timeouts, ClientCertificate clientCertificate) {
44 setTimeouts(timeouts);
45 setClientCertificate(clientCertificate);
48 public HttpClientConfig(Timeouts timeouts, BasicAuthorization basicAuthorization) {
49 setTimeouts(timeouts);
50 setBasicAuthorization(basicAuthorization);
53 public ComparableHttpRequestRetryHandler getRetryHandler() {
57 public void setRetryHandler(ComparableHttpRequestRetryHandler retryHandler) {
58 this.retryHandler = retryHandler;
61 public Timeouts getTimeouts() {
65 public void setTimeouts(Timeouts timeouts) {
66 this.timeouts = timeouts;
69 public BasicAuthorization getBasicAuthorization() {
70 return basicAuthorization;
73 public void setBasicAuthorization(BasicAuthorization basicAuthorization) {
74 this.basicAuthorization = basicAuthorization;
77 public ClientCertificate getClientCertificate() {
78 return clientCertificate;
81 public void setClientCertificate(ClientCertificate clientCertificate) {
82 this.clientCertificate = clientCertificate;
85 public Map<String, String> getHeaders() {
89 public void setHeaders(Map<String, String> headers) {
90 this.headers = headers;
93 public int getNumOfRetries() {
97 public void setNumOfRetries(int numOfRetries) {
98 this.numOfRetries = numOfRetries;
102 public String toString() {
103 StringBuilder builder = new StringBuilder();
104 builder.append("HttpClientConfig [basicAuthorization=");
105 builder.append(basicAuthorization);
106 builder.append(", clientCertificate=");
107 builder.append(clientCertificate);
108 builder.append(", retryHandler=");
109 builder.append(retryHandler);
110 builder.append(", timeouts=");
111 builder.append(timeouts);
112 builder.append(", headers=");
113 builder.append(headers);
114 builder.append(", numOfRetries=");
115 builder.append(numOfRetries);
117 return builder.toString();