Skip to content

Commit 4d03905

Browse files
authored
Fix type issues in security APIs
1 parent d8b3a91 commit 4d03905

File tree

17 files changed

+458
-80
lines changed

17 files changed

+458
-80
lines changed

output/schema/schema.json

Lines changed: 337 additions & 57 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 & 8 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: 28 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/security/_types/ApiKey.ts

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

20+
import { Role } from '@security/get_role/types'
21+
import { Dictionary } from '@spec_utils/Dictionary'
2022
import { Id, Metadata, Name, Username } from '@_types/common'
2123
import { long } from '@_types/Numeric'
24+
import { SortResults } from '@_types/sort'
25+
import { RoleDescriptor } from './RoleDescriptor'
2226

2327
export class ApiKey {
2428
creation?: long
@@ -30,4 +34,8 @@ export class ApiKey {
3034
username?: Username
3135
/** @since 7.13.0 */
3236
metadata?: Metadata
37+
role_descriptors?: Dictionary<string, RoleDescriptor>
38+
/** @since 8.5.0 */
39+
limited_by?: Array<Dictionary<string, RoleDescriptor>>
40+
_sort?: SortResults
3341
}

specification/security/_types/User.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import { Metadata, Name, Username } from '@_types/common'
21+
import { UserProfileId } from './UserProfile'
2122

2223
export class User {
2324
email?: string | null
@@ -26,4 +27,5 @@ export class User {
2627
roles: string[]
2728
username: Username
2829
enabled: boolean
30+
profile_uid?: UserProfileId
2931
}

specification/security/_types/UserProfile.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import { Dictionary } from '@spec_utils/Dictionary'
2121
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
2222
import { Username, Name } from '@_types/common'
23-
import { Metadata } from '@_types/common'
2423
import { long } from '@_types/Numeric'
2524
import { SequenceNumber } from '@_types/common'
2625

specification/security/get_api_key/SecurityGetApiKeyRequest.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,14 @@ export interface Request extends RequestBase {
3232
owner?: boolean
3333
realm_name?: Name
3434
username?: Username
35+
/**
36+
* Return the snapshot of the owner user's role descriptors
37+
* associated with the API key. An API key's actual
38+
* permission is the intersection of its assigned role
39+
* descriptors and the owner user's role descriptors.
40+
* @server_default false
41+
* @since 8.5.0
42+
*/
43+
with_limited_by?: boolean
3544
}
3645
}

specification/security/get_user/SecurityGetUserRequest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@ export interface Request extends RequestBase {
3030
/** An identifier for the user. You can specify multiple usernames as a comma-separated list. If you omit this parameter, the API retrieves information about all users. */
3131
username?: Username | Username[]
3232
}
33+
query_parameters: {
34+
/**
35+
* If true will return the User Profile ID for a user, if any.
36+
* @server_default false
37+
* @since 8.5.0
38+
*/
39+
with_profile_uid?: boolean
40+
}
3341
}

specification/security/get_user_profile/Request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface Request extends RequestBase {
3232
/**
3333
* A unique identifier for the user profile.
3434
*/
35-
uid: UserProfileId
35+
uid: UserProfileId | UserProfileId[]
3636
}
3737
query_parameters: {
3838
/**

specification/security/get_user_profile/Response.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
*/
1919

2020
import { UserProfileWithMetadata } from '@security/_types/UserProfile'
21-
import { Dictionary } from '@spec_utils/Dictionary'
21+
import { GetUserProfileErrors } from './types'
2222

2323
export class Response {
24-
body: Dictionary<string, UserProfileWithMetadata>
24+
body: {
25+
profiles: UserProfileWithMetadata[]
26+
errors?: GetUserProfileErrors
27+
}
2528
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 { UserProfileId } from '@security/_types/UserProfile'
21+
import { Dictionary } from '@spec_utils/Dictionary'
22+
import { ErrorCause } from '@_types/Errors'
23+
import { long } from '@_types/Numeric'
24+
25+
export class GetUserProfileErrors {
26+
count: long
27+
details: Dictionary<UserProfileId, ErrorCause>
28+
}

specification/security/grant_api_key/SecurityGrantApiKeyRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ export interface Request extends RequestBase {
3333
access_token?: string
3434
username?: Username
3535
password?: Password
36+
run_as?: Username
3637
}
3738
}

specification/security/grant_api_key/SecurityGrantApiKeyResponse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ export class Response {
2626
id: Id
2727
name: Name
2828
expiration?: EpochTime<UnitMillis>
29+
encoded: string
2930
}
3031
}

