001/*
002 * Copyright 2012-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure.elasticsearch.jest;
018
019import java.time.Duration;
020import java.util.ArrayList;
021import java.util.Collections;
022import java.util.List;
023
024import org.springframework.boot.context.properties.ConfigurationProperties;
025
026/**
027 * Configuration properties for Jest.
028 *
029 * @author Stephane Nicoll
030 * @since 1.4.0
031 */
032@ConfigurationProperties(prefix = "spring.elasticsearch.jest")
033public class JestProperties {
034
035        /**
036         * Comma-separated list of the Elasticsearch instances to use.
037         */
038        private List<String> uris = new ArrayList<>(
039                        Collections.singletonList("http://localhost:9200"));
040
041        /**
042         * Login username.
043         */
044        private String username;
045
046        /**
047         * Login password.
048         */
049        private String password;
050
051        /**
052         * Whether to enable connection requests from multiple execution threads.
053         */
054        private boolean multiThreaded = true;
055
056        /**
057         * Connection timeout.
058         */
059        private Duration connectionTimeout = Duration.ofSeconds(3);
060
061        /**
062         * Read timeout.
063         */
064        private Duration readTimeout = Duration.ofSeconds(3);
065
066        /**
067         * Proxy settings.
068         */
069        private final Proxy proxy = new Proxy();
070
071        public List<String> getUris() {
072                return this.uris;
073        }
074
075        public void setUris(List<String> uris) {
076                this.uris = uris;
077        }
078
079        public String getUsername() {
080                return this.username;
081        }
082
083        public void setUsername(String username) {
084                this.username = username;
085        }
086
087        public String getPassword() {
088                return this.password;
089        }
090
091        public void setPassword(String password) {
092                this.password = password;
093        }
094
095        public boolean isMultiThreaded() {
096                return this.multiThreaded;
097        }
098
099        public void setMultiThreaded(boolean multiThreaded) {
100                this.multiThreaded = multiThreaded;
101        }
102
103        public Duration getConnectionTimeout() {
104                return this.connectionTimeout;
105        }
106
107        public void setConnectionTimeout(Duration connectionTimeout) {
108                this.connectionTimeout = connectionTimeout;
109        }
110
111        public Duration getReadTimeout() {
112                return this.readTimeout;
113        }
114
115        public void setReadTimeout(Duration readTimeout) {
116                this.readTimeout = readTimeout;
117        }
118
119        public Proxy getProxy() {
120                return this.proxy;
121        }
122
123        public static class Proxy {
124
125                /**
126                 * Proxy host the HTTP client should use.
127                 */
128                private String host;
129
130                /**
131                 * Proxy port the HTTP client should use.
132                 */
133                private Integer port;
134
135                public String getHost() {
136                        return this.host;
137                }
138
139                public void setHost(String host) {
140                        this.host = host;
141                }
142
143                public Integer getPort() {
144                        return this.port;
145                }
146
147                public void setPort(Integer port) {
148                        this.port = port;
149                }
150
151        }
152
153}