Skip to content

Commit d60ddd0

Browse files
Add spec for bulk put roles (#2682) (#2696)
* Add spec for bulk put roles (cherry picked from commit eeb4f18) Co-authored-by: Johannes Fredén <109296772+jfreden@users.noreply.github.com>
1 parent 3a44b54 commit d60ddd0

File tree

4 files changed

+126
-3
lines changed

4 files changed

+126
-3
lines changed

specification/security/_types/Bulk.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { integer } from '@_types/Numeric'
21+
import { Dictionary } from '@spec_utils/Dictionary'
22+
import { ErrorCause } from '@_types/Errors'
23+
24+
export class BulkError {
25+
/**
26+
* The number of errors
27+
*/
28+
count: integer
29+
/**
30+
* Details about the errors, keyed by role name
31+
*/
32+
details: Dictionary<string, ErrorCause>
33+
}

specification/security/_types/RoleDescriptor.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import { GlobalPrivilege } from './Privileges'
20+
import { ClusterPrivilege, GlobalPrivilege } from './Privileges'
2121
import { IndicesPrivileges } from './Privileges'
2222
import { ApplicationPrivileges } from './Privileges'
2323
import { Metadata } from '@_types/common'
@@ -29,7 +29,7 @@ export class RoleDescriptor {
2929
/**
3030
* A list of cluster privileges. These privileges define the cluster level actions that API keys are able to execute.
3131
*/
32-
cluster?: string[]
32+
cluster?: ClusterPrivilege[]
3333
/**
3434
* A list of indices permissions entries.
3535
* @aliases index
@@ -52,6 +52,9 @@ export class RoleDescriptor {
5252
* @doc_id run-as-privilege
5353
*/
5454
run_as?: string[]
55+
/**
56+
* Optional description of the role descriptor
57+
*/
5558
description?: string
5659
transient_metadata?: Dictionary<string, UserDefinedValue>
5760
}
@@ -60,7 +63,7 @@ export class RoleDescriptorRead implements OverloadOf<RoleDescriptor> {
6063
/**
6164
* A list of cluster privileges. These privileges define the cluster level actions that API keys are able to execute.
6265
*/
63-
cluster: string[]
66+
cluster: ClusterPrivilege[]
6467
/**
6568
* A list of indices permissions entries.
6669
* @aliases index
@@ -83,6 +86,9 @@ export class RoleDescriptorRead implements OverloadOf<RoleDescriptor> {
8386
* @doc_id run-as-privilege
8487
*/
8588
run_as?: string[]
89+
/**
90+
* Optional description of the role descriptor
91+
*/
8692
description?: string
8793
transient_metadata?: Dictionary<string, UserDefinedValue>
8894
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { Dictionary } from '@spec_utils/Dictionary'
21+
import { RequestBase } from '@_types/Base'
22+
import { Refresh } from '@_types/common'
23+
import { RoleDescriptor } from '@security/_types/RoleDescriptor'
24+
25+
/**
26+
* The role management APIs are generally the preferred way to manage roles, rather than using file-based role management.
27+
* The bulk create or update roles API cannot update roles that are defined in roles files.
28+
* @rest_spec_name security.bulk_put_role
29+
* @availability stack since=8.15.0 stability=stable
30+
* @availability serverless stability=stable visibility=private
31+
* @cluster_privileges manage_security
32+
*/
33+
export interface Request extends RequestBase {
34+
query_parameters: {
35+
refresh?: Refresh
36+
}
37+
body: {
38+
/**
39+
* A dictionary of role name to RoleDescriptor objects to add or update
40+
*/
41+
roles: Dictionary<string, RoleDescriptor>
42+
}
43+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { BulkError } from '@security/_types/Bulk'
21+
22+
export class Response {
23+
body: {
24+
/**
25+
* Array of created roles
26+
*/
27+
created?: string[]
28+
/**
29+
* Array of updated roles
30+
*/
31+
updated?: string[]
32+
/**
33+
* Array of role names without any changes
34+
*/
35+
noop?: string[]
36+
/**
37+
* Present if any updates resulted in errors
38+
*/
39+
errors?: BulkError
40+
}
41+
}

0 commit comments

Comments
 (0)