-
Notifications
You must be signed in to change notification settings - Fork 99
Extract security.privileges.query in a typealias #1735
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
Conversation
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.
From the ES source code, the type for IndicesPrivilegesQuery
is string | QueryContainer | RoleTemplateQueryContainer | null
(not a string array).
I think we can ignore null
as it has the same result as not including the query
field.
The string
is interpreted as QueryContainer | RoleTemplateQueryContainer
in "json as text" (see also the doc). ES uses this string format internally, and will always serialize this field as a json-as-text (i.e. the string
variant).
Additionally, RoleTemplateQueryContainer
is not a container, it's a simple structure that has a single template: Script
field (we don't need RoleTemplateQueryContainer
).
And finally, we need a @codegen_name
on the union type to identify the variants.
So that should be:
export class IndicesPrivileges {
...
query?: IndicesPrivilegesQuery
}
/**
* ... explain that text and JSON are accepted in requests, but that responses
* will always contain the text version.
*
* @codegen_name text, query, template
*/
export type IndicesPrivilegesQuery = string | QueryContainer | RoleTemplateQuery
export class RoleTemplateQueryContainer {
...
template?: Script
}
Add comments to clarify usage and intent in requests & responses
9c0b917
to
2eb2281
Compare
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, with minor comments
Change codegen text to json_text for clarity
Following you can find the validation results for the APIs you have changed.
You can validate these APIs yourself by using the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-7.17 7.17
# Navigate to the new working tree
cd .worktrees/backport-7.17
# Create a new branch
git switch --create backport-1735-to-7.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 906a519c49fe09c81f3a95552208c6dbcf7dcd0b
# Push it to GitHub
git push --set-upstream origin backport-1735-to-7.17
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.17 Then, create a pull request where the |
* Extract security.privileges.query in a typealias * Change union type in favor a unique string Add comments to clarify usage and intent in requests & responses * Add backquotes for types clarity in comments Change codegen text to json_text for clarity * Rename RoleTemplateQuery as this is not a container
* Extract security.privileges.query in a typealias * Change union type in favor a unique string Add comments to clarify usage and intent in requests & responses * Add backquotes for types clarity in comments Change codegen text to json_text for clarity * Rename RoleTemplateQuery as this is not a container
* Extract security.privileges.query in a typealias * Change union type in favor a unique string Add comments to clarify usage and intent in requests & responses * Add backquotes for types clarity in comments Change codegen text to json_text for clarity * Rename RoleTemplateQuery as this is not a container
* Extract security.privileges.query in a typealias * Change union type in favor a unique string Add comments to clarify usage and intent in requests & responses * Add backquotes for types clarity in comments Change codegen text to json_text for clarity * Rename RoleTemplateQuery as this is not a container Co-authored-by: Laurent Saint-Félix <[email protected]>
No description provided.