From 0a086eb5752ded3ad19145560116ffe3b1f689f3 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 7 Dec 2023 14:44:18 +0400 Subject: [PATCH 1/2] Add role_templates in SecurityPutRoleMappingRequest (#2357) (cherry picked from commit 4f9a95d4358707339d8d33c85deb4ccd6a226a79) --- 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 7afdc3cace..89a67b537e 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -170606,7 +170606,7 @@ "kind": "instance_of", "type": { "name": "RoleTemplate", - "namespace": "security.get_role" + "namespace": "security._types" } } } @@ -170677,6 +170677,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", @@ -170824,6 +170856,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": { @@ -173878,7 +173926,7 @@ "kind": "instance_of", "type": { "name": "RoleTemplate", - "namespace": "security.get_role" + "namespace": "security._types" } } } @@ -173940,54 +173988,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" @@ -176581,6 +176581,20 @@ } } }, + { + "name": "role_templates", + "required": false, + "type": { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "RoleTemplate", + "namespace": "security._types" + } + } + } + }, { "name": "rules", "required": false, @@ -176648,7 +176662,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 d818b59c24..9ffd778679 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -16047,7 +16047,7 @@ export interface SecurityRoleMapping { metadata: Metadata roles: string[] rules: SecurityRoleMappingRule - role_templates?: SecurityGetRoleRoleTemplate[] + role_templates?: SecurityRoleTemplate[] } export interface SecurityRoleMappingRule { @@ -16057,6 +16057,11 @@ export interface SecurityRoleMappingRule { except?: SecurityRoleMappingRule } +export interface SecurityRoleTemplate { + format?: SecurityTemplateFormat + template: Script +} + export type SecurityRoleTemplateInlineQuery = string | QueryDslQueryContainer export interface SecurityRoleTemplateInlineScript extends ScriptBase { @@ -16071,6 +16076,8 @@ export interface SecurityRoleTemplateQuery { export type SecurityRoleTemplateScript = SecurityRoleTemplateInlineScript | SecurityRoleTemplateInlineQuery | StoredScriptId +export type SecurityTemplateFormat = 'string' | 'json' + export interface SecurityTransientMetadataConfig { enabled: boolean } @@ -16401,17 +16408,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 } @@ -16685,6 +16685,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[] } From 5f0de41a3e69de5188c525ed981b6f12fde11650 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 7 Dec 2023 14:53:06 +0400 Subject: [PATCH 2/2] Trigger CI