New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement StatusWriter so you can patch just the status field in an API object #1442
Comments
I managed to patch a status using code a bit like this. I hope I did it wrong and there's a better way ( CustomObjectsApi api = new CustomObjectsApi(apiClient);
GroupVersion gv = GroupVersion.parse(object);
api.patchNamespacedCustomObjectStatus(gv.getGroup(), gv.getVersion(),
object.getMetadata().getNamespace(), this.pluralName, object.getMetadata().getName(),
Arrays.asList(new ObjectPatch(extractStatus(object))), null, null, null); where public static class ObjectPatch {
private String op = "replace";
private String path = "/status";
private Object value;
// ... getters and setters
} If that really is the best way to do it then |
I think that this is the best way to do it. There are methods for updating status for concrete objects (e.g. patchNamespacedPodStatus) but it's not any easier to use. Probably worth adding the the existing patch utilities, rather than adding a new 'StatusWriter' but I think adding utility methods is a good idea. |
OK, so that's useful to know. Can you explain why there is this logic in public String selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) {
return "application/json";
}
for (String contentType : contentTypes) {
if (isJsonMime(contentType)) {
return contentType;
}
}
return contentTypes[0];
} where final String[] localVarContentTypes = {
"application/json-patch+json", "application/merge-patch+json", "application/apply-patch+yaml"
}; so it always responds with the same value (the first one). It's actually easier to create the patch using |
Yeah, this code is generated, and it is not awesome™ We have hacked around it in the Which uses a custom RequestBody: To override this code. You'll want to write your code in terms of that patch method in |
In the Java client is there an equivalent of StatusWriter in Go (where you can update just the status of an API object)? I don't see it anywhere so I guess this is a feature request.
The text was updated successfully, but these errors were encountered: