001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.model.cloud;
018
019import javax.xml.bind.annotation.XmlAccessType;
020import javax.xml.bind.annotation.XmlAccessorType;
021import javax.xml.bind.annotation.XmlAttribute;
022import javax.xml.bind.annotation.XmlRootElement;
023
024import org.apache.camel.spi.Metadata;
025
026@Metadata(label = "routing,cloud,service-discovery")
027@XmlRootElement(name = "kubernetesServiceDiscovery")
028@XmlAccessorType(XmlAccessType.FIELD)
029public class KubernetesServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration {
030    @XmlAttribute @Metadata(defaultValue = "environment", enums = "environment,dns,client")
031    private String lookup = "environment";
032    @XmlAttribute
033    private String dnsDomain;
034    @XmlAttribute
035    private String namespace;
036    @XmlAttribute
037    private String apiVersion;
038    @XmlAttribute @Metadata(label = "client")
039    private String masterUrl;
040    @XmlAttribute @Metadata(label = "client")
041    private String username;
042    @XmlAttribute @Metadata(label = "client")
043    private String password;
044    @XmlAttribute @Metadata(label = "client")
045    private String oauthToken;
046    @XmlAttribute @Metadata(label = "client")
047    private String caCertData;
048    @XmlAttribute @Metadata(label = "client")
049    private String caCertFile;
050    @XmlAttribute @Metadata(label = "client")
051    private String clientCertData;
052    @XmlAttribute @Metadata(label = "client")
053    private String clientCertFile;
054    @XmlAttribute @Metadata(label = "client")
055    private String clientKeyAlgo;
056    @XmlAttribute @Metadata(label = "client")
057    private String clientKeyData;
058    @XmlAttribute @Metadata(label = "client")
059    private String clientKeyFile;
060    @XmlAttribute @Metadata(label = "client")
061    private String clientKeyPassphrase;
062    @XmlAttribute @Metadata(label = "client")
063    private Boolean trustCerts;
064
065    public KubernetesServiceCallServiceDiscoveryConfiguration() {
066        this(null);
067    }
068
069    public KubernetesServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) {
070        super(parent, "kubernetes-service-discovery");
071    }
072
073    // *************************************************************************
074    // Properties
075    // *************************************************************************
076
077    public String getMasterUrl() {
078        return masterUrl;
079    }
080
081    /**
082     * Sets the URL to the master when using client lookup
083     */
084    public void setMasterUrl(String masterUrl) {
085        this.masterUrl = masterUrl;
086    }
087
088    public String getNamespace() {
089        return namespace;
090    }
091
092    /**
093     * Sets the namespace to use. Will by default use namespace from the ENV variable KUBERNETES_MASTER.
094     */
095    public void setNamespace(String namespace) {
096        this.namespace = namespace;
097    }
098
099    public String getApiVersion() {
100        return apiVersion;
101    }
102
103    /**
104     * Sets the API version when using client lookup
105     */
106    public void setApiVersion(String apiVersion) {
107        this.apiVersion = apiVersion;
108    }
109
110    public String getLookup() {
111        return lookup;
112    }
113
114    /**
115     * How to perform service lookup. Possible values: client, dns, environment.
116     * <p/>
117     * When using client, then the client queries the kubernetes master to obtain a list
118     * of active pods that provides the service, and then random (or round robin) select a pod.
119     * <p/>
120     * When using dns the service name is resolved as <tt>name.namespace.service.dnsDomain</tt>.
121     * <p/>
122     * When using environment then environment variables are used to lookup the service.
123     * <p/>
124     * By default environment is used.
125     */
126    public void setLookup(String lookup) {
127        this.lookup = lookup;
128    }
129
130    public String getDnsDomain() {
131        return dnsDomain;
132    }
133
134    /**
135     * Sets the DNS domain to use for DNS lookup.
136     */
137    public void setDnsDomain(String dnsDomain) {
138        this.dnsDomain = dnsDomain;
139    }
140
141    public String getUsername() {
142        return username;
143    }
144
145    /**
146     * Sets the username for authentication when using client lookup
147     */
148    public void setUsername(String username) {
149        this.username = username;
150    }
151
152    public String getPassword() {
153        return password;
154    }
155
156    /**
157     * Sets the password for authentication when using client lookup
158     */
159    public void setPassword(String password) {
160        this.password = password;
161    }
162
163    public String getOauthToken() {
164        return oauthToken;
165    }
166
167    /**
168     * Sets the OAUTH token for authentication (instead of username/password) when using client lookup
169     */
170    public void setOauthToken(String oauthToken) {
171        this.oauthToken = oauthToken;
172    }
173
174    public String getCaCertData() {
175        return caCertData;
176    }
177
178    /**
179     * Sets the Certificate Authority data when using client lookup
180     */
181    public void setCaCertData(String caCertData) {
182        this.caCertData = caCertData;
183    }
184
185    public String getCaCertFile() {
186        return caCertFile;
187    }
188
189    /**
190     * Sets the Certificate Authority data that are loaded from the file when using client lookup
191     */
192    public void setCaCertFile(String caCertFile) {
193        this.caCertFile = caCertFile;
194    }
195
196    public String getClientCertData() {
197        return clientCertData;
198    }
199
200    /**
201     * Sets the Client Certificate data when using client lookup
202     */
203    public void setClientCertData(String clientCertData) {
204        this.clientCertData = clientCertData;
205    }
206
207    public String getClientCertFile() {
208        return clientCertFile;
209    }
210
211    /**
212     * Sets the Client Certificate data that are loaded from the file when using client lookup
213     */
214    public void setClientCertFile(String clientCertFile) {
215        this.clientCertFile = clientCertFile;
216    }
217
218    public String getClientKeyAlgo() {
219        return clientKeyAlgo;
220    }
221
222    /**
223     * Sets the Client Keystore algorithm, such as RSA when using client lookup
224     */
225    public void setClientKeyAlgo(String clientKeyAlgo) {
226        this.clientKeyAlgo = clientKeyAlgo;
227    }
228
229    public String getClientKeyData() {
230        return clientKeyData;
231    }
232
233    /**
234     * Sets the Client Keystore data when using client lookup
235     */
236    public void setClientKeyData(String clientKeyData) {
237        this.clientKeyData = clientKeyData;
238    }
239
240    public String getClientKeyFile() {
241        return clientKeyFile;
242    }
243
244    /**
245     * Sets the Client Keystore data that are loaded from the file when using client lookup
246     */
247    public void setClientKeyFile(String clientKeyFile) {
248        this.clientKeyFile = clientKeyFile;
249    }
250
251    public String getClientKeyPassphrase() {
252        return clientKeyPassphrase;
253    }
254
255    /**
256     * Sets the Client Keystore passphrase when using client lookup
257     */
258    public void setClientKeyPassphrase(String clientKeyPassphrase) {
259        this.clientKeyPassphrase = clientKeyPassphrase;
260    }
261
262    public Boolean getTrustCerts() {
263        return trustCerts;
264    }
265
266    /**
267     * Sets whether to turn on trust certificate check when using client lookup
268     */
269    public void setTrustCerts(Boolean trustCerts) {
270        this.trustCerts = trustCerts;
271    }
272
273    // *************************************************************************
274    // Fluent API
275    // *************************************************************************
276
277    /**
278     * Sets the URL to the master when using client lookup
279     */
280    public KubernetesServiceCallServiceDiscoveryConfiguration masterUrl(String masterUrl) {
281        setMasterUrl(masterUrl);
282        return this;
283    }
284
285    /**
286     * Sets the namespace to use. Will by default use namespace from the ENV variable KUBERNETES_MASTER.
287     */
288    public KubernetesServiceCallServiceDiscoveryConfiguration namespace(String namespace) {
289        setNamespace(namespace);
290        return this;
291    }
292
293    /**
294     * Sets the API version when using client lookup
295     */
296    public KubernetesServiceCallServiceDiscoveryConfiguration apiVersion(String apiVersion) {
297        setApiVersion(apiVersion);
298        return this;
299    }
300
301    /**
302     * How to perform service lookup. Possible values: client, dns, environment.
303     * <p/>
304     * When using client, then the client queries the kubernetes master to obtain a list
305     * of active pods that provides the service, and then random (or round robin) select a pod.
306     * <p/>
307     * When using dns the service name is resolved as <tt>name.namespace.service.dnsDomain</tt>.
308     * <p/>
309     * When using environment then environment variables are used to lookup the service.
310     * <p/>
311     * By default environment is used.
312     */
313    public KubernetesServiceCallServiceDiscoveryConfiguration lookup(String lookup) {
314        setLookup(lookup);
315        return this;
316    }
317
318    /**
319     * Sets the DNS domain to use for DNS lookup.
320     */
321    public KubernetesServiceCallServiceDiscoveryConfiguration dnsDomain(String dnsDomain) {
322        setDnsDomain(dnsDomain);
323        return this;
324    }
325
326    /**
327     * Sets the username for authentication when using client lookup
328     */
329    public KubernetesServiceCallServiceDiscoveryConfiguration username(String username) {
330        setUsername(username);
331        return this;
332    }
333
334    /**
335     * Sets the password for authentication when using client lookup
336     */
337    public KubernetesServiceCallServiceDiscoveryConfiguration password(String password) {
338        setPassword(password);
339        return this;
340    }
341
342    /**
343     * Sets the OAUTH token for authentication (instead of username/password) when using client lookup
344     */
345    public KubernetesServiceCallServiceDiscoveryConfiguration oauthToken(String oauthToken) {
346        setOauthToken(oauthToken);
347        return this;
348    }
349
350    /**
351     * Sets the Certificate Authority data when using client lookup
352     */
353    public KubernetesServiceCallServiceDiscoveryConfiguration caCertData(String caCertData) {
354        setCaCertData(caCertData);
355        return this;
356    }
357
358    /**
359     * Sets the Certificate Authority data that are loaded from the file when using client lookup
360     */
361    public KubernetesServiceCallServiceDiscoveryConfiguration caCertFile(String caCertFile) {
362        setCaCertFile(caCertFile);
363        return this;
364    }
365
366    /**
367     * Sets the Client Certificate data when using client lookup
368     */
369    public KubernetesServiceCallServiceDiscoveryConfiguration clientCertData(String clientCertData) {
370        setClientCertData(clientCertData);
371        return this;
372    }
373
374    /**
375     * Sets the Client Certificate data that are loaded from the file when using client lookup
376     */
377    public KubernetesServiceCallServiceDiscoveryConfiguration clientCertFile(String clientCertFile) {
378        setClientCertFile(clientCertFile);
379        return this;
380    }
381
382    /**
383     * Sets the Client Keystore algorithm, such as RSA when using client lookup
384     */
385    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyAlgo(String clientKeyAlgo) {
386        setClientKeyAlgo(clientKeyAlgo);
387        return this;
388    }
389
390    /**
391     * Sets the Client Keystore data when using client lookup
392     */
393    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyData(String clientKeyData) {
394        setClientKeyData(clientKeyData);
395        return this;
396    }
397
398    /**
399     * Sets the Client Keystore data that are loaded from the file when using client lookup
400     */
401    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyFile(String clientKeyFile) {
402        setClientKeyFile(clientKeyFile);
403        return this;
404    }
405
406    /**
407     * Sets the Client Keystore passphrase when using client lookup
408     */
409    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyPassphrase(String clientKeyPassphrase) {
410        setClientKeyPassphrase(clientKeyPassphrase);
411        return this;
412    }
413
414    /**
415     * Sets whether to turn on trust certificate check when using client lookup
416     */
417    public KubernetesServiceCallServiceDiscoveryConfiguration trustCerts(boolean trustCerts) {
418        setTrustCerts(trustCerts);
419        return this;
420    }
421}