use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method patchNamespacedPodReturningObject.
@Test
public void patchNamespacedPodReturningObject() {
V1Patch v1Patch = new V1Patch("{}");
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(patch(urlEqualTo("/api/v1/namespaces/default/pods/foo1")).withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podPatchResp = podClient.patch("default", "foo1", V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, v1Patch);
assertTrue(podPatchResp.isSuccess());
assertEquals(foo1, podPatchResp.getObject());
assertNull(podPatchResp.getStatus());
verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method deleteNamespacedPodReturningDeletedObject.
@Test
public void deleteNamespacedPodReturningDeletedObject() {
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1")).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> deletePodResp = podClient.delete("default", "foo1");
assertTrue(deletePodResp.isSuccess());
assertEquals(foo1, deletePodResp.getObject());
assertNull(deletePodResp.getStatus());
verify(1, deleteRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method patchNamespacedPodWithApiPrefix.
@Test
public void patchNamespacedPodWithApiPrefix() {
V1Patch v1Patch = new V1Patch("{}");
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
// add api prefix
String prefix = "/k8s/clusters/c-7q988";
stubFor(patch(urlEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1")).withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
GenericKubernetesApi<V1Pod, V1PodList> rancherPodClient = new GenericKubernetesApi<>(V1Pod.class, V1PodList.class, "", "v1", "pods", new ClientBuilder().setBasePath("http://localhost:" + 8181 + prefix).build());
KubernetesApiResponse<V1Pod> podPatchResp = rancherPodClient.patch("default", "foo1", V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, v1Patch);
assertTrue(podPatchResp.isSuccess());
assertEquals(foo1, podPatchResp.getObject());
assertNull(podPatchResp.getStatus());
verify(1, patchRequestedFor(urlPathEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method updateNamespacedPodReturningObject.
@Test
public void updateNamespacedPodReturningObject() {
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(put(urlEqualTo("/api/v1/namespaces/default/pods/foo1")).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podListResp = podClient.update(foo1);
assertTrue(podListResp.isSuccess());
assertEquals(foo1, podListResp.getObject());
assertNull(podListResp.getStatus());
verify(1, putRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class DynamicKubernetesApiTest method testListNamespaceShouldWork.
@Test
public void testListNamespaceShouldWork() throws ApiException {
V1NamespaceList expectedList = new V1NamespaceList().addItemsItem(new V1Namespace().metadata(new V1ObjectMeta().name("foo1"))).addItemsItem(new V1Namespace().metadata(new V1ObjectMeta().name("foo2")));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/namespaces")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(apiClient.getJSON().serialize(expectedList))));
DynamicKubernetesApi api = new DynamicKubernetesApi("", "v1", "namespaces", apiClient);
DynamicKubernetesListObject listObj = api.list().throwsApiException().getObject();
assertEquals(expectedList.getItems().size(), listObj.getItems().size());
wireMockRule.verify(getRequestedFor(urlPathEqualTo("/api/v1/namespaces")));
}
Aggregations