
--
:api: get-service-accounts
:request: GetServiceAccountsRequest
:response: GetServiceAccountsResponse
--
[role="xpack"]
[id="{upid}-{api}"]
=== Get Service Accounts API

[id="{upid}-{api}-request"]
==== Get Service Accounts Request

Retrieving a service account can be performed by setting the namespace
and service-name on +{request}+:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------

Retrieving service accounts belong to a namespace can be performed
by just setting the namespace on +{request}+:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-namespace]
--------------------------------------------------

Retrieving all service accounts can be performed without specifying
either namespace or service-name on +{request}+:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-all]
--------------------------------------------------

include::../execution.asciidoc[]

[id="{upid}-{api}-response"]
==== Get Service Accounts Response

The returned +{response}+ allows getting information about the retrieved service accounts as follows.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> Information for the requested service account
