From 3f6c1bf20a572dce9c4b352bf03d514c7d6194ed Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 17 Nov 2022 12:27:17 +0000 Subject: [PATCH] [API] Updates create_service_token with generated code --- .../api/actions/security/create_service_token.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb index 204c65094e..2161c95503 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb @@ -47,13 +47,12 @@ def create_service_token(arguments = {}) _name = arguments.delete(:name) - if _namespace && _service && _name - method = Elasticsearch::API::HTTP_PUT - path = "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token/#{Utils.__listify(_name)}" - else - method = Elasticsearch::API::HTTP_POST - path = "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token" - end + method = _name ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST + path = if _namespace && _service && _name + "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token/#{Utils.__listify(_name)}" + else + "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token" + end params = Utils.process_params(arguments) Elasticsearch::API::Response.new(