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