Class: Tomba::Keys

Inherits:
Service show all
Defined in:
lib/tomba/services/keys.rb

Overview

Keys service for managing API keys.

Provides methods to list, create, reset, and delete API keys.

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Tomba::Service

Instance Method Details

#create_keyHash

Create a new API key.

Generates a new API key for the account.

Returns:

  • (Hash)

    API response containing the new key

Raises:

See Also:



70
71
72
73
74
75
76
77
78
# File 'lib/tomba/services/keys.rb', line 70

def create_key
  path = '/keys'

  params = {}

  @client.call('post', path, {
                 'content-type' => 'application/json'
               }, params)
end

#delete_key(id:) ⇒ Hash

Delete an API key.

Removes a specific API key by its ID.

Parameters:

  • id (String)

    the key ID to delete

Returns:

  • (Hash)

    API response

Raises:

See Also:



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/tomba/services/keys.rb', line 51

def delete_key(id:)
  raise Tomba::Exception, 'Missing required parameter: "id"' if id.nil?

  path = "/keys/#{id}"

  params = {}

  @client.call('delete', path, {
                 'content-type' => 'application/json'
               }, params)
end

#get_key(id:) ⇒ Hash

Get a specific API key by ID.

Parameters:

  • id (String)

    the key ID

Returns:

  • (Hash)

    API response

Raises:

See Also:



33
34
35
36
37
38
39
40
41
# File 'lib/tomba/services/keys.rb', line 33

def get_key(id:)
  raise Tomba::Exception, 'Missing required parameter: "id"' if id.nil?

  path = "/keys/#{id}"

  @client.call('get', path, {
                 'content-type' => 'application/json'
               }, {})
end

#get_keysHash

List all API keys.

Returns all API keys associated with the account.

Returns:

  • (Hash)

    API response containing the list of keys

Raises:

See Also:



17
18
19
20
21
22
23
24
25
# File 'lib/tomba/services/keys.rb', line 17

def get_keys
  path = '/keys'

  params = {}

  @client.call('get', path, {
                 'content-type' => 'application/json'
               }, params)
end

#reset_key(id:) ⇒ Hash

Reset an API key.

Regenerates a specific API key by its ID.

Parameters:

  • id (String)

    the key ID to reset

Returns:

  • (Hash)

    API response containing the reset key

Raises:

See Also:



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/tomba/services/keys.rb', line 88

def reset_key(id:)
  raise Tomba::Exception, 'Missing required parameter: "id"' if id.nil?

  path = "/keys/#{id}"

  params = {}

  @client.call('put', path, {
                 'content-type' => 'application/json'
               }, params)
end