putuser

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: 13 Imported by: 0

Documentation

Overview

Create or update users.

Add and update users in the native realm. A password is required for adding a new user but is optional when updating an existing user. To change a user's password without updating any other fields, use the change password API.

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 NewPutUser

type NewPutUser func(username string) *PutUser

NewPutUser type alias for index.

func NewPutUserFunc

func NewPutUserFunc(tp elastictransport.Interface) NewPutUser

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

type PutUser

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

func New

Create or update users.

Add and update users in the native realm. A password is required for adding a new user but is optional when updating an existing user. To change a user's password without updating any other fields, use the change password API.

https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-put-user

func (PutUser) Do

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

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

func (*PutUser) Email

func (r *PutUser) Email(email string) *PutUser

The email of the user. API name: email

func (*PutUser) Enabled

func (r *PutUser) Enabled(enabled bool) *PutUser

Specifies whether the user is enabled. API name: enabled

func (*PutUser) ErrorTrace

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

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

func (*PutUser) FilterPath

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

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

func (*PutUser) FullName

func (r *PutUser) FullName(fullname string) *PutUser

The full name of the user. API name: full_name

func (*PutUser) Header

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

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

func (*PutUser) HttpRequest

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

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

func (*PutUser) Human

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

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

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

Arbitrary metadata that you want to associate with the user. API name: metadata

func (*PutUser) Password

func (r *PutUser) Password(password string) *PutUser

The user's password. Passwords must be at least 6 characters long. When adding a user, one of `password` or `password_hash` is required. When updating an existing user, the password is optional, so that other fields on the user (such as their roles) may be updated without modifying the user's password API name: password

func (*PutUser) PasswordHash

func (r *PutUser) PasswordHash(passwordhash string) *PutUser

A hash of the user's password. This must be produced using the same hashing algorithm as has been configured for password storage. For more details, see the explanation of the `xpack.security.authc.password_hashing.algorithm` setting in the user cache and password hash algorithm documentation. Using this parameter allows the client to pre-hash the password for performance and/or confidentiality reasons. The `password` parameter and the `password_hash` parameter cannot be used in the same request. API name: password_hash

func (PutUser) Perform

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

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

func (*PutUser) Pretty

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

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

func (*PutUser) Raw

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

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

func (*PutUser) Refresh

func (r *PutUser) Refresh(refresh refresh.Refresh) *PutUser

Refresh Valid values are `true`, `false`, and `wait_for`. These values have the same meaning as in the index API, but the default value for this API is true. API name: refresh

func (*PutUser) Request

func (r *PutUser) Request(req *Request) *PutUser

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

func (*PutUser) Roles

func (r *PutUser) Roles(roles ...string) *PutUser

A set of roles the user has. The roles determine the user's access permissions. To create a user without any roles, specify an empty list (`[]`). API name: roles

type Request

type Request struct {

	// Email The email of the user.
	Email *string `json:"email,omitempty"`
	// Enabled Specifies whether the user is enabled.
	Enabled *bool `json:"enabled,omitempty"`
	// FullName The full name of the user.
	FullName *string `json:"full_name,omitempty"`
	// Metadata Arbitrary metadata that you want to associate with the user.
	Metadata types.Metadata `json:"metadata,omitempty"`
	// Password The user's password.
	// Passwords must be at least 6 characters long.
	// When adding a user, one of `password` or `password_hash` is required.
	// When updating an existing user, the password is optional, so that other
	// fields on the user (such as their roles) may be updated without modifying the
	// user's password
	Password *string `json:"password,omitempty"`
	// PasswordHash A hash of the user's password.
	// This must be produced using the same hashing algorithm as has been configured
	// for password storage.
	// For more details, see the explanation of the
	// `xpack.security.authc.password_hashing.algorithm` setting in the user cache
	// and password hash algorithm documentation.
	// Using this parameter allows the client to pre-hash the password for
	// performance and/or confidentiality reasons.
	// The `password` parameter and the `password_hash` parameter cannot be used in
	// the same request.
	PasswordHash *string `json:"password_hash,omitempty"`
	// Roles A set of roles the user has.
	// The roles determine the user's access permissions.
	// To create a user without any roles, specify an empty list (`[]`).
	Roles    []string `json:"roles,omitempty"`
	Username *string  `json:"username,omitempty"`
}

Request holds the request body struct for the package putuser

https://github.com/elastic/elasticsearch-specification/blob/52c473efb1fb5320a5bac12572d0b285882862fb/specification/security/put_user/SecurityPutUserRequest.ts#L23-L101

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 {

	// Created A successful call returns a JSON structure that shows whether the user has
	// been created or updated.
	// When an existing user is updated, `created` is set to `false`.
	Created bool `json:"created"`
}

Response holds the response body struct for the package putuser

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

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