Skip to content

Commit eb79528

Browse files
authored
Unify RoleDescriptor, add security.update_api_key API
1 parent d8c3eca commit eb79528

File tree

8 files changed

+495
-304
lines changed

8 files changed

+495
-304
lines changed

output/schema/schema.json

Lines changed: 366 additions & 240 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: 36 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/security/create_api_key/types.ts renamed to specification/security/_types/RoleDescriptor.ts

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

20-
import {
21-
IndexPrivilege,
22-
ApplicationPrivileges,
23-
IndicesPrivileges,
24-
GlobalPrivilege
25-
} from '@security/_types/Privileges'
26-
import { Indices, Metadata } from '@_types/common'
27-
import { TransientMetadataConfig } from '@security/_types/TransientMetadataConfig'
20+
import { GlobalPrivilege } from './Privileges'
21+
import { IndicesPrivileges } from './Privileges'
22+
import { ApplicationPrivileges } from './Privileges'
23+
import { TransientMetadataConfig } from './TransientMetadataConfig'
24+
import { Metadata } from '@_types/common'
25+
import { OverloadOf } from '@spec_utils/behaviors'
2826

29-
// FIXME: should be merged with get_service_accounts/RoleDescriptor
3027
export class RoleDescriptor {
31-
cluster: string[]
28+
cluster?: string[]
3229
/** @aliases index */
33-
indices: IndicesPrivileges[]
30+
indices?: IndicesPrivileges[]
3431
global?: GlobalPrivilege[] | GlobalPrivilege
3532
applications?: ApplicationPrivileges[]
3633
metadata?: Metadata
3734
run_as?: string[]
3835
transient_metadata?: TransientMetadataConfig
3936
}
4037

41-
export class IndexPrivileges {
42-
names: Indices
43-
privileges: IndexPrivilege[]
38+
export class RoleDescriptorRead implements OverloadOf<RoleDescriptor> {
39+
cluster: string[]
40+
/** @aliases index */
41+
indices: IndicesPrivileges[]
42+
global?: GlobalPrivilege[] | GlobalPrivilege
43+
applications?: ApplicationPrivileges[]
44+
metadata?: Metadata
45+
run_as?: string[]
46+
transient_metadata?: TransientMetadataConfig
4447
}

specification/security/create_api_key/SecurityCreateApiKeyRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Dictionary } from '@spec_utils/Dictionary'
2121
import { RequestBase } from '@_types/Base'
2222
import { Metadata, Name, Refresh } from '@_types/common'
2323
import { Duration } from '@_types/Time'
24-
import { RoleDescriptor } from './types'
24+
import { RoleDescriptor } from '@security/_types/RoleDescriptor'
2525

2626
/**
2727
* @rest_spec_name security.create_api_key

specification/security/get_service_accounts/types.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,8 @@
1717
* under the License.
1818
*/
1919

20-
import {
21-
IndicesPrivileges,
22-
GlobalPrivilege,
23-
ApplicationPrivileges
24-
} from '@security/_types/Privileges'
25-
import { TransientMetadataConfig } from '@security/_types/TransientMetadataConfig'
26-
import { Metadata } from '@_types/common'
20+
import { RoleDescriptorRead } from '@security/_types/RoleDescriptor'
2721

2822
export class RoleDescriptorWrapper {
29-
role_descriptor: RoleDescriptor
30-
}
31-
32-
export class RoleDescriptor {
33-
cluster: string[]
34-
/** @aliases index */
35-
indices: IndicesPrivileges[]
36-
global?: GlobalPrivilege[] | GlobalPrivilege
37-
applications?: ApplicationPrivileges[]
38-
metadata?: Metadata
39-
run_as?: string[]
40-
transient_metadata?: TransientMetadataConfig
23+
role_descriptor: RoleDescriptorRead
4124
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 { RequestBase } from '@_types/Base'
21+
import { Id, Metadata } from '@_types/common'
22+
import { Dictionary } from '@spec_utils/Dictionary'
23+
import { RoleDescriptor } from '@security/_types/RoleDescriptor'
24+
25+
/**
26+
* Updates attributes of an existing API key.
27+
* @rest_spec_name security.update_api_key
28+
* @since 8.4.0
29+
* @stability stable
30+
*/
31+
export interface Request extends RequestBase {
32+
path_parts: {
33+
/**
34+
* The ID of the API key to update.
35+
*/
36+
id: Id
37+
}
38+
body: {
39+
/**
40+
* An array of role descriptors for this API key. This parameter is optional. When it is not specified or is an empty array, then the API key will have a point in time snapshot of permissions of the authenticated user. If you supply role descriptors then the resultant permissions would be an intersection of API keys permissions and authenticated user’s permissions thereby limiting the access scope for API keys. The structure of role descriptor is the same as the request for create role API. For more details, see create or update roles API.
41+
* @doc_id security-api-put-role
42+
*/
43+
role_descriptors?: Dictionary<string, RoleDescriptor>
44+
/**
45+
* Arbitrary metadata that you want to associate with the API key. It supports nested data structure. Within the metadata object, keys beginning with _ are reserved for system usage.
46+
*/
47+
metadata?: Metadata
48+
}
49+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
export class Response {
21+
body: {
22+
updated: boolean
23+
}
24+
}

0 commit comments

Comments
 (0)