-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Make role descriptors optional when creating API keys #43481
Conversation
This commit changes the `role_descriptors` field from required to optional when creating API key. The default behavior in .NET ES client is to omit properties with `null` value requiring additional workarounds. The behavior for the API does not change. Field names (`id`, `name`) in the invalidate api keys API documentation have been corrected where they were wrong. Closes elastic#42053
Pinging @elastic/es-docs |
Pinging @elastic/es-security |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a minor nit
@@ -49,7 +49,7 @@ public CreateApiKeyRequest(String name, List<RoleDescriptor> roleDescriptors, @N | |||
} else { | |||
throw new IllegalArgumentException("name must not be null or empty"); | |||
} | |||
this.roleDescriptors = Objects.requireNonNull(roleDescriptors, "role descriptors may not be null"); | |||
this.roleDescriptors = (roleDescriptors == null) ? List.of() : roleDescriptors; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter can be annotated with @Nullable
.
@@ -86,7 +86,7 @@ public void setExpiration(TimeValue expiration) { | |||
} | |||
|
|||
public void setRoleDescriptors(List<RoleDescriptor> roleDescriptors) { | |||
this.roleDescriptors = Collections.unmodifiableList(Objects.requireNonNull(roleDescriptors, "role descriptors may not be null")); | |||
this.roleDescriptors = (roleDescriptors == null) ? List.of() : Collections.unmodifiableList(roleDescriptors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are going to use List.of
then Collections.unmodifiableList(
should also be replaced by List.copyOf
.
But, we don't have a general guidance, so I would go with the "surroundings", and raise a bigger refactoring issue for all requests? Maybe worth raising a discussion in the team's meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here I think we should be using List.copyOf
so it is unmodifiable not not just unmodifiable view of the source. Updated here, Thank you.
This commit changes the `role_descriptors` field from required to optional when creating API key. The default behavior in .NET ES client is to omit properties with `null` value requiring additional workarounds. The behavior for the API does not change. Field names (`id`, `name`) in the invalidate api keys API documentation have been corrected where they were wrong. Closes elastic#42053
This commit changes the `role_descriptors` field from required to optional when creating API key. The default behavior in .NET ES client is to omit properties with `null` value requiring additional workarounds. The behavior for the API does not change. Field names (`id`, `name`) in the invalidate api keys API documentation have been corrected where they were wrong. Closes elastic#42053
This commit changes the `role_descriptors` field from required to optional when creating API key. The default behavior in .NET ES client is to omit properties with `null` value requiring additional workarounds. The behavior for the API does not change. Field names (`id`, `name`) in the invalidate api keys API documentation have been corrected where they were wrong. Closes #42053
This commit changes the `role_descriptors` field from required to optional when creating API key. The default behavior in .NET ES client is to omit properties with `null` value requiring additional workarounds. The behavior for the API does not change. Field names (`id`, `name`) in the invalidate api keys API documentation have been corrected where they were wrong. Closes #42053
This commit changes the
role_descriptors
field from requiredto optional when creating an API key. The default behavior in .NET ES
client is to omit properties with
null
value requiring additionalworkarounds. The behavior for the API does not change.
Field names (
id
,name
) in the invalidate api keys API documentation have beencorrected where they were wrong.
Closes #42053