mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-29 09:54:06 -04:00
This PR adds HLRC for the new Query API key API added with #75335 and #76144 Relates: #71023
86 lines
3 KiB
Text
86 lines
3 KiB
Text
--
|
|
:api: query-api-key
|
|
:request: QueryApiKeyRequest
|
|
:response: QueryApiKeyResponse
|
|
--
|
|
[role="xpack"]
|
|
[id="{upid}-{api}"]
|
|
=== Query API Key information API
|
|
|
|
API Key(s) information can be queried and retrieved in a paginated
|
|
fashion using this API.
|
|
|
|
[id="{upid}-{api}-request"]
|
|
==== Query API Key Request
|
|
The +{request}+ supports query and retrieving API key information using
|
|
Elasticsearch's {ref}/query-dsl.html[Query DSL] with
|
|
{ref}/paginate-search-results.html[pagination].
|
|
It supports only a subset of available query types, including:
|
|
|
|
. {ref}/query-dsl-bool-query.html[Boolean query]
|
|
|
|
. {ref}/query-dsl-match-all-query.html[Match all query]
|
|
|
|
. {ref}/query-dsl-term-query.html[Term query]
|
|
|
|
. {ref}/query-dsl-terms-query.html[Terms query]
|
|
|
|
. {ref}/query-dsl-ids-query.html[IDs Query]
|
|
|
|
. {ref}/query-dsl-prefix-query.html[Prefix query]
|
|
|
|
. {ref}/query-dsl-wildcard-query.html[Wildcard query]
|
|
|
|
. {ref}/query-dsl-range-query.html[Range query]
|
|
|
|
===== Query for all API keys
|
|
In its most basic form, the request selects all API keys that the user
|
|
has access to.
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests-file}[query-api-key-default-request]
|
|
--------------------------------------------------
|
|
|
|
===== Query API keys with Query DSL
|
|
The following query selects API keys owned by the user and also satisfy following criteria:
|
|
* The API key name must begin with the word `key`
|
|
* The API key name must *not* be `key-20000`
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests-file}[query-api-key-query-request]
|
|
--------------------------------------------------
|
|
|
|
===== Retrieve API keys with explicitly configured sort and paging
|
|
The following request sort the API keys by their names in descending order.
|
|
It also retrieves the API keys from index 1 (zero-based) and in a page size of 100.
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests-file}[query-api-key-from-size-sort-request]
|
|
--------------------------------------------------
|
|
|
|
===== Deep pagination can be achieved with search after
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests-file}[query-api-key-search-after-request]
|
|
--------------------------------------------------
|
|
|
|
include::../execution.asciidoc[]
|
|
|
|
[id="{upid}-{api}-response"]
|
|
==== Query API Key information API Response
|
|
|
|
The returned +{response}+ contains the information regarding the API keys that were
|
|
requested.
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests-file}[query-api-key-from-size-sort-response]
|
|
--------------------------------------------------
|
|
<1> Total number of API keys matched by the query
|
|
<2> Number of API keys returned in this response
|
|
<3> The list of API keys
|
|
<4> If sorting is requested, each API key in the response contains its sort values.
|