queryrole

package
v8.18.1 Latest Latest
Warning

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

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

Documentation

Overview

Find roles with a query.

Get roles in a paginated manner. The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. The query roles API does not retrieve roles that are defined in roles files, nor built-in ones. You can optionally filter the results with a query. Also, the results can be paginated and sorted.

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 NewQueryRole

type NewQueryRole func() *QueryRole

NewQueryRole type alias for index.

func NewQueryRoleFunc

func NewQueryRoleFunc(tp elastictransport.Interface) NewQueryRole

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

type QueryRole

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

func New

Find roles with a query.

Get roles in a paginated manner. The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. The query roles API does not retrieve roles that are defined in roles files, nor built-in ones. You can optionally filter the results with a query. Also, the results can be paginated and sorted.

https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-role.html

func (QueryRole) Do

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

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

func (*QueryRole) ErrorTrace

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

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

func (*QueryRole) FilterPath

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

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

func (*QueryRole) From

func (r *QueryRole) From(from int) *QueryRole

From The starting document offset. It must not be negative. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. API name: from

func (*QueryRole) Header

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

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

func (*QueryRole) HttpRequest

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

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

func (*QueryRole) Human

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

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 (QueryRole) Perform

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

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

func (*QueryRole) Pretty

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

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

func (*QueryRole) Query

func (r *QueryRole) Query(query *types.RoleQueryContainer) *QueryRole

Query A query to filter which roles to return. If the query parameter is missing, it is equivalent to a `match_all` query. The query supports a subset of query types, including `match_all`, `bool`, `term`, `terms`, `match`, `ids`, `prefix`, `wildcard`, `exists`, `range`, and `simple_query_string`. You can query the following information associated with roles: `name`, `description`, `metadata`, `applications.application`, `applications.privileges`, and `applications.resources`. API name: query

func (*QueryRole) Raw

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

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

func (*QueryRole) Request

func (r *QueryRole) Request(req *Request) *QueryRole

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

func (*QueryRole) SearchAfter

func (r *QueryRole) SearchAfter(sortresults ...types.FieldValue) *QueryRole

SearchAfter The search after definition. API name: search_after

func (*QueryRole) Size

func (r *QueryRole) Size(size int) *QueryRole

Size The number of hits to return. It must not be negative. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. API name: size

func (*QueryRole) Sort

func (r *QueryRole) Sort(sorts ...types.SortCombinations) *QueryRole

Sort The sort definition. You can sort on `username`, `roles`, or `enabled`. In addition, sort can also be applied to the `_doc` field to sort by index order. API name: sort

type Request

type Request struct {

	// From The starting document offset.
	// It must not be negative.
	// By default, you cannot page through more than 10,000 hits using the `from`
	// and `size` parameters.
	// To page through more hits, use the `search_after` parameter.
	From *int `json:"from,omitempty"`
	// Query A query to filter which roles to return.
	// If the query parameter is missing, it is equivalent to a `match_all` query.
	// The query supports a subset of query types, including `match_all`, `bool`,
	// `term`, `terms`, `match`,
	// `ids`, `prefix`, `wildcard`, `exists`, `range`, and `simple_query_string`.
	// You can query the following information associated with roles: `name`,
	// `description`, `metadata`,
	// `applications.application`, `applications.privileges`, and
	// `applications.resources`.
	Query *types.RoleQueryContainer `json:"query,omitempty"`
	// SearchAfter The search after definition.
	SearchAfter []types.FieldValue `json:"search_after,omitempty"`
	// Size The number of hits to return.
	// It must not be negative.
	// By default, you cannot page through more than 10,000 hits using the `from`
	// and `size` parameters.
	// To page through more hits, use the `search_after` parameter.
	Size *int `json:"size,omitempty"`
	// Sort The sort definition.
	// You can sort on `username`, `roles`, or `enabled`.
	// In addition, sort can also be applied to the `_doc` field to sort by index
	// order.
	Sort []types.SortCombinations `json:"sort,omitempty"`
}

Request holds the request body struct for the package queryrole

https://github.com/elastic/elasticsearch-specification/blob/3a94b6715915b1e9311724a2614c643368eece90/specification/security/query_role/QueryRolesRequest.ts#L25-L85

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 {

	// Count The number of roles returned in the response.
	Count int `json:"count"`
	// Roles A list of roles that match the query.
	// The returned role format is an extension of the role definition format.
	// It adds the `transient_metadata.enabled` and the `_sort` fields.
	// `transient_metadata.enabled` is set to `false` in case the role is
	// automatically disabled, for example when the role grants privileges that are
	// not allowed by the installed license.
	// `_sort` is present when the search query sorts on some field.
	// It contains the array of values that have been used for sorting.
	Roles []types.QueryRole `json:"roles"`
	// Total The total number of roles found.
	Total int `json:"total"`
}

Response holds the response body struct for the package queryrole

https://github.com/elastic/elasticsearch-specification/blob/3a94b6715915b1e9311724a2614c643368eece90/specification/security/query_role/QueryRolesResponse.ts#L23-L43

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