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; 023import javax.xml.bind.annotation.XmlTransient; 024 025import org.apache.camel.spi.Metadata; 026import org.apache.camel.support.jsse.SSLContextParameters; 027 028@Metadata(label = "routing,cloud,service-discovery") 029@XmlRootElement(name = "etcdServiceDiscovery") 030@XmlAccessorType(XmlAccessType.FIELD) 031public class EtcdServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration { 032 @XmlAttribute 033 private String uris; 034 @XmlAttribute 035 @Metadata(label = "security") 036 private String userName; 037 @XmlAttribute 038 @Metadata(label = "security") 039 private String password; 040 @XmlAttribute 041 @Metadata(javaType = "java.lang.Long") 042 private String timeout; 043 @XmlAttribute 044 @Metadata(defaultValue = "/services/") 045 private String servicePath = "/services/"; 046 @XmlTransient 047 private SSLContextParameters sslContextParameters; 048 @XmlAttribute 049 @Metadata(defaultValue = "on-demand", enums = "on-demand,watch") 050 private String type = "on-demand"; 051 052 public EtcdServiceCallServiceDiscoveryConfiguration() { 053 this(null); 054 } 055 056 public EtcdServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) { 057 super(parent, "etcd-service-discovery"); 058 } 059 060 // ************************************************************************* 061 // Properties 062 // ************************************************************************* 063 064 public String getUris() { 065 return uris; 066 } 067 068 /** 069 * The URIs the client can connect to. 070 */ 071 public void setUris(String uris) { 072 this.uris = uris; 073 } 074 075 public String getUserName() { 076 return userName; 077 } 078 079 /** 080 * The user name to use for basic authentication. 081 */ 082 public void setUserName(String userName) { 083 this.userName = userName; 084 } 085 086 public String getPassword() { 087 return password; 088 } 089 090 /** 091 * The password to use for basic authentication. 092 */ 093 public void setPassword(String password) { 094 this.password = password; 095 } 096 097 public String getTimeout() { 098 return timeout; 099 } 100 101 /** 102 * To set the maximum time an action could take to complete. 103 */ 104 public void setTimeout(String timeout) { 105 this.timeout = timeout; 106 } 107 108 public String getServicePath() { 109 return servicePath; 110 } 111 112 /** 113 * The path to look for for service discovery 114 */ 115 public void setServicePath(String servicePath) { 116 this.servicePath = servicePath; 117 } 118 119 public SSLContextParameters getSslContextParameters() { 120 return sslContextParameters; 121 } 122 123 /** 124 * To configure security using SSLContextParameters. 125 */ 126 public void setSslContextParameters(SSLContextParameters sslContextParameters) { 127 this.sslContextParameters = sslContextParameters; 128 } 129 130 public String getType() { 131 return type; 132 } 133 134 /** 135 * To set the discovery type, valid values are on-demand and watch. 136 */ 137 public void setType(String type) { 138 this.type = type; 139 } 140 141 // ************************************************************************* 142 // Fluent API 143 // ************************************************************************* 144 145 /** 146 * The URIs the client can connect to. 147 */ 148 public EtcdServiceCallServiceDiscoveryConfiguration uris(String uris) { 149 setUris(uris); 150 return this; 151 } 152 153 /** 154 * The user name to use for basic authentication. 155 */ 156 public EtcdServiceCallServiceDiscoveryConfiguration userName(String userName) { 157 setUserName(userName); 158 return this; 159 } 160 161 /** 162 * The password to use for basic authentication. 163 */ 164 public EtcdServiceCallServiceDiscoveryConfiguration password(String password) { 165 setPassword(password); 166 return this; 167 } 168 169 /** 170 * To set the maximum time an action could take to complete. 171 */ 172 public EtcdServiceCallServiceDiscoveryConfiguration timeout(Long timeout) { 173 return timeout(Long.toString(timeout)); 174 } 175 176 /** 177 * To set the maximum time an action could take to complete. 178 */ 179 public EtcdServiceCallServiceDiscoveryConfiguration timeout(String timeout) { 180 setTimeout(timeout); 181 return this; 182 } 183 184 /** 185 * The path to look for for service discovery 186 */ 187 public EtcdServiceCallServiceDiscoveryConfiguration servicePath(String servicePath) { 188 setServicePath(servicePath); 189 return this; 190 } 191 192 /** 193 * To configure security using SSLContextParameters. 194 */ 195 public EtcdServiceCallServiceDiscoveryConfiguration sslContextParameters(SSLContextParameters sslContextParameters) { 196 setSslContextParameters(sslContextParameters); 197 return this; 198 } 199 200 /** 201 * To set the discovery type, valid values are on-demand and watch. 202 */ 203 public EtcdServiceCallServiceDiscoveryConfiguration type(String type) { 204 setType(type); 205 return this; 206 } 207}