Class: Braintrust::Resources::APIKeys
- Inherits:
-
Object
- Object
- Braintrust::Resources::APIKeys
- Defined in:
- lib/braintrust/resources/api_keys.rb
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Braintrust::Models::CreateAPIKeyOutput
Create a new api_key.
-
#delete(api_key_id, opts = {}) ⇒ Braintrust::Models::APIKey
Delete an api_key object by its id.
-
#initialize(client:) ⇒ APIKeys
constructor
A new instance of APIKeys.
-
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::APIKey>
List out all api_keys.
-
#retrieve(api_key_id, opts = {}) ⇒ Braintrust::Models::APIKey
Get an api_key object by its id.
Constructor Details
#initialize(client:) ⇒ APIKeys
Returns a new instance of APIKeys.
6 7 8 |
# File 'lib/braintrust/resources/api_keys.rb', line 6 def initialize(client:) @client = client end |
Instance Method Details
#create(params = {}, opts = {}) ⇒ Braintrust::Models::CreateAPIKeyOutput
Create a new api_key. It is possible to have multiple API keys with the same name. There is no de-duplication
22 23 24 25 26 27 28 29 |
# File 'lib/braintrust/resources/api_keys.rb', line 22 def create(params = {}, opts = {}) req = {} req[:method] = :post req[:path] = "/v1/api_key" req[:body] = params req[:model] = Braintrust::Models::CreateAPIKeyOutput @client.request(req, opts) end |
#delete(api_key_id, opts = {}) ⇒ Braintrust::Models::APIKey
Delete an api_key object by its id
84 85 86 87 88 89 90 |
# File 'lib/braintrust/resources/api_keys.rb', line 84 def delete(api_key_id, opts = {}) req = {} req[:method] = :delete req[:path] = "/v1/api_key/#{api_key_id}" req[:model] = Braintrust::Models::APIKey @client.request(req, opts) end |
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::APIKey>
List out all api_keys. The api_keys are sorted by creation date, with the most recently-created api_keys coming first
68 69 70 71 72 73 74 75 76 |
# File 'lib/braintrust/resources/api_keys.rb', line 68 def list(params = {}, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/api_key" req[:query] = params req[:page] = Braintrust::ListObjects req[:model] = Braintrust::Models::APIKey @client.request(req, opts) end |
#retrieve(api_key_id, opts = {}) ⇒ Braintrust::Models::APIKey
Get an api_key object by its id
37 38 39 40 41 42 43 |
# File 'lib/braintrust/resources/api_keys.rb', line 37 def retrieve(api_key_id, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/api_key/#{api_key_id}" req[:model] = Braintrust::Models::APIKey @client.request(req, opts) end |