Class: Apertur::Resources::Keys
- Inherits:
-
Object
- Object
- Apertur::Resources::Keys
- Defined in:
- lib/apertur/resources/keys.rb
Overview
Manage API keys within a project.
Instance Method Summary collapse
-
#create(project_id, **options) ⇒ Hash
Create a new API key.
-
#delete(project_id, key_id) ⇒ nil
Delete an API key.
-
#initialize(http) ⇒ Keys
constructor
A new instance of Keys.
-
#list(project_id) ⇒ Array<Hash>
List all API keys for a project.
-
#set_destinations(key_id, destination_ids, long_polling_enabled: false) ⇒ Hash
Set the destinations and long-polling configuration for a key.
-
#update(project_id, key_id, **options) ⇒ Hash
Update an existing API key.
Constructor Details
#initialize(http) ⇒ Keys
Returns a new instance of Keys.
8 9 10 |
# File 'lib/apertur/resources/keys.rb', line 8 def initialize(http) @http = http end |
Instance Method Details
#create(project_id, **options) ⇒ Hash
Create a new API key.
25 26 27 |
# File 'lib/apertur/resources/keys.rb', line 25 def create(project_id, **) @http.request(:post, "/api/v1/projects/#{project_id}/keys", body: ) end |
#delete(project_id, key_id) ⇒ nil
Delete an API key.
44 45 46 |
# File 'lib/apertur/resources/keys.rb', line 44 def delete(project_id, key_id) @http.request(:delete, "/api/v1/projects/#{project_id}/keys/#{key_id}") end |
#list(project_id) ⇒ Array<Hash>
List all API keys for a project.
16 17 18 |
# File 'lib/apertur/resources/keys.rb', line 16 def list(project_id) @http.request(:get, "/api/v1/projects/#{project_id}/keys") end |
#set_destinations(key_id, destination_ids, long_polling_enabled: false) ⇒ Hash
Set the destinations and long-polling configuration for a key.
54 55 56 57 58 |
# File 'lib/apertur/resources/keys.rb', line 54 def set_destinations(key_id, destination_ids, long_polling_enabled: false) body = { destination_ids: destination_ids } body[:long_polling_enabled] = long_polling_enabled unless long_polling_enabled.nil? @http.request(:put, "/api/v1/keys/#{key_id}/destinations", body: body) end |
#update(project_id, key_id, **options) ⇒ Hash
Update an existing API key.
35 36 37 |
# File 'lib/apertur/resources/keys.rb', line 35 def update(project_id, key_id, **) @http.request(:patch, "/api/v1/projects/#{project_id}/keys/#{key_id}", body: ) end |