createcrossclusterapikey

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

Create a cross-cluster API key.

Create an API key of the `cross_cluster` type for the API key based remote cluster access. A `cross_cluster` API key cannot be used to authenticate through the REST interface.

IMPORTANT: To authenticate this request you must use a credential that is not an API key. Even if you use an API key that has the required privilege, the API returns an error.

Cross-cluster API keys are created by the Elasticsearch API key service, which is automatically enabled.

NOTE: Unlike REST API keys, a cross-cluster API key does not capture permissions of the authenticated user. The API key’s effective permission is exactly as specified with the `access` property.

A successful request returns a JSON structure that contains the API key, its unique ID, and its name. If applicable, it also returns expiration information for the API key in milliseconds.

By default, API keys never expire. You can specify expiration information when you create the API keys.

Cross-cluster API keys can only be updated with the update cross-cluster API key API. Attempting to update them with the update REST API key API or the bulk update REST API keys API will result in an error.

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 CreateCrossClusterApiKey

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

func New

Create a cross-cluster API key.

Create an API key of the `cross_cluster` type for the API key based remote cluster access. A `cross_cluster` API key cannot be used to authenticate through the REST interface.

IMPORTANT: To authenticate this request you must use a credential that is not an API key. Even if you use an API key that has the required privilege, the API returns an error.

Cross-cluster API keys are created by the Elasticsearch API key service, which is automatically enabled.

NOTE: Unlike REST API keys, a cross-cluster API key does not capture permissions of the authenticated user. The API key’s effective permission is exactly as specified with the `access` property.

A successful request returns a JSON structure that contains the API key, its unique ID, and its name. If applicable, it also returns expiration information for the API key in milliseconds.

By default, API keys never expire. You can specify expiration information when you create the API keys.

Cross-cluster API keys can only be updated with the update cross-cluster API key API. Attempting to update them with the update REST API key API or the bulk update REST API keys API will result in an error.

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

func (*CreateCrossClusterApiKey) Access

The access to be granted to this API key. The access is composed of permissions for cross-cluster search and cross-cluster replication. At least one of them must be specified.

NOTE: No explicit privileges should be specified for either search or replication access. The creation process automatically converts the access specification to a role descriptor which has relevant privileges assigned accordingly. API name: access

func (CreateCrossClusterApiKey) Do

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

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

func (*CreateCrossClusterApiKey) ErrorTrace

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

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

func (*CreateCrossClusterApiKey) Expiration

Expiration time for the API key. By default, API keys never expire. API name: expiration

func (*CreateCrossClusterApiKey) FilterPath

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

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

func (*CreateCrossClusterApiKey) Header

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

func (*CreateCrossClusterApiKey) HttpRequest

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

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

func (*CreateCrossClusterApiKey) Human

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 (*CreateCrossClusterApiKey) Metadata

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. API name: metadata

func (*CreateCrossClusterApiKey) Name

Specifies the name for this API key. API name: name

func (CreateCrossClusterApiKey) Perform

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

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

func (*CreateCrossClusterApiKey) Pretty

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

func (*CreateCrossClusterApiKey) Raw

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

func (*CreateCrossClusterApiKey) Request

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

type NewCreateCrossClusterApiKey

type NewCreateCrossClusterApiKey func() *CreateCrossClusterApiKey

NewCreateCrossClusterApiKey type alias for index.

func NewCreateCrossClusterApiKeyFunc

func NewCreateCrossClusterApiKeyFunc(tp elastictransport.Interface) NewCreateCrossClusterApiKey

NewCreateCrossClusterApiKeyFunc returns a new instance of CreateCrossClusterApiKey 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 {

	// Access The access to be granted to this API key.
	// The access is composed of permissions for cross-cluster search and
	// cross-cluster replication.
	// At least one of them must be specified.
	//
	// NOTE: No explicit privileges should be specified for either search or
	// replication access.
	// The creation process automatically converts the access specification to a
	// role descriptor which has relevant privileges assigned accordingly.
	Access types.Access `json:"access"`
	// Expiration Expiration time for the API key.
	// By default, API keys never expire.
	Expiration types.Duration `json:"expiration,omitempty"`
	// Metadata 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 types.Metadata `json:"metadata,omitempty"`
	// Name Specifies the name for this API key.
	Name string `json:"name"`
}

Request holds the request body struct for the package createcrossclusterapikey

https://github.com/elastic/elasticsearch-specification/blob/52c473efb1fb5320a5bac12572d0b285882862fb/specification/security/create_cross_cluster_api_key/CreateCrossClusterApiKeyRequest.ts#L25-L80

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 {

	// ApiKey Generated API key.
	ApiKey string `json:"api_key"`
	// Encoded API key credentials which is the base64-encoding of
	// the UTF-8 representation of `id` and `api_key` joined
	// by a colon (`:`).
	Encoded string `json:"encoded"`
	// Expiration Expiration in milliseconds for the API key.
	Expiration *int64 `json:"expiration,omitempty"`
	// Id Unique ID for this API key.
	Id string `json:"id"`
	// Name Specifies the name for this API key.
	Name string `json:"name"`
}

Response holds the response body struct for the package createcrossclusterapikey

https://github.com/elastic/elasticsearch-specification/blob/52c473efb1fb5320a5bac12572d0b285882862fb/specification/security/create_cross_cluster_api_key/CreateCrossClusterApiKeyResponse.ts#L23-L48

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

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