Jian Li | a1ebbf4 | 2020-12-24 02:43:21 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.kubevirtnode.api; |
| 17 | |
| 18 | import org.onlab.packet.IpAddress; |
| 19 | |
| 20 | /** |
| 21 | * Representation of configuration used in KubeVirt API server. |
| 22 | */ |
| 23 | public interface KubevirtApiConfig { |
| 24 | |
| 25 | /** |
| 26 | * Lists of authentication schemes. |
| 27 | */ |
| 28 | enum Scheme { |
| 29 | /** |
| 30 | * Signifies that this is a HTTP authentication scheme. |
| 31 | */ |
| 32 | HTTP, |
| 33 | |
| 34 | /** |
| 35 | * Signifies that this is a HTTPS authentication scheme. |
| 36 | */ |
| 37 | HTTPS, |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Lists of API server connectivity states. |
| 42 | */ |
| 43 | enum State { |
| 44 | /** |
| 45 | * Signifies that client is connected to KubeVirt API server. |
| 46 | */ |
| 47 | CONNECTED, |
| 48 | |
| 49 | /** |
| 50 | * Signifies that client is dis-connected from KubeVirt API server. |
| 51 | */ |
| 52 | DISCONNECTED, |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns the authentication scheme. |
| 57 | * |
| 58 | * @return authentication scheme |
| 59 | */ |
| 60 | Scheme scheme(); |
| 61 | |
| 62 | /** |
| 63 | * Returns the IP address of KubeVirt API server. |
| 64 | * |
| 65 | * @return IP address of KubeVirt API server |
| 66 | */ |
| 67 | IpAddress ipAddress(); |
| 68 | |
| 69 | /** |
| 70 | * Returns the port number of KubeVirt API server. |
| 71 | * |
| 72 | * @return port number of KubeVirt API server |
| 73 | */ |
| 74 | int port(); |
| 75 | |
| 76 | /** |
| 77 | * Returns the connectivity state to KubeVirt API server. |
| 78 | * |
| 79 | * @return connectivity state to KubeVirt API server |
| 80 | */ |
| 81 | State state(); |
| 82 | |
| 83 | /** |
| 84 | * Returns new KubeVirt API config instance with given state. |
| 85 | * |
| 86 | * @param newState updated state |
| 87 | * @return updated kubernetes API config |
| 88 | */ |
| 89 | KubevirtApiConfig updateState(State newState); |
| 90 | |
| 91 | /** |
Jian Li | 3c3b163 | 2021-04-28 17:24:56 +0900 | [diff] [blame^] | 92 | * Returns the new KubeVirt API config instance with the given IP address. |
| 93 | * |
| 94 | * @param ipAddress updated IP address |
| 95 | * @return updated kubernetes API config |
| 96 | */ |
| 97 | KubevirtApiConfig updateIpAddress(IpAddress ipAddress); |
| 98 | |
| 99 | /** |
| 100 | * Returns the new KubeVirt API config instance with the given port. |
| 101 | * |
| 102 | * @param port updated port |
| 103 | * @return updated kubernetes API config |
| 104 | */ |
| 105 | KubevirtApiConfig updatePort(int port); |
| 106 | |
| 107 | /** |
Jian Li | a1ebbf4 | 2020-12-24 02:43:21 +0900 | [diff] [blame] | 108 | * Returns the token used for authenticating to API server. |
| 109 | * |
| 110 | * @return token value |
| 111 | */ |
| 112 | String token(); |
| 113 | |
| 114 | /** |
| 115 | * Returns the CA certificate data. |
| 116 | * |
| 117 | * @return CA certificate data |
| 118 | */ |
| 119 | String caCertData(); |
| 120 | |
| 121 | /** |
| 122 | * Returns the client certificate data. |
| 123 | * |
| 124 | * @return client certificate data |
| 125 | */ |
| 126 | String clientCertData(); |
| 127 | |
| 128 | /** |
| 129 | * Returns the client key data. |
| 130 | * |
| 131 | * @return client key data |
| 132 | */ |
| 133 | String clientKeyData(); |
| 134 | |
| 135 | /** |
Jian Li | 94b6d16 | 2021-04-15 17:09:11 +0900 | [diff] [blame] | 136 | * Returns the Fully Qualified Domain Name (FQDN) of the service. |
| 137 | * |
Jian Li | 3c3b163 | 2021-04-28 17:24:56 +0900 | [diff] [blame^] | 138 | * @return service FQDN |
Jian Li | 94b6d16 | 2021-04-15 17:09:11 +0900 | [diff] [blame] | 139 | */ |
| 140 | String serviceFqdn(); |
| 141 | |
| 142 | /** |
Jian Li | 3c3b163 | 2021-04-28 17:24:56 +0900 | [diff] [blame^] | 143 | * Returns the Fully Qualified Domain Name (FQDN) of the API server. |
| 144 | * |
| 145 | * @return API server FQDN |
| 146 | */ |
| 147 | String apiServerFqdn(); |
| 148 | |
| 149 | /** |
Jian Li | a1ebbf4 | 2020-12-24 02:43:21 +0900 | [diff] [blame] | 150 | * Builder of new API config entity. |
| 151 | */ |
| 152 | interface Builder { |
| 153 | |
| 154 | /** |
| 155 | * Builds an immutable KubeVirt API config instance. |
| 156 | * |
| 157 | * @return KubeVirt API config instance |
| 158 | */ |
| 159 | KubevirtApiConfig build(); |
| 160 | |
| 161 | /** |
| 162 | * Returns KubeVirt API server config builder with supplied scheme. |
| 163 | * |
| 164 | * @param scheme scheme of authentication |
| 165 | * @return KubeVirt API config builder |
| 166 | */ |
| 167 | Builder scheme(Scheme scheme); |
| 168 | |
| 169 | /** |
| 170 | * Returns KubeVirt API server config builder with supplied IP address. |
| 171 | * |
| 172 | * @param ipAddress IP address of KubeVirt API server |
| 173 | * @return KubeVirt API config builder |
| 174 | */ |
| 175 | Builder ipAddress(IpAddress ipAddress); |
| 176 | |
| 177 | /** |
| 178 | * Returns KubeVirt API server config builder with supplied port number. |
| 179 | * |
| 180 | * @param port port number of KubeVirt API server |
| 181 | * @return KubeVirt API config builder |
| 182 | */ |
| 183 | Builder port(int port); |
| 184 | |
| 185 | /** |
| 186 | * Returns KubeVirt API server config builder with supplied state. |
| 187 | * |
| 188 | * @param state connectivity state |
| 189 | * @return KubeVirt API config builder |
| 190 | */ |
| 191 | Builder state(State state); |
| 192 | |
| 193 | /** |
| 194 | * Returns KubeVirt API server config builder with supplied token. |
| 195 | * |
| 196 | * @param token token for authentication |
| 197 | * @return KubeVirt API config builder |
| 198 | */ |
| 199 | Builder token(String token); |
| 200 | |
| 201 | /** |
| 202 | * Returns KubeVirt API server config builder with supplied CA certificate data. |
| 203 | * |
| 204 | * @param caCertData CA certificate data |
| 205 | * @return KubeVirt API config builder |
| 206 | */ |
| 207 | Builder caCertData(String caCertData); |
| 208 | |
| 209 | /** |
| 210 | * Returns KubeVirt API server config builder with supplied client certificate data. |
| 211 | * |
| 212 | * @param clientCertData client certificate data |
| 213 | * @return KubeVirt API config builder |
| 214 | */ |
| 215 | Builder clientCertData(String clientCertData); |
| 216 | |
| 217 | /** |
| 218 | * Returns KubeVirt API server config builder with supplied client key data. |
| 219 | * |
| 220 | * @param clientKeyData client key data |
| 221 | * @return KubeVirt API config builder |
| 222 | */ |
| 223 | Builder clientKeyData(String clientKeyData); |
Jian Li | 94b6d16 | 2021-04-15 17:09:11 +0900 | [diff] [blame] | 224 | |
| 225 | /** |
Jian Li | 3c3b163 | 2021-04-28 17:24:56 +0900 | [diff] [blame^] | 226 | * Returns Kubevirt API server config builder with supplied service Fqdn. |
Jian Li | 94b6d16 | 2021-04-15 17:09:11 +0900 | [diff] [blame] | 227 | * |
| 228 | * @param serviceFqdn service FQDN |
| 229 | * @return KubeVirt API config builder |
| 230 | */ |
| 231 | Builder serviceFqdn(String serviceFqdn); |
Jian Li | 3c3b163 | 2021-04-28 17:24:56 +0900 | [diff] [blame^] | 232 | |
| 233 | /** |
| 234 | * Returns Kubevirt API server config builder with the supplied API server Fqdn. |
| 235 | * |
| 236 | * @param apiServerFqdn API server FQDN |
| 237 | * @return Kubevirt API config builder |
| 238 | */ |
| 239 | Builder apiServerFqdn(String apiServerFqdn); |
Jian Li | a1ebbf4 | 2020-12-24 02:43:21 +0900 | [diff] [blame] | 240 | } |
| 241 | } |