|
| 1 | +/* |
| 2 | + * |
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 4 | + * or more contributor license agreements. See the NOTICE file |
| 5 | + * distributed with this work for additional information |
| 6 | + * regarding copyright ownership. The ASF licenses this file |
| 7 | + * to you under the Apache License, Version 2.0 (the |
| 8 | + * "License"); you may not use this file except in compliance |
| 9 | + * with the License. You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, |
| 14 | + * software distributed under the License is distributed on an |
| 15 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | + * KIND, either express or implied. See the License for the |
| 17 | + * specific language governing permissions and limitations |
| 18 | + * under the License. |
| 19 | + * |
| 20 | + */ |
| 21 | +package com.github.kubernetes.java.client.v2; |
| 22 | + |
| 23 | +import javax.ws.rs.Consumes; |
| 24 | +import javax.ws.rs.DELETE; |
| 25 | +import javax.ws.rs.GET; |
| 26 | +import javax.ws.rs.POST; |
| 27 | +import javax.ws.rs.PUT; |
| 28 | +import javax.ws.rs.Path; |
| 29 | +import javax.ws.rs.PathParam; |
| 30 | +import javax.ws.rs.Produces; |
| 31 | +import javax.ws.rs.QueryParam; |
| 32 | +import javax.ws.rs.core.MediaType; |
| 33 | + |
| 34 | +import com.github.kubernetes.java.client.exceptions.KubernetesClientException; |
| 35 | +import com.github.kubernetes.java.client.model.Label; |
| 36 | +import com.github.kubernetes.java.client.model.Pod; |
| 37 | +import com.github.kubernetes.java.client.model.PodList; |
| 38 | +import com.github.kubernetes.java.client.model.ReplicationController; |
| 39 | +import com.github.kubernetes.java.client.model.ReplicationControllerList; |
| 40 | +import com.github.kubernetes.java.client.model.Service; |
| 41 | +import com.github.kubernetes.java.client.model.ServiceList; |
| 42 | + |
| 43 | +public interface KubernetesAPI { |
| 44 | + |
| 45 | + /* Pod API */ |
| 46 | + |
| 47 | + /** |
| 48 | + * Get information of a Pod given the PodID |
| 49 | + * @param podId id of the pod |
| 50 | + * @return {@link Pod} |
| 51 | + * @throws KubernetesClientException |
| 52 | + */ |
| 53 | + @GET |
| 54 | + @Path("/pods/{podId}") |
| 55 | + @Consumes(MediaType.APPLICATION_JSON) |
| 56 | + @Produces(MediaType.APPLICATION_JSON) |
| 57 | + public Pod getPod(@PathParam("podId") String podId) throws KubernetesClientException; |
| 58 | + |
| 59 | + /** |
| 60 | + * Get all Pods |
| 61 | + * @return Pods |
| 62 | + * @throws KubernetesClientException |
| 63 | + */ |
| 64 | + @GET |
| 65 | + @Path("/pods") |
| 66 | + @Consumes(MediaType.APPLICATION_JSON) |
| 67 | + @Produces(MediaType.APPLICATION_JSON) |
| 68 | + public PodList getAllPods() throws KubernetesClientException; |
| 69 | + |
| 70 | + /** |
| 71 | + * Create a new Pod |
| 72 | + * @param pod Pod to be created |
| 73 | + * @throws KubernetesClientException |
| 74 | + */ |
| 75 | + @POST |
| 76 | + @Path("/pods") |
| 77 | + @Consumes(MediaType.APPLICATION_JSON) |
| 78 | + @Produces(MediaType.APPLICATION_JSON) |
| 79 | + public void createPod(Pod pod) throws KubernetesClientException; |
| 80 | + |
| 81 | + /** |
| 82 | + * Delete a Pod |
| 83 | + * @param podId Id of the Pod to be deleted |
| 84 | + * @throws KubernetesClientException |
| 85 | + */ |
| 86 | + @DELETE |
| 87 | + @Path("/pods/{podId}") |
| 88 | + @Consumes(MediaType.APPLICATION_JSON) |
| 89 | + public void deletePod(@PathParam("podId") String podId) throws KubernetesClientException; |
| 90 | + |
| 91 | + /* Replication Controller API */ |
| 92 | + |
| 93 | + /** |
| 94 | + * Get a Replication Controller Info |
| 95 | + * @param controllerId id of the Replication Controller |
| 96 | + * @return {@link ReplicationController} |
| 97 | + * @throws KubernetesClientException |
| 98 | + */ |
| 99 | + @GET |
| 100 | + @Path("/replicationControllers/{controllerId}") |
| 101 | + @Consumes(MediaType.APPLICATION_JSON) |
| 102 | + public ReplicationController getReplicationController(@PathParam("controllerId") String controllerId) throws KubernetesClientException; |
| 103 | + |
| 104 | + /** |
| 105 | + * Get all Replication Controllers. |
| 106 | + * @return {@link ReplicationController}s |
| 107 | + * @throws KubernetesClientException |
| 108 | + */ |
| 109 | + @GET |
| 110 | + @Path("/replicationControllers") |
| 111 | + @Consumes(MediaType.APPLICATION_JSON) |
| 112 | + public ReplicationControllerList getAllReplicationControllers() throws KubernetesClientException; |
| 113 | + |
| 114 | + /** |
| 115 | + * Create a new Replication Controller |
| 116 | + * @param controller controller to be created |
| 117 | + * @throws KubernetesClientException |
| 118 | + */ |
| 119 | + @POST |
| 120 | + @Path("/replicationControllers") |
| 121 | + @Consumes(MediaType.APPLICATION_JSON) |
| 122 | + public void createReplicationController(ReplicationController controller) throws KubernetesClientException; |
| 123 | + |
| 124 | + /** |
| 125 | + * Convenience method to update the number of replicas in a Replication Controller. |
| 126 | + * @param controllerId id of the controller to be updated |
| 127 | + * @param replicas update the replicas count of the current controller. |
| 128 | + * @throws KubernetesClientException |
| 129 | + */ |
| 130 | + @PUT |
| 131 | + @Path("/replicationControllers/{controllerId}") |
| 132 | + @Consumes(MediaType.APPLICATION_JSON) |
| 133 | + public void updateReplicationController(@PathParam("controllerId") String controllerId, int replicas) throws KubernetesClientException; |
| 134 | + |
| 135 | + /** |
| 136 | + * Update a Replication Controller |
| 137 | + * @param controllerId id of the controller to be updated |
| 138 | + * @param controller controller to update (only the number of replicas can be updated). |
| 139 | + * @throws KubernetesClientException |
| 140 | + */ |
| 141 | + @PUT |
| 142 | + @Path("/replicationControllers/{controllerId}") |
| 143 | + @Consumes(MediaType.APPLICATION_JSON) |
| 144 | + public void updateReplicationController(@PathParam("controllerId") String controllerId, ReplicationController replicationController) throws KubernetesClientException; |
| 145 | + |
| 146 | + /** |
| 147 | + * Delete a Replication Controller. |
| 148 | + * @param replication controller id controller id to be deleted. |
| 149 | + * @throws KubernetesClientException |
| 150 | + */ |
| 151 | + @DELETE |
| 152 | + @Path("/replicationControllers/{controllerId}") |
| 153 | + @Consumes(MediaType.APPLICATION_JSON) |
| 154 | + public void deleteReplicationController(@PathParam("controllerId") String controllerId) throws KubernetesClientException; |
| 155 | + |
| 156 | + /* Services API */ |
| 157 | + |
| 158 | + /** |
| 159 | + * Get the Service with the given id. |
| 160 | + * @param serviceId id of the service. |
| 161 | + * @return {@link Service} |
| 162 | + * @throws KubernetesClientException |
| 163 | + */ |
| 164 | + @GET |
| 165 | + @Path("/services/{serviceId}") |
| 166 | + @Consumes(MediaType.APPLICATION_JSON) |
| 167 | + public Service getService(@PathParam("serviceId") String serviceId) throws KubernetesClientException; |
| 168 | + |
| 169 | + /** |
| 170 | + * Get all the services. |
| 171 | + * @return array of {@link Service}s |
| 172 | + * @throws KubernetesClientException |
| 173 | + */ |
| 174 | + @GET |
| 175 | + @Path("/services") |
| 176 | + @Consumes(MediaType.APPLICATION_JSON) |
| 177 | + public ServiceList getAllServices() throws KubernetesClientException; |
| 178 | + |
| 179 | + /** |
| 180 | + * Create a new Kubernetes service. |
| 181 | + * @param service service to be created. |
| 182 | + * @throws KubernetesClientException |
| 183 | + */ |
| 184 | + @POST |
| 185 | + @Path("/services") |
| 186 | + @Consumes(MediaType.APPLICATION_JSON) |
| 187 | + public void createService(Service service) throws KubernetesClientException; |
| 188 | + |
| 189 | + /** |
| 190 | + * Delete a Service. |
| 191 | + * @param serviceId service id to be deleted. |
| 192 | + * @throws KubernetesClientException |
| 193 | + */ |
| 194 | + @DELETE |
| 195 | + @Path("/services/{serviceId}") |
| 196 | + @Consumes(MediaType.APPLICATION_JSON) |
| 197 | + public void deleteService(@PathParam("serviceId") String serviceId) throws KubernetesClientException; |
| 198 | + |
| 199 | + /** |
| 200 | + * Run a label query and retrieve a sub set of Pods. |
| 201 | + * @param labels parameter label=label1,label2,label3 |
| 202 | + * @return Pods selected Pods by executing the label query. |
| 203 | + * @throws KubernetesClientException |
| 204 | + */ |
| 205 | + @GET |
| 206 | + @Path("/pods") |
| 207 | + @Consumes(MediaType.APPLICATION_JSON) |
| 208 | + public PodList getSelectedPods(@QueryParam("labels") String labels) throws KubernetesClientException; |
| 209 | +} |
0 commit comments