use of io.kubernetes.client.openapi.ApiException in project java by kubernetes-client.
the class KubectlApply method executeServerSideApply.
private ApiType executeServerSideApply() throws KubectlException {
refreshDiscovery();
GenericKubernetesApi<ApiType, KubernetesListObject> api = getGenericApi();
PatchOptions patchOptions = new PatchOptions();
patchOptions.setForce(this.forceConflict);
patchOptions.setFieldManager(this.fieldManager);
if (ModelMapper.isNamespaced(this.targetObj.getClass())) {
String targetNamespace = namespace != null ? namespace : Strings.isNullOrEmpty(targetObj.getMetadata().getNamespace()) ? Namespaces.NAMESPACE_DEFAULT : targetObj.getMetadata().getNamespace();
KubernetesApiResponse<KubernetesObject> response = null;
try {
return api.patch(targetNamespace, targetObj.getMetadata().getName(), V1Patch.PATCH_FORMAT_APPLY_YAML, new V1Patch(apiClient.getJSON().serialize(targetObj)), patchOptions).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
} else {
try {
return api.patch(targetObj.getMetadata().getName(), V1Patch.PATCH_FORMAT_APPLY_YAML, new V1Patch(apiClient.getJSON().serialize(targetObj)), patchOptions).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
}
}
use of io.kubernetes.client.openapi.ApiException in project java by kubernetes-client.
the class KubectlExec method execute.
@Override
public Integer execute() throws KubectlException {
V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(name).namespace(namespace));
Exec exec = new Exec(apiClient);
try {
Process proc = exec.exec(pod, command, container, stdin, tty);
copyAsync(proc.getInputStream(), System.out);
copyAsync(proc.getErrorStream(), System.err);
if (stdin) {
copyAsync(System.in, proc.getOutputStream());
}
return proc.waitFor();
} catch (InterruptedException | ApiException | IOException ex) {
throw new KubectlException(ex);
}
}
use of io.kubernetes.client.openapi.ApiException in project java by kubernetes-client.
the class KubectlLabel method execute.
@Override
public ApiType execute() throws KubectlException {
verifyArguments();
refreshDiscovery();
final ApiType currentObj;
if (isNamespaced(apiTypeClass)) {
try {
currentObj = getGenericApi().get(namespace, name).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
} else {
try {
currentObj = getGenericApi().get(name).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
}
Labels.addLabels(currentObj, addingLabels);
try {
return getGenericApi().update(currentObj).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
}
use of io.kubernetes.client.openapi.ApiException in project java by kubernetes-client.
the class KubectlReplace method execute.
@Override
public ApiType execute() throws KubectlException {
verifyArguments();
refreshDiscovery();
if (isNamespaced(apiTypeClass)) {
try {
return getGenericApi().update(updateObject, options).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
} else {
try {
return getGenericApi().update(updateObject, options).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
}
}
use of io.kubernetes.client.openapi.ApiException in project java by kubernetes-client.
the class KubectlGet method execute.
@Override
public List<ApiType> execute() throws KubectlException {
refreshDiscovery();
GenericKubernetesApi<ApiType, ? extends KubernetesListObject> api = apiTypeListClass == null ? getGenericApi(apiTypeClass) : getGenericApi(apiTypeClass, apiTypeListClass);
try {
if (isNamespaced()) {
return (List<ApiType>) api.list(namespace, listOptions).throwsApiException().getObject().getItems();
} else {
return (List<ApiType>) api.list(listOptions).throwsApiException().getObject().getItems();
}
} catch (ApiException e) {
throw new KubectlException(e);
}
}
Aggregations