specification/security/grant_api_key/types.ts

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

20+
import { RoleDescriptor } from '@security/_types/RoleDescriptor'
2021
import { Dictionary } from '@spec_utils/Dictionary'
21-
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
22-
import { Name } from '@_types/common'
23-
import { Duration } from '@_types/Time'
22+
import { Metadata, Name } from '@_types/common'
23+
import { DurationLarge } from '@_types/Time'
2424

2525
export class GrantApiKey {
2626
name: Name
27-
expiration?: Duration
28-
role_descriptors?: Dictionary<string, UserDefinedValue>[]
27+
expiration?: DurationLarge
28+
role_descriptors?:
29+
| Dictionary<string, RoleDescriptor>
30+
| Dictionary<string, RoleDescriptor>[]
31+
metadata?: Metadata
2932
}
3033

3134
export enum ApiKeyGrantType {

specification/security/has_privileges_user_profile/Response.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import { UserProfileId } from '@security/_types/UserProfile'
21+
import { HasPrivilegesUserProfileErrors } from './types'
2122

2223
export class Response {
2324
body: {
@@ -32,6 +33,6 @@ export class Response {
3233
* or the profile IDs of the users that do not have all the
3334
* requested privileges. This field is absent if empty.
3435
*/
35-
error_uids?: UserProfileId[]
36+
errors?: HasPrivilegesUserProfileErrors
3637
}
3738
}

specification/security/has_privileges_user_profile/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
*/
1919

2020
import { ClusterPrivilege } from '@security/_types/Privileges'
21+
import { UserProfileId } from '@security/_types/UserProfile'
22+
import { Dictionary } from '@spec_utils/Dictionary'
23+
import { ErrorCause } from '@_types/Errors'
24+
import { long } from '@_types/Numeric'
2125
import {
2226
ApplicationPrivilegesCheck,
2327
IndexPrivilegesCheck
@@ -31,3 +35,8 @@ export class PrivilegesCheck {
3135
cluster?: ClusterPrivilege[]
3236
index?: IndexPrivilegesCheck[]
3337
}
38+
39+
export class HasPrivilegesUserProfileErrors {
40+
count: long
41+
details: Dictionary<UserProfileId, ErrorCause>
42+
}

specification/security/query_api_keys/QueryApiKeysRequest.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ import { Sort, SortResults } from '@_types/sort'
2828
* @stability stable
2929
*/
3030
export interface Request extends RequestBase {
31+
query_parameters: {
32+
/**
33+
* Return the snapshot of the owner user's role descriptors
34+
* associated with the API key. An API key's actual
35+
* permission is the intersection of its assigned role
36+
* descriptors and the owner user's role descriptors.
37+
* @since 8.5.0
38+
*/
39+
with_limited_by?: boolean
40+
}
3141
body: {
3242
/**
3343
* A query to filter which API keys to return.
@@ -48,6 +58,7 @@ export interface Request extends RequestBase {
4858
* The number of hits to return. By default, you cannot page through more
4959
* than 10,000 hits using the from and size parameters. To page through more
5060
* hits, use the search_after parameter.
61+
* @server_default false
5162
* @server_default 10
5263
*/
5364
size?: integer

0 commit comments

Comments
 (0)