Skip to content

Unify RoleDescriptor, add security.update_api_key API #1787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
606 changes: 366 additions & 240 deletions output/schema/schema.json

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions output/schema/validation-errors.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 36 additions & 24 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@
* under the License.
*/

import {
IndexPrivilege,
ApplicationPrivileges,
IndicesPrivileges,
GlobalPrivilege
} from '@security/_types/Privileges'
import { Indices, Metadata } from '@_types/common'
import { TransientMetadataConfig } from '@security/_types/TransientMetadataConfig'
import { GlobalPrivilege } from './Privileges'
import { IndicesPrivileges } from './Privileges'
import { ApplicationPrivileges } from './Privileges'
import { TransientMetadataConfig } from './TransientMetadataConfig'
import { Metadata } from '@_types/common'
import { OverloadOf } from '@spec_utils/behaviors'

// FIXME: should be merged with get_service_accounts/RoleDescriptor
export class RoleDescriptor {
cluster: string[]
cluster?: string[]
/** @aliases index */
indices: IndicesPrivileges[]
indices?: IndicesPrivileges[]
global?: GlobalPrivilege[] | GlobalPrivilege
applications?: ApplicationPrivileges[]
metadata?: Metadata
run_as?: string[]
transient_metadata?: TransientMetadataConfig
}

export class IndexPrivileges {
names: Indices
privileges: IndexPrivilege[]
export class RoleDescriptorRead implements OverloadOf<RoleDescriptor> {
cluster: string[]
/** @aliases index */
indices: IndicesPrivileges[]
global?: GlobalPrivilege[] | GlobalPrivilege
applications?: ApplicationPrivileges[]
metadata?: Metadata
run_as?: string[]
transient_metadata?: TransientMetadataConfig
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Dictionary } from '@spec_utils/Dictionary'
import { RequestBase } from '@_types/Base'
import { Metadata, Name, Refresh } from '@_types/common'
import { Duration } from '@_types/Time'
import { RoleDescriptor } from './types'
import { RoleDescriptor } from '@security/_types/RoleDescriptor'

/**
* @rest_spec_name security.create_api_key
Expand Down
21 changes: 2 additions & 19 deletions specification/security/get_service_accounts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,8 @@
* under the License.
*/

import {
IndicesPrivileges,
GlobalPrivilege,
ApplicationPrivileges
} from '@security/_types/Privileges'
import { TransientMetadataConfig } from '@security/_types/TransientMetadataConfig'
import { Metadata } from '@_types/common'
import { RoleDescriptorRead } from '@security/_types/RoleDescriptor'

export class RoleDescriptorWrapper {
role_descriptor: RoleDescriptor
}

export class RoleDescriptor {
cluster: string[]
/** @aliases index */
indices: IndicesPrivileges[]
global?: GlobalPrivilege[] | GlobalPrivilege
applications?: ApplicationPrivileges[]
metadata?: Metadata
run_as?: string[]
transient_metadata?: TransientMetadataConfig
role_descriptor: RoleDescriptorRead
}
49 changes: 49 additions & 0 deletions specification/security/update_api_key/Request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 { RequestBase } from '@_types/Base'
import { Id, Metadata } from '@_types/common'
import { Dictionary } from '@spec_utils/Dictionary'
import { RoleDescriptor } from '@security/_types/RoleDescriptor'

/**
* Updates attributes of an existing API key.
* @rest_spec_name security.update_api_key
* @since 8.4.0
* @stability stable
*/
export interface Request extends RequestBase {
path_parts: {
/**
* The ID of the API key to update.
*/
id: Id
}
body: {
/**
* 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.
* @doc_id security-api-put-role
*/
role_descriptors?: Dictionary<string, RoleDescriptor>
/**
* 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.
*/
metadata?: Metadata
}
}
24 changes: 24 additions & 0 deletions specification/security/update_api_key/Response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.
*/

export class Response {
body: {
updated: boolean
}
}