updateapikey

package
v9.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Update an API key.

Update attributes of an existing API key. This API supports updates to an API key's access scope, expiration, and metadata.

To use this API, you must have at least the `manage_own_api_key` cluster privilege. Users can only update API keys that they created or that were granted to them. To update another user’s API key, use the `run_as` feature to submit a request on behalf of another user.

IMPORTANT: It's not possible to use an API key as the authentication credential for this API. The owner user’s credentials are required.

Use this API to update API keys created by the create API key or grant API Key APIs. If you need to apply the same update to many API keys, you can use the bulk update API keys API to reduce overhead. It's not possible to update expired API keys or API keys that have been invalidated by the invalidate API key API.

The access scope of an API key is derived from the `role_descriptors` you specify in the request and a snapshot of the owner user's permissions at the time of the request. The snapshot of the owner's permissions is updated automatically on every call.

IMPORTANT: If you don't specify `role_descriptors` in the request, a call to this API might still change the API key's access scope. This change can occur if the owner user's permissions have changed since the API key was created or last modified.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

type NewUpdateApiKey

type NewUpdateApiKey func(id string) *UpdateApiKey

NewUpdateApiKey type alias for index.

func NewUpdateApiKeyFunc

func NewUpdateApiKeyFunc(tp elastictransport.Interface) NewUpdateApiKey

NewUpdateApiKeyFunc returns a new instance of UpdateApiKey with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.

type Request

type Request struct {

	// Expiration The expiration time for the API key.
	// By default, API keys never expire.
	// This property can be omitted to leave the expiration unchanged.
	Expiration types.Duration `json:"expiration,omitempty"`
	// Metadata Arbitrary metadata that you want to associate with the API key.
	// It supports a nested data structure.
	// Within the metadata object, keys beginning with `_` are reserved for system
	// usage.
	// When specified, this value fully replaces the metadata previously associated
	// with the API key.
	Metadata types.Metadata `json:"metadata,omitempty"`
	// RoleDescriptors The role descriptors to assign to this API key.
	// The API key's effective permissions are an intersection of its assigned
	// privileges and the point in time snapshot of permissions of the owner user.
	// You can assign new privileges by specifying them in this parameter.
	// To remove assigned privileges, you can supply an empty `role_descriptors`
	// parameter, that is to say, an empty object `{}`.
	// If an API key has no assigned privileges, it inherits the owner user's full
	// permissions.
	// The snapshot of the owner's permissions is always updated, whether you supply
	// the `role_descriptors` parameter or not.
	// The structure of a role descriptor is the same as the request for the create
	// API keys API.
	RoleDescriptors map[string]types.RoleDescriptor `json:"role_descriptors,omitempty"`
}

Request holds the request body struct for the package updateapikey

https://github.com/elastic/elasticsearch-specification/blob/52c473efb1fb5320a5bac12572d0b285882862fb/specification/security/update_api_key/Request.ts#L26-L91

func NewRequest

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON

func (s *Request) UnmarshalJSON(data []byte) error

type Response

type Response struct {

	// Updated If `true`, the API key was updated.
	// If `false`, the API key didn't change because no change was detected.
	Updated bool `json:"updated"`
}

Response holds the response body struct for the package updateapikey

https://github.com/elastic/elasticsearch-specification/blob/52c473efb1fb5320a5bac12572d0b285882862fb/specification/security/update_api_key/Response.ts#L20-L28

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

type UpdateApiKey

type UpdateApiKey struct {
	// contains filtered or unexported fields
}

func New

Update an API key.

Update attributes of an existing API key. This API supports updates to an API key's access scope, expiration, and metadata.

To use this API, you must have at least the `manage_own_api_key` cluster privilege. Users can only update API keys that they created or that were granted to them. To update another user’s API key, use the `run_as` feature to submit a request on behalf of another user.

IMPORTANT: It's not possible to use an API key as the authentication credential for this API. The owner user’s credentials are required.

