Skip to content

Commit e6a1ab1

Browse files
Anaetheliongithub-actions[bot]
authored andcommitted
Extract security.privileges.query in a typealias (#1735)
* 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
1 parent 52ed85b commit e6a1ab1

File tree

5 files changed

+74
-50
lines changed

5 files changed

+74
-50
lines changed

output/schema/schema.json

Lines changed: 55 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/validation-errors.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/typescript/types.ts

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/security/_types/Privileges.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,25 @@ export class IndicesPrivileges {
9494
/**
9595
* A search query that defines the documents the owners of the role have read access to. A document within the specified indices must match this query for it to be accessible by the owners of the role.
9696
*/
97-
query?: string[] | QueryContainer | RoleTemplateQueryContainer
97+
query?: IndicesPrivilegesQuery
9898
/**
9999
* Set to `true` if using wildcard or regular expressions for patterns that cover restricted indices. Implicitly, restricted indices have limited privileges that can cause pattern tests to fail. If restricted indices are explicitly included in the `names` list, Elasticsearch checks privileges against these indices regardless of the value set for `allow_restricted_indices`.
100100
* @server_default false
101101
*/
102102
allow_restricted_indices?: boolean
103103
}
104104

105-
/** @variants container */
106-
export class RoleTemplateQueryContainer {
105+
/**
106+
* While creating or updating a role you can provide either a JSON structure or a string to the API.
107+
* However, the response provided by Elasticsearch will only be string with a json-as-text content.
108+
*
109+
* Since this is embedded in `IndicesPrivileges`, the same structure is used for clarity in both contexts.
110+
*
111+
* @codegen_names json_text, query, template
112+
*/
113+
export type IndicesPrivilegesQuery = string | QueryContainer | RoleTemplateQuery
114+
115+
export class RoleTemplateQuery {
107116
/**
108117
* When you create a role, you can specify a query that defines the document level security permissions. You can optionally
109118
* use Mustache templates in the role query to insert the username of the current authenticated user into the role.

specification/security/get_user_privileges/SecurityGetUserPrivilegesResponse.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class Response {
2828
applications: ApplicationPrivileges[]
2929
cluster: string[]
3030
global: GlobalPrivilege[]
31+
/**
32+
* In this context `IndicesPrivileges.query` property can only be a string, see `IndicesPrivileges` documentation for detail.
33+
*/
3134
indices: IndicesPrivileges[]
3235
run_as: string[]
3336
}

0 commit comments

Comments
 (0)