Added oparent to sdc main
[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 org.openecomp.sdc.common.http.client.api.ComparableHttpRequestRetryHandler;
24
25 import java.util.Map;
26
27 public class HttpClientConfig {
28
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;
35
36     public HttpClientConfig() {    
37     }
38     
39     public HttpClientConfig(Timeouts timeouts) {
40         setTimeouts(timeouts);
41     }
42
43     public HttpClientConfig(Timeouts timeouts, ClientCertificate clientCertificate) {
44         setTimeouts(timeouts);
45         setClientCertificate(clientCertificate);
46     }
47
48     public HttpClientConfig(Timeouts timeouts, BasicAuthorization basicAuthorization) {
49         setTimeouts(timeouts);
50         setBasicAuthorization(basicAuthorization);
51     }
52
53     public ComparableHttpRequestRetryHandler getRetryHandler() {
54         return retryHandler;
55     }
56
57     public void setRetryHandler(ComparableHttpRequestRetryHandler retryHandler) {
58         this.retryHandler = retryHandler;
59     }
60
61     public Timeouts getTimeouts() {
62         return timeouts;
63     }
64
65     public void setTimeouts(Timeouts timeouts) {
66         this.timeouts = timeouts;
67     }
68
69     public BasicAuthorization getBasicAuthorization() {
70         return basicAuthorization;
71     }
72
73     public void setBasicAuthorization(BasicAuthorization basicAuthorization) {
74         this.basicAuthorization = basicAuthorization;
75     }
76
77     public ClientCertificate getClientCertificate() {
78         return clientCertificate;
79     }
80
81     public void setClientCertificate(ClientCertificate clientCertificate) {
82         this.clientCertificate = clientCertificate;
83     }
84     
85     public Map<String, String> getHeaders() {
86         return headers;
87     }
88     
89     public void setHeaders(Map<String, String> headers) {
90         this.headers = headers;
91     }
92
93     public int getNumOfRetries() {
94         return numOfRetries;
95     }
96     
97     public void setNumOfRetries(int numOfRetries) {
98         this.numOfRetries = numOfRetries;
99     }
100
101     @Override
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);
116         builder.append("]");
117         return builder.toString();
118     }
119 }