Use this API to update API keys created by the create API key or grant API Key APIs. If you need to apply the same update to many API keys, you can use the bulk update API keys API to reduce overhead. It's not possible to update expired API keys or API keys that have been invalidated by the invalidate API key API.

The access scope of an API key is derived from the `role_descriptors` you specify in the request and a snapshot of the owner user's permissions at the time of the request. The snapshot of the owner's permissions is updated automatically on every call.

IMPORTANT: If you don't specify `role_descriptors` in the request, a call to this API might still change the API key's access scope. This change can occur if the owner user's permissions have changed since the API key was created or last modified.

https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-update-api-key

func (*UpdateApiKey) AddRoleDescriptor

func (r *UpdateApiKey) AddRoleDescriptor(key string, value types.RoleDescriptorVariant) *UpdateApiKey

func (UpdateApiKey) Do

func (r UpdateApiKey) Do(providedCtx context.Context) (*Response, error)

Do runs the request through the transport, handle the response and returns a updateapikey.Response

func (*UpdateApiKey) ErrorTrace

func (r *UpdateApiKey) ErrorTrace(errortrace bool) *UpdateApiKey

ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errors when they occur. API name: error_trace

func (*UpdateApiKey) Expiration

func (r *UpdateApiKey) Expiration(duration types.DurationVariant) *UpdateApiKey

The expiration time for the API key. By default, API keys never expire. This property can be omitted to leave the expiration unchanged. API name: expiration

func (*UpdateApiKey) FilterPath

func (r *UpdateApiKey) FilterPath(filterpaths ...string) *UpdateApiKey

FilterPath Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch. API name: filter_path

func (*UpdateApiKey) Header

func (r *UpdateApiKey) Header(key, value string) *UpdateApiKey

Header set a key, value pair in the UpdateApiKey headers map.

func (*UpdateApiKey) HttpRequest

func (r *UpdateApiKey) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*UpdateApiKey) Human

func (r *UpdateApiKey) Human(human bool) *UpdateApiKey

Human When set to `true` will return statistics in a format suitable for humans. For example `"exists_time": "1h"` for humans and `"eixsts_time_in_millis": 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. API name: human

func (*UpdateApiKey) Metadata

func (r *UpdateApiKey) Metadata(metadata types.MetadataVariant) *UpdateApiKey

Arbitrary metadata that you want to associate with the API key. It supports a nested data structure. Within the metadata object, keys beginning with `_` are reserved for system usage. When specified, this value fully replaces the metadata previously associated with the API key. API name: metadata

func (UpdateApiKey) Perform

func (r UpdateApiKey) Perform(providedCtx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*UpdateApiKey) Pretty

func (r *UpdateApiKey) Pretty(pretty bool) *UpdateApiKey

Pretty If set to `true` the returned JSON will be "pretty-formatted". Only use this option for debugging only. API name: pretty

func (*UpdateApiKey) Raw

func (r *UpdateApiKey) Raw(raw io.Reader) *UpdateApiKey

Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.

func (*UpdateApiKey) Request

func (r *UpdateApiKey) Request(req *Request) *UpdateApiKey

Request allows to set the request property with the appropriate payload.

func (*UpdateApiKey) RoleDescriptors

func (r *UpdateApiKey) RoleDescriptors(roledescriptors map[string]types.RoleDescriptor) *UpdateApiKey

The role descriptors to assign to this API key. The API key's effective permissions are an intersection of its assigned privileges and the point in time snapshot of permissions of the owner user. You can assign new privileges by specifying them in this parameter. To remove assigned privileges, you can supply an empty `role_descriptors` parameter, that is to say, an empty object `{}`. If an API key has no assigned privileges, it inherits the owner user's full permissions. The snapshot of the owner's permissions is always updated, whether you supply the `role_descriptors` parameter or not. The structure of a role descriptor is the same as the request for the create API keys API. API name: role_descriptors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL