Jian Li | b25bcd4 | 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 | /** |
| 92 | * Returns the token used for authenticating to API server. |
| 93 | * |
| 94 | * @return token value |
| 95 | */ |
| 96 | String token(); |
| 97 | |
| 98 | /** |
| 99 | * Returns the CA certificate data. |
| 100 | * |
| 101 | * @return CA certificate data |
| 102 | */ |
| 103 | String caCertData(); |
| 104 | |
| 105 | /** |
| 106 | * Returns the client certificate data. |
| 107 | * |
| 108 | * @return client certificate data |
| 109 | */ |
| 110 | String clientCertData(); |
| 111 | |
| 112 | /** |
| 113 | * Returns the client key data. |
| 114 | * |
| 115 | * @return client key data |
| 116 | */ |
| 117 | String clientKeyData(); |
| 118 | |
| 119 | /** |
| 120 | * Builder of new API config entity. |
| 121 | */ |
| 122 | interface Builder { |
| 123 | |
| 124 | /** |
| 125 | * Builds an immutable KubeVirt API config instance. |
| 126 | * |
| 127 | * @return KubeVirt API config instance |
| 128 | */ |
| 129 | KubevirtApiConfig build(); |
| 130 | |
| 131 | /** |
| 132 | * Returns KubeVirt API server config builder with supplied scheme. |
| 133 | * |
| 134 | * @param scheme scheme of authentication |
| 135 | * @return KubeVirt API config builder |
| 136 | */ |
| 137 | Builder scheme(Scheme scheme); |
| 138 | |
| 139 | /** |
| 140 | * Returns KubeVirt API server config builder with supplied IP address. |
| 141 | * |
| 142 | * @param ipAddress IP address of KubeVirt API server |
| 143 | * @return KubeVirt API config builder |
| 144 | */ |
| 145 | Builder ipAddress(IpAddress ipAddress); |
| 146 | |
| 147 | /** |
| 148 | * Returns KubeVirt API server config builder with supplied port number. |
| 149 | * |
| 150 | * @param port port number of KubeVirt API server |
| 151 | * @return KubeVirt API config builder |
| 152 | */ |
| 153 | Builder port(int port); |
| 154 | |
| 155 | /** |
| 156 | * Returns KubeVirt API server config builder with supplied state. |
| 157 | * |
| 158 | * @param state connectivity state |
| 159 | * @return KubeVirt API config builder |
| 160 | */ |
| 161 | Builder state(State state); |
| 162 | |
| 163 | /** |
| 164 | * Returns KubeVirt API server config builder with supplied token. |
| 165 | * |
| 166 | * @param token token for authentication |
| 167 | * @return KubeVirt API config builder |
| 168 | */ |
| 169 | Builder token(String token); |
| 170 | |
| 171 | /** |
| 172 | * Returns KubeVirt API server config builder with supplied CA certificate data. |
| 173 | * |
| 174 | * @param caCertData CA certificate data |
| 175 | * @return KubeVirt API config builder |
| 176 | */ |
| 177 | Builder caCertData(String caCertData); |
| 178 | |
| 179 | /** |
| 180 | * Returns KubeVirt API server config builder with supplied client certificate data. |
| 181 | * |
| 182 | * @param clientCertData client certificate data |
| 183 | * @return KubeVirt API config builder |
| 184 | */ |
| 185 | Builder clientCertData(String clientCertData); |
| 186 | |
| 187 | /** |
| 188 | * Returns KubeVirt API server config builder with supplied client key data. |
| 189 | * |
| 190 | * @param clientKeyData client key data |
| 191 | * @return KubeVirt API config builder |
| 192 | */ |
| 193 | Builder clientKeyData(String clientKeyData); |
| 194 | } |
| 195 | } |