module Elasticsearch::XPack::API::Security::Actions

Public Instance Methods

authenticate(arguments = {}) click to toggle source

Enables authentication as a user and retrieve information about the authenticated user.

@option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-authenticate.html

# File lib/elasticsearch/xpack/api/actions/security/authenticate.rb, line 29
def authenticate(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = "_security/_authenticate"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
change_password(arguments = {}) click to toggle source

Changes the passwords of users in the native realm and built-in users.

@option arguments [String] :username The username of the user to change the password for @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body the new password for the user (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-change-password.html

# File lib/elasticsearch/xpack/api/actions/security/change_password.rb, line 32
def change_password(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _username = arguments.delete(:username)

  method = Elasticsearch::API::HTTP_PUT
  path   = if _username
             "_security/user/#{Elasticsearch::API::Utils.__listify(_username)}/_password"
           else
             "_security/user/_password"
           end
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
clear_api_key_cache(arguments = {}) click to toggle source

Clear a subset or all entries from the API key cache.

@option arguments [List] :ids A comma-separated list of IDs of API keys to clear from the cache @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-clear-api-key-cache.html

# File lib/elasticsearch/xpack/api/actions/security/clear_api_key_cache.rb, line 30
def clear_api_key_cache(arguments = {})
  raise ArgumentError, "Required argument 'ids' missing" unless arguments[:ids]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _ids = arguments.delete(:ids)

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/api_key/#{Elasticsearch::API::Utils.__listify(_ids)}/_clear_cache"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
clear_cached_privileges(arguments = {}) click to toggle source

Evicts application privileges from the native application privileges cache.

@option arguments [List] :application A comma-separated list of application names @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-clear-privilege-cache.html

# File lib/elasticsearch/xpack/api/actions/security/clear_cached_privileges.rb, line 30
def clear_cached_privileges(arguments = {})
  raise ArgumentError, "Required argument 'application' missing" unless arguments[:application]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _application = arguments.delete(:application)

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/privilege/#{Elasticsearch::API::Utils.__listify(_application)}/_clear_cache"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
clear_cached_realms(arguments = {}) click to toggle source

Evicts users from the user cache. Can completely clear the cache or evict specific users.

@option arguments [List] :realms Comma-separated list of realms to clear @option arguments [List] :usernames Comma-separated list of usernames to clear from the cache @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-clear-cache.html

# File lib/elasticsearch/xpack/api/actions/security/clear_cached_realms.rb, line 31
def clear_cached_realms(arguments = {})
  raise ArgumentError, "Required argument 'realms' missing" unless arguments[:realms]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _realms = arguments.delete(:realms)

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/realm/#{Elasticsearch::API::Utils.__listify(_realms)}/_clear_cache"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
clear_cached_roles(arguments = {}) click to toggle source

Evicts roles from the native role cache.

@option arguments [List] :name Role name @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-clear-role-cache.html

# File lib/elasticsearch/xpack/api/actions/security/clear_cached_roles.rb, line 30
def clear_cached_roles(arguments = {})
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/role/#{Elasticsearch::API::Utils.__listify(_name)}/_clear_cache"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
clear_cached_service_tokens(arguments = {}) click to toggle source

Evicts tokens from the service account token caches. This functionality is in Beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

@option arguments [String] :namespace An identifier for the namespace @option arguments [String] :service An identifier for the service name @option arguments [List] :name A comma-separated list of service token names @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-clear-service-token-caches.html

# File lib/elasticsearch/xpack/api/actions/security/clear_cached_service_tokens.rb, line 36
def clear_cached_service_tokens(arguments = {})
  raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace]
  raise ArgumentError, "Required argument 'service' missing" unless arguments[:service]
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _namespace = arguments.delete(:namespace)

  _service = arguments.delete(:service)

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/service/#{Elasticsearch::API::Utils.__listify(_namespace)}/#{Elasticsearch::API::Utils.__listify(_service)}/credential/token/#{Elasticsearch::API::Utils.__listify(_name)}/_clear_cache"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
create_api_key(arguments = {}) click to toggle source

Creates an API key for access without requiring basic authentication.

@option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The api key request to create an API key (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-create-api-key.html

# File lib/elasticsearch/xpack/api/actions/security/create_api_key.rb, line 31
def create_api_key(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_PUT
  path   = "_security/api_key"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
create_service_token(arguments = {}) click to toggle source

Creates a service account token for access without requiring basic authentication. This functionality is in Beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

@option arguments [String] :namespace An identifier for the namespace @option arguments [String] :service An identifier for the service name @option arguments [String] :name An identifier for the token name @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-create-service-token.html

# File lib/elasticsearch/xpack/api/actions/security/create_service_token.rb, line 37
def create_service_token(arguments = {})
  raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace]
  raise ArgumentError, "Required argument 'service' missing" unless arguments[:service]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _namespace = arguments.delete(:namespace)

  _service = arguments.delete(:service)

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_PUT
  path   = if _namespace && _service && _name
             "_security/service/#{Elasticsearch::API::Utils.__listify(_namespace)}/#{Elasticsearch::API::Utils.__listify(_service)}/credential/token/#{Elasticsearch::API::Utils.__listify(_name)}"
           else
             "_security/service/#{Elasticsearch::API::Utils.__listify(_namespace)}/#{Elasticsearch::API::Utils.__listify(_service)}/credential/token"
           end
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
delete_privileges(arguments = {}) click to toggle source

Removes application privileges.

@option arguments [String] :application Application name @option arguments [String] :name Privilege name @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-delete-privilege.html

# File lib/elasticsearch/xpack/api/actions/security/delete_privileges.rb, line 32
def delete_privileges(arguments = {})
  raise ArgumentError, "Required argument 'application' missing" unless arguments[:application]
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _application = arguments.delete(:application)

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_security/privilege/#{Elasticsearch::API::Utils.__listify(_application)}/#{Elasticsearch::API::Utils.__listify(_name)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
delete_role(arguments = {}) click to toggle source

Removes roles in the native realm.

@option arguments [String] :name Role name @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-delete-role.html

# File lib/elasticsearch/xpack/api/actions/security/delete_role.rb, line 31
def delete_role(arguments = {})
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_security/role/#{Elasticsearch::API::Utils.__listify(_name)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
delete_role_mapping(arguments = {}) click to toggle source

Removes role mappings.

@option arguments [String] :name Role-mapping name @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-delete-role-mapping.html

# File lib/elasticsearch/xpack/api/actions/security/delete_role_mapping.rb, line 31
def delete_role_mapping(arguments = {})
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_security/role_mapping/#{Elasticsearch::API::Utils.__listify(_name)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
delete_service_token(arguments = {}) click to toggle source

Deletes a service account token. This functionality is in Beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

@option arguments [String] :namespace An identifier for the namespace @option arguments [String] :service An identifier for the service name @option arguments [String] :name An identifier for the token name @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-delete-service-token.html

# File lib/elasticsearch/xpack/api/actions/security/delete_service_token.rb, line 37
def delete_service_token(arguments = {})
  raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace]
  raise ArgumentError, "Required argument 'service' missing" unless arguments[:service]
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _namespace = arguments.delete(:namespace)

  _service = arguments.delete(:service)

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_security/service/#{Elasticsearch::API::Utils.__listify(_namespace)}/#{Elasticsearch::API::Utils.__listify(_service)}/credential/token/#{Elasticsearch::API::Utils.__listify(_name)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
delete_user(arguments = {}) click to toggle source

Deletes users from the native realm.

@option arguments [String] :username username @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-delete-user.html

# File lib/elasticsearch/xpack/api/actions/security/delete_user.rb, line 31
def delete_user(arguments = {})
  raise ArgumentError, "Required argument 'username' missing" unless arguments[:username]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _username = arguments.delete(:username)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_security/user/#{Elasticsearch::API::Utils.__listify(_username)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
disable_user(arguments = {}) click to toggle source

Disables users in the native realm.

@option arguments [String] :username The username of the user to disable @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-disable-user.html

# File lib/elasticsearch/xpack/api/actions/security/disable_user.rb, line 31
def disable_user(arguments = {})
  raise ArgumentError, "Required argument 'username' missing" unless arguments[:username]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _username = arguments.delete(:username)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_security/user/#{Elasticsearch::API::Utils.__listify(_username)}/_disable"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
enable_user(arguments = {}) click to toggle source

Enables users in the native realm.

@option arguments [String] :username The username of the user to enable @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-enable-user.html

# File lib/elasticsearch/xpack/api/actions/security/enable_user.rb, line 31
def enable_user(arguments = {})
  raise ArgumentError, "Required argument 'username' missing" unless arguments[:username]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _username = arguments.delete(:username)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_security/user/#{Elasticsearch::API::Utils.__listify(_username)}/_enable"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_api_key(arguments = {}) click to toggle source

Retrieves information for one or more API keys.

@option arguments [String] :id API key id of the API key to be retrieved @option arguments [String] :name API key name of the API key to be retrieved @option arguments [String] :username user name of the user who created this API key to be retrieved @option arguments [String] :realm_name realm name of the user who created this API key to be retrieved @option arguments [Boolean] :owner flag to query API keys owned by the currently authenticated user @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-api-key.html

# File lib/elasticsearch/xpack/api/actions/security/get_api_key.rb, line 34
def get_api_key(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = "_security/api_key"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_builtin_privileges(arguments = {}) click to toggle source

Retrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch.

@option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-builtin-privileges.html

# File lib/elasticsearch/xpack/api/actions/security/get_builtin_privileges.rb, line 29
def get_builtin_privileges(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = "_security/privilege/_builtin"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_privileges(arguments = {}) click to toggle source

Retrieves application privileges.

@option arguments [String] :application Application name @option arguments [String] :name Privilege name @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-privileges.html

# File lib/elasticsearch/xpack/api/actions/security/get_privileges.rb, line 31
def get_privileges(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _application = arguments.delete(:application)

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_GET
  path   = if _application && _name
             "_security/privilege/#{Elasticsearch::API::Utils.__listify(_application)}/#{Elasticsearch::API::Utils.__listify(_name)}"
           elsif _application
             "_security/privilege/#{Elasticsearch::API::Utils.__listify(_application)}"
           else
             "_security/privilege"
           end
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_role(arguments = {}) click to toggle source

Retrieves roles in the native realm.

@option arguments [List] :name A comma-separated list of role names @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-role.html

# File lib/elasticsearch/xpack/api/actions/security/get_role.rb, line 30
def get_role(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_GET
  path   = if _name
             "_security/role/#{Elasticsearch::API::Utils.__listify(_name)}"
           else
             "_security/role"
           end
  params = {}

  body = nil
  if Array(arguments[:ignore]).include?(404)
    Elasticsearch::API::Utils.__rescue_from_not_found {
      perform_request(method, path, params, body, headers).body
    }
  else
    perform_request(method, path, params, body, headers).body
  end
end
get_role_mapping(arguments = {}) click to toggle source

Retrieves role mappings.

@option arguments [List] :name A comma-separated list of role-mapping names @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-role-mapping.html

# File lib/elasticsearch/xpack/api/actions/security/get_role_mapping.rb, line 30
def get_role_mapping(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_GET
  path   = if _name
             "_security/role_mapping/#{Elasticsearch::API::Utils.__listify(_name)}"
           else
             "_security/role_mapping"
           end
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_service_accounts(arguments = {}) click to toggle source

Retrieves information about service accounts. This functionality is in Beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

@option arguments [String] :namespace An identifier for the namespace @option arguments [String] :service An identifier for the service name @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-service-accounts.html

# File lib/elasticsearch/xpack/api/actions/security/get_service_accounts.rb, line 35
def get_service_accounts(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _namespace = arguments.delete(:namespace)

  _service = arguments.delete(:service)

  method = Elasticsearch::API::HTTP_GET
  path   = if _namespace && _service
             "_security/service/#{Elasticsearch::API::Utils.__listify(_namespace)}/#{Elasticsearch::API::Utils.__listify(_service)}"
           elsif _namespace
             "_security/service/#{Elasticsearch::API::Utils.__listify(_namespace)}"
           else
             "_security/service"
           end
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_service_credentials(arguments = {}) click to toggle source

Retrieves information of all service credentials for a service account. This functionality is in Beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

@option arguments [String] :namespace An identifier for the namespace @option arguments [String] :service An identifier for the service name @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-service-credentials.html

# File lib/elasticsearch/xpack/api/actions/security/get_service_credentials.rb, line 35
def get_service_credentials(arguments = {})
  raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace]
  raise ArgumentError, "Required argument 'service' missing" unless arguments[:service]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _namespace = arguments.delete(:namespace)

  _service = arguments.delete(:service)

  method = Elasticsearch::API::HTTP_GET
  path   = "_security/service/#{Elasticsearch::API::Utils.__listify(_namespace)}/#{Elasticsearch::API::Utils.__listify(_service)}/credential"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
get_token(arguments = {}) click to toggle source

Creates a bearer token for access without requiring basic authentication.

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The token request to get (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-token.html

# File lib/elasticsearch/xpack/api/actions/security/get_token.rb, line 30
def get_token(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/oauth2/token"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
get_user(arguments = {}) click to toggle source

Retrieves information about users in the native realm and built-in users.

@option arguments [List] :username A comma-separated list of usernames @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-user.html

# File lib/elasticsearch/xpack/api/actions/security/get_user.rb, line 30
def get_user(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _username = arguments.delete(:username)

  method = Elasticsearch::API::HTTP_GET
  path   = if _username
             "_security/user/#{Elasticsearch::API::Utils.__listify(_username)}"
           else
             "_security/user"
           end
  params = {}

  body = nil
  if Array(arguments[:ignore]).include?(404)
    Elasticsearch::API::Utils.__rescue_from_not_found {
      perform_request(method, path, params, body, headers).body
    }
  else
    perform_request(method, path, params, body, headers).body
  end
end
get_user_privileges(arguments = {}) click to toggle source

Retrieves security privileges for the logged in user.

@option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-get-user-privileges.html

# File lib/elasticsearch/xpack/api/actions/security/get_user_privileges.rb, line 29
def get_user_privileges(arguments = {})
  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = "_security/user/_privileges"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end
grant_api_key(arguments = {}) click to toggle source

Creates an API key on behalf of another user.

@option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The api key request to create an API key (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-grant-api-key.html

# File lib/elasticsearch/xpack/api/actions/security/grant_api_key.rb, line 31
def grant_api_key(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/api_key/grant"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
has_privileges(arguments = {}) click to toggle source

Determines whether the specified user has a specified list of privileges.

@option arguments [String] :user Username @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The privileges to test (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-has-privileges.html

# File lib/elasticsearch/xpack/api/actions/security/has_privileges.rb, line 31
def has_privileges(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _user = arguments.delete(:user)

  method = Elasticsearch::API::HTTP_POST
  path   = if _user
             "_security/user/#{Elasticsearch::API::Utils.__listify(_user)}/_has_privileges"
           else
             "_security/user/_has_privileges"
           end
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
invalidate_api_key(arguments = {}) click to toggle source

Invalidates one or more API keys.

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The api key request to invalidate API key(s) (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-invalidate-api-key.html

# File lib/elasticsearch/xpack/api/actions/security/invalidate_api_key.rb, line 30
def invalidate_api_key(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_security/api_key"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
invalidate_token(arguments = {}) click to toggle source

Invalidates one or more access tokens or refresh tokens.

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The token to invalidate (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-invalidate-token.html

# File lib/elasticsearch/xpack/api/actions/security/invalidate_token.rb, line 30
def invalidate_token(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_security/oauth2/token"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
put_privileges(arguments = {}) click to toggle source

Adds or updates application privileges.

@option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The privilege(s) to add (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-put-privileges.html

# File lib/elasticsearch/xpack/api/actions/security/put_privileges.rb, line 31
def put_privileges(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_PUT
  path   = "_security/privilege"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
put_role(arguments = {}) click to toggle source

Adds and updates roles in the native realm.

@option arguments [String] :name Role name @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The role to add (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-put-role.html

# File lib/elasticsearch/xpack/api/actions/security/put_role.rb, line 32
def put_role(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_security/role/#{Elasticsearch::API::Utils.__listify(_name)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
put_role_mapping(arguments = {}) click to toggle source

Creates and updates role mappings.

@option arguments [String] :name Role-mapping name @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The role mapping to add (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-put-role-mapping.html

# File lib/elasticsearch/xpack/api/actions/security/put_role_mapping.rb, line 32
def put_role_mapping(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _name = arguments.delete(:name)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_security/role_mapping/#{Elasticsearch::API::Utils.__listify(_name)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
put_user(arguments = {}) click to toggle source

Adds and updates users in the native realm. These users are commonly referred to as native users.

@option arguments [String] :username The username of the User @option arguments [String] :refresh If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The user to add (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-put-user.html

# File lib/elasticsearch/xpack/api/actions/security/put_user.rb, line 32
def put_user(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'username' missing" unless arguments[:username]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _username = arguments.delete(:username)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_security/user/#{Elasticsearch::API::Utils.__listify(_username)}"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
saml_authenticate(arguments = {}) click to toggle source

Exchanges a SAML Response message for an Elasticsearch access token and refresh token pair

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The SAML response to authenticate (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-saml-authenticate.html

# File lib/elasticsearch/xpack/api/actions/security/saml_authenticate.rb, line 30
def saml_authenticate(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/saml/authenticate"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
saml_complete_logout(arguments = {}) click to toggle source

Verifies the logout response sent from the SAML IdP

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The logout response to verify (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-saml-complete-logout.html

# File lib/elasticsearch/xpack/api/actions/security/saml_complete_logout.rb, line 30
def saml_complete_logout(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/saml/complete_logout"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
saml_invalidate(arguments = {}) click to toggle source

Consumes a SAML LogoutRequest

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The LogoutRequest message (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-saml-invalidate.html

# File lib/elasticsearch/xpack/api/actions/security/saml_invalidate.rb, line 30
def saml_invalidate(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/saml/invalidate"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
saml_logout(arguments = {}) click to toggle source

Invalidates an access token and a refresh token that were generated via the SAML Authenticate API

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The tokens to invalidate (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-saml-logout.html

# File lib/elasticsearch/xpack/api/actions/security/saml_logout.rb, line 30
def saml_logout(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/saml/logout"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
saml_prepare_authentication(arguments = {}) click to toggle source

Creates a SAML authentication request

@option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The realm for which to create the authentication request, identified by either its name or the ACS URL (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-saml-prepare-authentication.html

# File lib/elasticsearch/xpack/api/actions/security/saml_prepare_authentication.rb, line 30
def saml_prepare_authentication(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_security/saml/prepare"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body, headers).body
end
saml_service_provider_metadata(arguments = {}) click to toggle source

Generates SAML metadata for the Elastic stack SAML 2.0 Service Provider

@option arguments [String] :realm_name The name of the SAML realm to get the metadata for @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/7.14/security-api-saml-sp-metadata.html

# File lib/elasticsearch/xpack/api/actions/security/saml_service_provider_metadata.rb, line 30
def saml_service_provider_metadata(arguments = {})
  raise ArgumentError, "Required argument 'realm_name' missing" unless arguments[:realm_name]

  headers = arguments.delete(:headers) || {}

  arguments = arguments.clone

  _realm_name = arguments.delete(:realm_name)

  method = Elasticsearch::API::HTTP_GET
  path   = "_security/saml/metadata/#{Elasticsearch::API::Utils.__listify(_realm_name)}"
  params = {}

  body = nil
  perform_request(method, path, params, body, headers).body
end