Skip to content

Commit

Permalink
feat(clients): helper to switch API key in use (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3616

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Thomas Raffray <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
3 people committed Sep 6, 2024
1 parent 7ebd11b commit 23cfee8
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/algolia/api/abtesting_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# Creates a new A/B test.
#
# Required API Key ACLs:
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/analytics_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# This method allow you to send requests to the Algolia REST API.

# @param path [String] Path of the endpoint, anything after \&quot;/1\&quot; must be specified. (required)
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/ingestion_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# Creates a new authentication resource.
#
# Required API Key ACLs:
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/insights_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# This method allow you to send requests to the Algolia REST API.

# @param path [String] Path of the endpoint, anything after \&quot;/1\&quot; must be specified. (required)
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/monitoring_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# This method allow you to send requests to the Algolia REST API.

# @param path [String] Path of the endpoint, anything after \&quot;/1\&quot; must be specified. (required)
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/personalization_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# This method allow you to send requests to the Algolia REST API.

# @param path [String] Path of the endpoint, anything after \&quot;/1\&quot; must be specified. (required)
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/query_suggestions_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
#
# Required API Key ACLs:
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/recommend_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# This method allow you to send requests to the Algolia REST API.

# @param path [String] Path of the endpoint, anything after \&quot;/1\&quot; must be specified. (required)
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/search_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# Creates a new API key with specific permissions and restrictions.
#
# Required API Key ACLs:
Expand Down
8 changes: 8 additions & 0 deletions lib/algolia/api/usage_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def self.create_with_config(config)
new(config)
end

# Helper method to switch the API key used to authenticate the requests.
#
# @param api_key [String] the new API key to use.
# @return [void]
def set_client_api_key(api_key)
@api_client.set_client_api_key(api_key)
end

# This method allow you to send requests to the Algolia REST API.

# @param path [String] Path of the endpoint, anything after \&quot;/1\&quot; must be specified. (required)
Expand Down
4 changes: 4 additions & 0 deletions lib/algolia/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def self.default
@@default ||= ApiClient.new
end

def set_client_api_key(api_key)
@config.set_client_api_key(api_key)
end

# Call an API with given options.
#
# @return [Http::Response] the response.
Expand Down
5 changes: 5 additions & 0 deletions lib/algolia/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def initialize(app_id, api_key, hosts, client_name, opts = {})
yield(self) if block_given?
end

def set_client_api_key(api_key)
@api_key = api_key
@header_params["X-Algolia-API-Key"] = api_key
end

# The default Configuration object.
def self.default
@@default ||= Configuration.new
Expand Down

0 comments on commit 23cfee8

Please sign in to comment.