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.remote;
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/**
027 * Kubernetes remote service call configuration
028 */
029@Metadata(label = "eip,routing,remote")
030@XmlRootElement(name = "kubernetesConfiguration")
031@XmlAccessorType(XmlAccessType.FIELD)
032public class KubernetesConfigurationDefinition extends ServiceCallConfigurationDefinition {
033
034    @XmlAttribute @Metadata(defaultValue = "environment")
035    private String lookup;
036    @XmlAttribute
037    private String dnsDomain;
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 KubernetesConfigurationDefinition() {
070    }
071
072    public KubernetesConfigurationDefinition(ServiceCallDefinition parent) {
073        super(parent);
074    }
075
076    // Getter/Setter
077    // -------------------------------------------------------------------------
078
079
080    public String getMasterUrl() {
081        return masterUrl;
082    }
083
084    public void setMasterUrl(String masterUrl) {
085        this.masterUrl = masterUrl;
086    }
087
088    public String getNamespace() {
089        return namespace;
090    }
091
092    public void setNamespace(String namespace) {
093        this.namespace = namespace;
094    }
095
096    public String getApiVersion() {
097        return apiVersion;
098    }
099
100    public void setApiVersion(String apiVersion) {
101        this.apiVersion = apiVersion;
102    }
103
104    public String getLookup() {
105        return lookup;
106    }
107
108    public void setLookup(String lookup) {
109        this.lookup = lookup;
110    }
111
112    public String getDnsDomain() {
113        return dnsDomain;
114    }
115
116    public void setDnsDomain(String dnsDomain) {
117        this.dnsDomain = dnsDomain;
118    }
119
120    public String getUsername() {
121        return username;
122    }
123
124    public void setUsername(String username) {
125        this.username = username;
126    }
127
128    public String getPassword() {
129        return password;
130    }
131
132    public void setPassword(String password) {
133        this.password = password;
134    }
135
136    public String getOauthToken() {
137        return oauthToken;
138    }
139
140    public void setOauthToken(String oauthToken) {
141        this.oauthToken = oauthToken;
142    }
143
144    public String getCaCertData() {
145        return caCertData;
146    }
147
148    public void setCaCertData(String caCertData) {
149        this.caCertData = caCertData;
150    }
151
152    public String getCaCertFile() {
153        return caCertFile;
154    }
155
156    public void setCaCertFile(String caCertFile) {
157        this.caCertFile = caCertFile;
158    }
159
160    public String getClientCertData() {
161        return clientCertData;
162    }
163
164    public void setClientCertData(String clientCertData) {
165        this.clientCertData = clientCertData;
166    }
167
168    public String getClientCertFile() {
169        return clientCertFile;
170    }
171
172    public void setClientCertFile(String clientCertFile) {
173        this.clientCertFile = clientCertFile;
174    }
175
176    public String getClientKeyAlgo() {
177        return clientKeyAlgo;
178    }
179
180    public void setClientKeyAlgo(String clientKeyAlgo) {
181        this.clientKeyAlgo = clientKeyAlgo;
182    }
183
184    public String getClientKeyData() {
185        return clientKeyData;
186    }
187
188    public void setClientKeyData(String clientKeyData) {
189        this.clientKeyData = clientKeyData;
190    }
191
192    public String getClientKeyFile() {
193        return clientKeyFile;
194    }
195
196    public void setClientKeyFile(String clientKeyFile) {
197        this.clientKeyFile = clientKeyFile;
198    }
199
200    public String getClientKeyPassphrase() {
201        return clientKeyPassphrase;
202    }
203
204    public void setClientKeyPassphrase(String clientKeyPassphrase) {
205        this.clientKeyPassphrase = clientKeyPassphrase;
206    }
207
208    public Boolean getTrustCerts() {
209        return trustCerts;
210    }
211
212    public void setTrustCerts(Boolean trustCerts) {
213        this.trustCerts = trustCerts;
214    }
215
216    // Fluent API
217    // -------------------------------------------------------------------------
218
219    /**
220     * Sets the URL to the master when using client lookup
221     */
222    public KubernetesConfigurationDefinition masterUrl(String masterUrl) {
223        setMasterUrl(masterUrl);
224        return this;
225    }
226
227    /**
228     * Sets the namespace to use. Will by default use namespace from the ENV variable KUBERNETES_MASTER.
229     */
230    public KubernetesConfigurationDefinition namespace(String namespace) {
231        setNamespace(namespace);
232        return this;
233    }
234
235    /**
236     * Sets the API version when using client lookup
237     */
238    public KubernetesConfigurationDefinition apiVersion(String apiVersion) {
239        setApiVersion(apiVersion);
240        return this;
241    }
242
243    /**
244     * How to perform service lookup. Possible values: client, dns, environment.
245     * <p/>
246     * When using client, then the client queries the kubernetes master to obtain a list
247     * of active pods that provides the service, and then random (or round robin) select a pod.
248     * <p/>
249     * When using dns the service name is resolved as <tt>name.namespace.service.dnsDomain</tt>.
250     * <p/>
251     * When using environment then environment variables are used to lookup the service.
252     * <p/>
253     * By default environment is used.
254     */
255    public KubernetesConfigurationDefinition lookup(String lookup) {
256        setLookup(lookup);
257        return this;
258    }
259
260    /**
261     * Sets the DNS domain to use for DNS lookup.
262     */
263    public KubernetesConfigurationDefinition dnsDomain(String dnsDomain) {
264        setDnsDomain(dnsDomain);
265        return this;
266    }
267
268    /**
269     * Sets the username for authentication when using client lookup
270     */
271    public KubernetesConfigurationDefinition username(String username) {
272        setUsername(username);
273        return this;
274    }
275
276    /**
277     * Sets the password for authentication when using client lookup
278     */
279    public KubernetesConfigurationDefinition password(String password) {
280        setPassword(password);
281        return this;
282    }
283
284    /**
285     * Sets the OAUTH token for authentication (instead of username/password) when using client lookup
286     */
287    public KubernetesConfigurationDefinition oauthToken(String oauthToken) {
288        setOauthToken(oauthToken);
289        return this;
290    }
291
292    /**
293     * Sets the Certificate Authority data when using client lookup
294     */
295    public KubernetesConfigurationDefinition caCertData(String caCertData) {
296        setCaCertData(caCertData);
297        return this;
298    }
299
300    /**
301     * Sets the Certificate Authority data that are loaded from the file when using client lookup
302     */
303    public KubernetesConfigurationDefinition caCertFile(String caCertFile) {
304        setCaCertFile(caCertFile);
305        return this;
306    }
307
308    /**
309     * Sets the Client Certificate data when using client lookup
310     */
311    public KubernetesConfigurationDefinition clientCertData(String clientCertData) {
312        setClientCertData(clientCertData);
313        return this;
314    }
315
316    /**
317     * Sets the Client Certificate data that are loaded from the file when using client lookup
318     */
319    public KubernetesConfigurationDefinition clientCertFile(String clientCertFile) {
320        setClientCertFile(clientCertFile);
321        return this;
322    }
323
324    /**
325     * Sets the Client Keystore algorithm, such as RSA when using client lookup
326     */
327    public KubernetesConfigurationDefinition clientKeyAlgo(String clientKeyAlgo) {
328        setClientKeyAlgo(clientKeyAlgo);
329        return this;
330    }
331
332    /**
333     * Sets the Client Keystore data when using client lookup
334     */
335    public KubernetesConfigurationDefinition clientKeyData(String clientKeyData) {
336        setClientKeyData(clientKeyData);
337        return this;
338    }
339
340    /**
341     * Sets the Client Keystore data that are loaded from the file when using client lookup
342     */
343    public KubernetesConfigurationDefinition clientKeyFile(String clientKeyFile) {
344        setClientKeyFile(clientKeyFile);
345        return this;
346    }
347
348    /**
349     * Sets the Client Keystore passphrase when using client lookup
350     */
351    public KubernetesConfigurationDefinition clientKeyPassphrase(String clientKeyPassphrase) {
352        setClientKeyPassphrase(clientKeyPassphrase);
353        return this;
354    }
355
356    /**
357     * Sets whether to turn on trust certificate check when using client lookup
358     */
359    public KubernetesConfigurationDefinition trustCerts(boolean trustCerts) {
360        setTrustCerts(trustCerts);
361        return this;
362    }
363
364}