Catalog alignment
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / common / http / config / HttpClientConfig.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.common.http.config;
22
23 import com.fasterxml.jackson.annotation.JsonIgnore;
24 import org.nustaq.serialization.annotations.Serialize;
25 import org.openecomp.sdc.common.http.client.api.ComparableHttpRequestRetryHandler;
26
27 import java.util.Map;
28
29 public class HttpClientConfig {
30
31     private BasicAuthorization basicAuthorization;
32     private ClientCertificate clientCertificate;
33     private ComparableHttpRequestRetryHandler retryHandler;
34     private Timeouts timeouts = Timeouts.DEFAULT;
35     private Map<String, String> headers;
36     private int numOfRetries;
37     @JsonIgnore
38     private boolean enableMetricLogging = false;
39
40     public HttpClientConfig() {    
41     }
42     
43     public HttpClientConfig(Timeouts timeouts) {
44         setTimeouts(timeouts);
45     }
46
47     public HttpClientConfig(Timeouts timeouts, ClientCertificate clientCertificate) {
48         setTimeouts(timeouts);
49         setClientCertificate(clientCertificate);
50     }
51
52     public HttpClientConfig(Timeouts timeouts, BasicAuthorization basicAuthorization) {
53         setTimeouts(timeouts);
54         setBasicAuthorization(basicAuthorization);
55     }
56
57     public ComparableHttpRequestRetryHandler getRetryHandler() {
58         return retryHandler;
59     }
60
61     public void setRetryHandler(ComparableHttpRequestRetryHandler retryHandler) {
62         this.retryHandler = retryHandler;
63     }
64
65     public Timeouts getTimeouts() {
66         return timeouts;
67     }
68
69     public void setTimeouts(Timeouts timeouts) {
70         this.timeouts = timeouts;
71     }
72
73     public BasicAuthorization getBasicAuthorization() {
74         return basicAuthorization;
75     }
76
77     public void setBasicAuthorization(BasicAuthorization basicAuthorization) {
78         this.basicAuthorization = basicAuthorization;
79     }
80
81     public ClientCertificate getClientCertificate() {
82         return clientCertificate;
83     }
84
85     public void setClientCertificate(ClientCertificate clientCertificate) {
86         this.clientCertificate = clientCertificate;
87     }
88     
89     public Map<String, String> getHeaders() {
90         return headers;
91     }
92     
93     public void setHeaders(Map<String, String> headers) {
94         this.headers = headers;
95     }
96
97     public int getNumOfRetries() {
98         return numOfRetries;
99     }
100     
101     public void setNumOfRetries(int numOfRetries) {
102         this.numOfRetries = numOfRetries;
103     }
104
105     public boolean isEnableMetricLogging() {
106         return enableMetricLogging;
107     }
108
109     public void setEnableMetricLogging(boolean enableMetricLogging) {
110         this.enableMetricLogging = enableMetricLogging;
111     }
112
113     @Override
114     public String toString() {
115         StringBuilder builder = new StringBuilder();
116         builder.append("HttpClientConfig [basicAuthorization=");
117         builder.append(basicAuthorization);
118         builder.append(", clientCertificate=");
119         builder.append(clientCertificate);
120         builder.append(", retryHandler=");
121         builder.append(retryHandler);
122         builder.append(", timeouts=");
123         builder.append(timeouts);
124         builder.append(", headers=");
125         builder.append(headers);
126         builder.append(", numOfRetries=");
127         builder.append(numOfRetries);
128         builder.append(", enableMetricLogging=");
129         builder.append(enableMetricLogging);
130         builder.append("]");
131         return builder.toString();
132     }
133 }