Class: NgrokAPI::Services::ApiKeysClient
- Inherits:
-
Object
- Object
- NgrokAPI::Services::ApiKeysClient
- Defined in:
- lib/ngrokapi/services/api_keys_client.rb
Overview
A client for interacting with the api_keys API
Constant Summary collapse
- LIST_PROPERTY =
The List Property from the resulting API for list calls
'keys'
- PATH =
The API path for API keys
'/api_keys'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey
Create a new API key.
-
#delete(id: nil) ⇒ nil
Delete an API key by ID.
-
#delete!(id: nil) ⇒ nil
Delete an API key by ID.
-
#get(id: nil) ⇒ NgrokAPI::Models::ApiKey
Get the details of an API key by ID.
-
#get!(id: nil) ⇒ NgrokAPI::Models::ApiKey
Get the details of an API key by ID.
-
#initialize(client:) ⇒ ApiKeysClient
constructor
A new instance of ApiKeysClient.
-
#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all API keys owned by this account.
-
#update(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey
Update attributes of an API key by ID.
-
#update!(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey
Update attributes of an API key by ID.
Constructor Details
#initialize(client:) ⇒ ApiKeysClient
Returns a new instance of ApiKeysClient.
17 18 19 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 17 def initialize(client:) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
15 16 17 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 15 def client @client end |
Instance Method Details
#create(description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey
Create a new API key. The generated API key can be used to authenticate to the ngrok API.
31 32 33 34 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 31 def create(description: nil, metadata: nil) result = @client.post(PATH, data: build_data(description: description, metadata: )) NgrokAPI::Models::ApiKey.new(client: self, result: result) end |
#delete(id: nil) ⇒ nil
Delete an API key by ID.
44 45 46 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 44 def delete(id: nil) @client.delete("#{PATH}/#{id}") end |
#delete!(id: nil) ⇒ nil
Delete an API key by ID. Throw an exception if 404.
55 56 57 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 55 def delete!(id: nil) @client.delete("#{PATH}/#{id}", danger: true) end |
#get(id: nil) ⇒ NgrokAPI::Models::ApiKey
Get the details of an API key by ID.
66 67 68 69 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 66 def get(id: nil) result = @client.get("#{PATH}/#{id}") NgrokAPI::Models::ApiKey.new(client: self, result: result) end |
#get!(id: nil) ⇒ NgrokAPI::Models::ApiKey
Get the details of an API key by ID. Throw an exception if 404.
78 79 80 81 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 78 def get!(id: nil) result = @client.get("#{PATH}/#{id}", danger: true) NgrokAPI::Models::ApiKey.new(client: self, result: result) end |
#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all API keys owned by this account.
92 93 94 95 96 97 98 99 100 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 92 def list(before_id: nil, limit: nil, url: nil) result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH) NgrokAPI::Models::Listable.new( client: self, result: result, list_property: LIST_PROPERTY, klass: NgrokAPI::Models::ApiKey ) end |
#update(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey
Update attributes of an API key by ID.
113 114 115 116 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 113 def update(id: nil, description: nil, metadata: nil) result = @client.patch("#{PATH}/#{id}", data: build_data(description: description, metadata: )) NgrokAPI::Models::ApiKey.new(client: self, result: result) end |
#update!(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey
Update attributes of an API key by ID.
127 128 129 130 131 |
# File 'lib/ngrokapi/services/api_keys_client.rb', line 127 def update!(id: nil, description: nil, metadata: nil) data = build_data(description: description, metadata: ) result = @client.patch("#{PATH}/#{id}", danger: true, data: data) NgrokAPI::Models::ApiKey.new(client: self, result: result) end |