Class: Elastic::EnterpriseSearch::WorkplaceSearch::Client
- Defined in:
- lib/elastic/workplace-search/workplace_search.rb
Overview
The Workplace Search Client Extends EnterpriseSearch client but overrides authentication to use access token.
Constant Summary
Constants included from Utils
Constants inherited from Client
Instance Attribute Summary collapse
-
#kibana_url ⇒ Object
Returns the value of attribute kibana_url.
Instance Method Summary collapse
- #authorization_url(client_id, redirect_uri) ⇒ Object
- #http_auth ⇒ Object
- #http_auth=(access_token) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
Create a new Elastic::EnterpriseSearch::WorkplaceSearch::Client client.
- #request_access_token(client_id, client_secret, authorization_code, redirect_uri) ⇒ Object
Methods included from Utils
#stringify_keys, symbolize_keys
Methods included from Actions
#auto_query_refinement_details, #command_sync_jobs, #content_source, #create_analytics_event, #create_batch_synonym_sets, #create_content_source, #create_external_identity, #current_user, #delete_all_documents, #delete_content_source, #delete_documents, #delete_documents_by_query, #delete_external_identity, #delete_synonym_set, #document, #external_identity, #index_documents, #list_content_sources, #list_documents, #list_external_identities, #list_synonym_sets, #put_content_source, #put_content_source_icons, #put_external_identity, #put_synonym_set, #put_triggers_blocklist, #search, #synonym_set, #triggers_blocklist
Methods inherited from Client
#adapter, #app_search, #host, #log, #logger, #open_timeout, #overall_timeout, #trace, #tracer, #transport, #workplace_search
Methods included from Actions
#health, #put_read_only, #read_only, #search_engines, #stats, #version
Methods included from Request
#basic_auth_header, #delete, #get, #post, #put, #request, #setup_authentication_header
Constructor Details
#initialize(options = {}) ⇒ Client
Create a new Elastic::EnterpriseSearch::WorkplaceSearch::Client client
39 40 41 42 |
# File 'lib/elastic/workplace-search/workplace_search.rb', line 39 def initialize( = {}) @kibana_url = [:kibana_url] super() end |
Instance Attribute Details
#kibana_url ⇒ Object
Returns the value of attribute kibana_url.
30 31 32 |
# File 'lib/elastic/workplace-search/workplace_search.rb', line 30 def kibana_url @kibana_url end |
Instance Method Details
#authorization_url(client_id, redirect_uri) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elastic/workplace-search/workplace_search.rb', line 52 def (client_id, redirect_uri) raise ArgumentError, 'kibana_url The base URL of your Kibana instance must be set in the client' unless kibana_url [ kibana_url, '/app/enterprise_search/workplace_search/p/oauth/authorize?', 'response_type=code&', "client_id=#{client_id}&", "redirect_uri=#{CGI.escape(redirect_uri)}" ].join end |
#http_auth ⇒ Object
44 45 46 |
# File 'lib/elastic/workplace-search/workplace_search.rb', line 44 def http_auth @options[:http_auth] end |
#http_auth=(access_token) ⇒ Object
48 49 50 |
# File 'lib/elastic/workplace-search/workplace_search.rb', line 48 def http_auth=(access_token) @options[:http_auth] = access_token end |
#request_access_token(client_id, client_secret, authorization_code, redirect_uri) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/elastic/workplace-search/workplace_search.rb', line 64 def request_access_token(client_id, client_secret, , redirect_uri) response = request( :post, '/ws/oauth/token', { grant_type: 'authorization_code', client_id: client_id, client_secret: client_secret, redirect_uri: redirect_uri, code: } ) response.body['access_token'] end |