From 4f9a95d4358707339d8d33c85deb4ccd6a226a79 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 7 Dec 2023 14:44:18 +0400 Subject: [PATCH] Add role_templates in SecurityPutRoleMappingRequest (#2357) --- output/schema/schema.json | 116 ++++++++++-------- output/typescript/types.ts | 19 +-- specification/security/_types/RoleMapping.ts | 2 +- specification/security/_types/RoleTemplate.ts | 31 +++++ specification/security/get_role/types.ts | 13 +- .../SecurityPutRoleMappingRequest.ts | 2 + 6 files changed, 110 insertions(+), 73 deletions(-) create mode 100644 specification/security/_types/RoleTemplate.ts diff --git a/output/schema/schema.json b/output/schema/schema.json index 341159676e..af1ae3d844 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -171818,7 +171818,7 @@ "kind": "instance_of", "type": { "name": "RoleTemplate", - "namespace": "security.get_role" + "namespace": "security._types" } } } @@ -171889,6 +171889,38 @@ "kind": "container" } }, + { + "kind": "interface", + "name": { + "name": "RoleTemplate", + "namespace": "security._types" + }, + "properties": [ + { + "name": "format", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "TemplateFormat", + "namespace": "security._types" + } + } + }, + { + "name": "template", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Script", + "namespace": "_types" + } + } + } + ], + "specLocation": "security/_types/RoleTemplate.ts#L28-L31" + }, { "codegenNames": [ "query_string", @@ -172036,6 +172068,22 @@ "kind": "union_of" } }, + { + "kind": "enum", + "members": [ + { + "name": "string" + }, + { + "name": "json" + } + ], + "name": { + "name": "TemplateFormat", + "namespace": "security._types" + }, + "specLocation": "security/_types/RoleTemplate.ts#L22-L25" + }, { "kind": "interface", "name": { @@ -175090,7 +175138,7 @@ "kind": "instance_of", "type": { "name": "RoleTemplate", - "namespace": "security.get_role" + "namespace": "security._types" } } } @@ -175152,54 +175200,6 @@ ], "specLocation": "security/get_role/types.ts#L29-L42" }, - { - "kind": "interface", - "name": { - "name": "RoleTemplate", - "namespace": "security.get_role" - }, - "properties": [ - { - "name": "format", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "TemplateFormat", - "namespace": "security.get_role" - } - } - }, - { - "name": "template", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Script", - "namespace": "_types" - } - } - } - ], - "specLocation": "security/get_role/types.ts#L50-L53" - }, - { - "kind": "enum", - "members": [ - { - "name": "string" - }, - { - "name": "json" - } - ], - "name": { - "name": "TemplateFormat", - "namespace": "security.get_role" - }, - "specLocation": "security/get_role/types.ts#L44-L47" - }, { "attachedBehaviors": [ "CommonQueryParameters" @@ -177793,6 +177793,20 @@ } } }, + { + "name": "role_templates", + "required": false, + "type": { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "RoleTemplate", + "namespace": "security._types" + } + } + } + }, { "name": "rules", "required": false, @@ -177860,7 +177874,7 @@ } } ], - "specLocation": "security/put_role_mapping/SecurityPutRoleMappingRequest.ts#L24-L43" + "specLocation": "security/put_role_mapping/SecurityPutRoleMappingRequest.ts#L25-L45" }, { "body": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index ce3141a877..4bc6d799f3 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -16142,7 +16142,7 @@ export interface SecurityRoleMapping { metadata: Metadata roles: string[] rules: SecurityRoleMappingRule - role_templates?: SecurityGetRoleRoleTemplate[] + role_templates?: SecurityRoleTemplate[] } export interface SecurityRoleMappingRule { @@ -16152,6 +16152,11 @@ export interface SecurityRoleMappingRule { except?: SecurityRoleMappingRule } +export interface SecurityRoleTemplate { + format?: SecurityTemplateFormat + template: Script +} + export type SecurityRoleTemplateInlineQuery = string | QueryDslQueryContainer export interface SecurityRoleTemplateInlineScript extends ScriptBase { @@ -16166,6 +16171,8 @@ export interface SecurityRoleTemplateQuery { export type SecurityRoleTemplateScript = SecurityRoleTemplateInlineScript | SecurityRoleTemplateInlineQuery | StoredScriptId +export type SecurityTemplateFormat = 'string' | 'json' + export interface SecurityTransientMetadataConfig { enabled: boolean } @@ -16496,17 +16503,10 @@ export interface SecurityGetRoleRole { run_as: string[] transient_metadata: SecurityTransientMetadataConfig applications: SecurityApplicationPrivileges[] - role_templates?: SecurityGetRoleRoleTemplate[] + role_templates?: SecurityRoleTemplate[] global?: Record>> } -export interface SecurityGetRoleRoleTemplate { - format?: SecurityGetRoleTemplateFormat - template: Script -} - -export type SecurityGetRoleTemplateFormat = 'string' | 'json' - export interface SecurityGetRoleMappingRequest extends RequestBase { name?: Names } @@ -16780,6 +16780,7 @@ export interface SecurityPutRoleMappingRequest extends RequestBase { enabled?: boolean metadata?: Metadata roles?: string[] + role_templates?: SecurityRoleTemplate[] rules?: SecurityRoleMappingRule run_as?: string[] } diff --git a/specification/security/_types/RoleMapping.ts b/specification/security/_types/RoleMapping.ts index 494a1bfe74..9f505418a9 100644 --- a/specification/security/_types/RoleMapping.ts +++ b/specification/security/_types/RoleMapping.ts @@ -17,9 +17,9 @@ * under the License. */ -import { RoleTemplate } from '@security/get_role/types' import { Metadata } from '@_types/common' import { RoleMappingRule } from './RoleMappingRule' +import { RoleTemplate } from './RoleTemplate' // ES: ExpressionRoleMapping export class RoleMapping { diff --git a/specification/security/_types/RoleTemplate.ts b/specification/security/_types/RoleTemplate.ts new file mode 100644 index 0000000000..2065b84377 --- /dev/null +++ b/specification/security/_types/RoleTemplate.ts @@ -0,0 +1,31 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Script } from '@_types/Scripting' + +export enum TemplateFormat { + string = 0, + json = 1 +} + +// ES: TemplateRoleName +export class RoleTemplate { + format?: TemplateFormat + template: Script +} diff --git a/specification/security/get_role/types.ts b/specification/security/get_role/types.ts index 2cef4c0e17..64e7be0146 100644 --- a/specification/security/get_role/types.ts +++ b/specification/security/get_role/types.ts @@ -24,7 +24,7 @@ import { import { TransientMetadataConfig } from '@security/_types/TransientMetadataConfig' import { Dictionary } from '@spec_utils/Dictionary' import { Metadata } from '@_types/common' -import { Script } from '@_types/Scripting' +import { RoleTemplate } from '@security/_types/RoleTemplate' export class Role { cluster: string[] @@ -40,14 +40,3 @@ export class Role { */ global?: Dictionary>> } - -export enum TemplateFormat { - string = 0, - json = 1 -} - -// ES: TemplateRoleName -export class RoleTemplate { - format?: TemplateFormat - template: Script -} diff --git a/specification/security/put_role_mapping/SecurityPutRoleMappingRequest.ts b/specification/security/put_role_mapping/SecurityPutRoleMappingRequest.ts index 87ebba9cc1..fd9e6fc050 100644 --- a/specification/security/put_role_mapping/SecurityPutRoleMappingRequest.ts +++ b/specification/security/put_role_mapping/SecurityPutRoleMappingRequest.ts @@ -20,6 +20,7 @@ import { RoleMappingRule } from '@security/_types/RoleMappingRule' import { RequestBase } from '@_types/Base' import { Metadata, Name, Refresh } from '@_types/common' +import { RoleTemplate } from '@security/_types/RoleTemplate' /** * @rest_spec_name security.put_role_mapping @@ -37,6 +38,7 @@ export interface Request extends RequestBase { enabled?: boolean metadata?: Metadata roles?: string[] + role_templates?: RoleTemplate[] rules?: RoleMappingRule run_as?: string[] }