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
031    @Metadata(defaultValue = "environment", enums = "environment,dns,client")
032    private String lookup = "environment";
033    @XmlAttribute
034    @Metadata(label = "dns,dnssrv")
035    private String dnsDomain;
036    @XmlAttribute
037    @Metadata(label = "dns,dnssrv")
038    private String portName;
039    @XmlAttribute
040    @Metadata(label = "dns,dnssrv")
041    private String portProtocol = "tcp";
042    @XmlAttribute
043    private String namespace;
044    @XmlAttribute
045    private String apiVersion;
046    @XmlAttribute
047    @Metadata(label = "client")
048    private String masterUrl;
049    @XmlAttribute
050    @Metadata(label = "client")
051    private String username;
052    @XmlAttribute
053    @Metadata(label = "client")
054    private String password;
055    @XmlAttribute
056    @Metadata(label = "client")
057    private String oauthToken;
058    @XmlAttribute
059    @Metadata(label = "client")
060    private String caCertData;
061    @XmlAttribute
062    @Metadata(label = "client")
063    private String caCertFile;
064    @XmlAttribute
065    @Metadata(label = "client")
066    private String clientCertData;
067    @XmlAttribute
068    @Metadata(label = "client")
069    private String clientCertFile;
070    @XmlAttribute
071    @Metadata(label = "client")
072    private String clientKeyAlgo;
073    @XmlAttribute
074    @Metadata(label = "client")
075    private String clientKeyData;
076    @XmlAttribute
077    @Metadata(label = "client")
078    private String clientKeyFile;
079    @XmlAttribute
080    @Metadata(label = "client")
081    private String clientKeyPassphrase;
082    @XmlAttribute
083    @Metadata(label = "client")
084    private Boolean trustCerts;
085
086    public KubernetesServiceCallServiceDiscoveryConfiguration() {
087        this(null);
088    }
089
090    public KubernetesServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) {
091        super(parent, "kubernetes-service-discovery");
092    }
093
094    // *************************************************************************
095    // Properties
096    // *************************************************************************
097
098    public String getMasterUrl() {
099        return masterUrl;
100    }
101
102    /**
103     * Sets the URL to the master when using client lookup
104     */
105    public void setMasterUrl(String masterUrl) {
106        this.masterUrl = masterUrl;
107    }
108
109    public String getNamespace() {
110        return namespace;
111    }
112
113    /**
114     * Sets the namespace to use. Will by default use namespace from the ENV
115     * variable KUBERNETES_MASTER.
116     */
117    public void setNamespace(String namespace) {
118        this.namespace = namespace;
119    }
120
121    public String getApiVersion() {
122        return apiVersion;
123    }
124
125    /**
126     * Sets the API version when using client lookup
127     */
128    public void setApiVersion(String apiVersion) {
129        this.apiVersion = apiVersion;
130    }
131
132    public String getLookup() {
133        return lookup;
134    }
135
136    /**
137     * How to perform service lookup. Possible values: client, dns, environment.
138     * <p/>
139     * When using client, then the client queries the kubernetes master to
140     * obtain a list of active pods that provides the service, and then random
141     * (or round robin) select a pod.
142     * <p/>
143     * When using dns the service name is resolved as
144     * <tt>name.namespace.svc.dnsDomain</tt>.
145     * <p/>
146     * When using dnssrv the service name is resolved with SRV query for
147     * <tt>_<port_name>._<port_proto>.<serviceName>.<namespace>.svc.<zone>.</tt>.
148     * <p/>
149     * When using environment then environment variables are used to lookup the
150     * service.
151     * <p/>
152     * By default environment is used.
153     */
154    public void setLookup(String lookup) {
155        this.lookup = lookup;
156    }
157
158    public String getDnsDomain() {
159        return dnsDomain;
160    }
161
162    /**
163     * Sets the DNS domain to use for DNS lookup.
164     */
165    public void setDnsDomain(String dnsDomain) {
166        this.dnsDomain = dnsDomain;
167    }
168
169    public String getPortName() {
170        return portName;
171    }
172
173    /**
174     * Sets the Port Name to use for DNS/DNSSRV lookup.
175     */
176    public void setPortName(String portName) {
177        this.portName = portName;
178    }
179
180    public String getPortProtocol() {
181        return portProtocol;
182    }
183
184    /**
185     * Sets the Port Protocol to use for DNS/DNSSRV lookup.
186     */
187    public void setPortProtocol(String portProtocol) {
188        this.portProtocol = portProtocol;
189    }
190
191    public String getUsername() {
192        return username;
193    }
194
195    /**
196     * Sets the username for authentication when using client lookup
197     */
198    public void setUsername(String username) {
199        this.username = username;
200    }
201
202    public String getPassword() {
203        return password;
204    }
205
206    /**
207     * Sets the password for authentication when using client lookup
208     */
209    public void setPassword(String password) {
210        this.password = password;
211    }
212
213    public String getOauthToken() {
214        return oauthToken;
215    }
216
217    /**
218     * Sets the OAUTH token for authentication (instead of username/password)
219     * when using client lookup
220     */
221    public void setOauthToken(String oauthToken) {
222        this.oauthToken = oauthToken;
223    }
224
225    public String getCaCertData() {
226        return caCertData;
227    }
228
229    /**
230     * Sets the Certificate Authority data when using client lookup
231     */
232    public void setCaCertData(String caCertData) {
233        this.caCertData = caCertData;
234    }
235
236    public String getCaCertFile() {
237        return caCertFile;
238    }
239
240    /**
241     * Sets the Certificate Authority data that are loaded from the file when
242     * using client lookup
243     */
244    public void setCaCertFile(String caCertFile) {
245        this.caCertFile = caCertFile;
246    }
247
248    public String getClientCertData() {
249        return clientCertData;
250    }
251
252    /**
253     * Sets the Client Certificate data when using client lookup
254     */
255    public void setClientCertData(String clientCertData) {
256        this.clientCertData = clientCertData;
257    }
258
259    public String getClientCertFile() {
260        return clientCertFile;
261    }
262
263    /**
264     * Sets the Client Certificate data that are loaded from the file when using
265     * client lookup
266     */
267    public void setClientCertFile(String clientCertFile) {
268        this.clientCertFile = clientCertFile;
269    }
270
271    public String getClientKeyAlgo() {
272        return clientKeyAlgo;
273    }
274
275    /**
276     * Sets the Client Keystore algorithm, such as RSA when using client lookup
277     */
278    public void setClientKeyAlgo(String clientKeyAlgo) {
279        this.clientKeyAlgo = clientKeyAlgo;
280    }
281
282    public String getClientKeyData() {
283        return clientKeyData;
284    }
285
286    /**
287     * Sets the Client Keystore data when using client lookup
288     */
289    public void setClientKeyData(String clientKeyData) {
290        this.clientKeyData = clientKeyData;
291    }
292
293    public String getClientKeyFile() {
294        return clientKeyFile;
295    }
296
297    /**
298     * Sets the Client Keystore data that are loaded from the file when using
299     * client lookup
300     */
301    public void setClientKeyFile(String clientKeyFile) {
302        this.clientKeyFile = clientKeyFile;
303    }
304
305    public String getClientKeyPassphrase() {
306        return clientKeyPassphrase;
307    }
308
309    /**
310     * Sets the Client Keystore passphrase when using client lookup
311     */
312    public void setClientKeyPassphrase(String clientKeyPassphrase) {
313        this.clientKeyPassphrase = clientKeyPassphrase;
314    }
315
316    public Boolean getTrustCerts() {
317        return trustCerts;
318    }
319
320    /**
321     * Sets whether to turn on trust certificate check when using client lookup
322     */
323    public void setTrustCerts(Boolean trustCerts) {
324        this.trustCerts = trustCerts;
325    }
326
327    // *************************************************************************
328    // Fluent API
329    // *************************************************************************
330
331    /**
332     * Sets the URL to the master when using client lookup
333     */
334    public KubernetesServiceCallServiceDiscoveryConfiguration masterUrl(String masterUrl) {
335        setMasterUrl(masterUrl);
336        return this;
337    }
338
339    /**
340     * Sets the namespace to use. Will by default use namespace from the ENV
341     * variable KUBERNETES_MASTER.
342     */
343    public KubernetesServiceCallServiceDiscoveryConfiguration namespace(String namespace) {
344        setNamespace(namespace);
345        return this;
346    }
347
348    /**
349     * Sets the API version when using client lookup
350     */
351    public KubernetesServiceCallServiceDiscoveryConfiguration apiVersion(String apiVersion) {
352        setApiVersion(apiVersion);
353        return this;
354    }
355
356    /**
357     * How to perform service lookup, @see {@link #setLookup(String)}.
358     */
359    public KubernetesServiceCallServiceDiscoveryConfiguration lookup(String lookup) {
360        setLookup(lookup);
361        return this;
362    }
363
364    /**
365     * Sets the DNS domain to use for DNS/SNDSRV lookup.
366     */
367    public KubernetesServiceCallServiceDiscoveryConfiguration dnsDomain(String dnsDomain) {
368        setDnsDomain(dnsDomain);
369        return this;
370    }
371
372    /**
373     * Sets Port Name to use for DNS/SNDSRV lookup.
374     */
375    public KubernetesServiceCallServiceDiscoveryConfiguration portName(String portName) {
376        setPortName(portName);
377        return this;
378    }
379
380    /**
381     * Sets Port Protocol to use for DNS/SNDSRV lookup.
382     */
383    public KubernetesServiceCallServiceDiscoveryConfiguration portProtocol(String portProtocol) {
384        setPortProtocol(portProtocol);
385        return this;
386    }
387
388    /**
389     * Sets the username for authentication when using client lookup
390     */
391    public KubernetesServiceCallServiceDiscoveryConfiguration username(String username) {
392        setUsername(username);
393        return this;
394    }
395
396    /**
397     * Sets the password for authentication when using client lookup
398     */
399    public KubernetesServiceCallServiceDiscoveryConfiguration password(String password) {
400        setPassword(password);
401        return this;
402    }
403
404    /**
405     * Sets the OAUTH token for authentication (instead of username/password)
406     * when using client lookup
407     */
408    public KubernetesServiceCallServiceDiscoveryConfiguration oauthToken(String oauthToken) {
409        setOauthToken(oauthToken);
410        return this;
411    }
412
413    /**
414     * Sets the Certificate Authority data when using client lookup
415     */
416    public KubernetesServiceCallServiceDiscoveryConfiguration caCertData(String caCertData) {
417        setCaCertData(caCertData);
418        return this;
419    }
420
421    /**
422     * Sets the Certificate Authority data that are loaded from the file when
423     * using client lookup
424     */
425    public KubernetesServiceCallServiceDiscoveryConfiguration caCertFile(String caCertFile) {
426        setCaCertFile(caCertFile);
427        return this;
428    }
429
430    /**
431     * Sets the Client Certificate data when using client lookup
432     */
433    public KubernetesServiceCallServiceDiscoveryConfiguration clientCertData(String clientCertData) {
434        setClientCertData(clientCertData);
435        return this;
436    }
437
438    /**
439     * Sets the Client Certificate data that are loaded from the file when using
440     * client lookup
441     */
442    public KubernetesServiceCallServiceDiscoveryConfiguration clientCertFile(String clientCertFile) {
443        setClientCertFile(clientCertFile);
444        return this;
445    }
446
447    /**
448     * Sets the Client Keystore algorithm, such as RSA when using client lookup
449     */
450    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyAlgo(String clientKeyAlgo) {
451        setClientKeyAlgo(clientKeyAlgo);
452        return this;
453    }
454
455    /**
456     * Sets the Client Keystore data when using client lookup
457     */
458    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyData(String clientKeyData) {
459        setClientKeyData(clientKeyData);
460        return this;
461    }
462
463    /**
464     * Sets the Client Keystore data that are loaded from the file when using
465     * client lookup
466     */
467    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyFile(String clientKeyFile) {
468        setClientKeyFile(clientKeyFile);
469        return this;
470    }
471
472    /**
473     * Sets the Client Keystore passphrase when using client lookup
474     */
475    public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyPassphrase(String clientKeyPassphrase) {
476        setClientKeyPassphrase(clientKeyPassphrase);
477        return this;
478    }
479
480    /**
481     * Sets whether to turn on trust certificate check when using client lookup
482     */
483    public KubernetesServiceCallServiceDiscoveryConfiguration trustCerts(boolean trustCerts) {
484        setTrustCerts(trustCerts);
485        return this;
486    }
487}