Class: Braintrust::Resources::AISecrets

Inherits:
Object
  • Object
show all
Defined in:
lib/braintrust/resources/ai_secrets.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ AISecrets

Returns a new instance of AISecrets.



6
7
8
# File 'lib/braintrust/resources/ai_secrets.rb', line 6

def initialize(client:)
  @client = client
end

Instance Method Details

#create(params = {}, opts = {}) ⇒ Braintrust::Models::AISecret

Create a new ai_secret. If there is an existing ai_secret with the same name as the one specified in the request, will return the existing ai_secret unmodified

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :name (String)

    Name of the AI secret

  • :metadata (Hash)
  • :org_name (String)

    For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the AI Secret belongs in.

  • :secret (String)

    Secret value. If omitted in a PUT request, the existing secret value will be left intact, not replaced with null.

  • :type (String)

Returns:



26
27
28
29
30
31
32
33
# File 'lib/braintrust/resources/ai_secrets.rb', line 26

def create(params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/v1/ai_secret"
  req[:body] = params
  req[:model] = Braintrust::Models::AISecret
  @client.request(req, opts)
end

#delete(ai_secret_id, opts = {}) ⇒ Braintrust::Models::AISecret

Delete an ai_secret object by its id

Parameters:

  • ai_secret_id (String)

    AiSecret id

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



113
114
115
116
117
118
119
# File 'lib/braintrust/resources/ai_secrets.rb', line 113

def delete(ai_secret_id, opts = {})
  req = {}
  req[:method] = :delete
  req[:path] = "/v1/ai_secret/#{ai_secret_id}"
  req[:model] = Braintrust::Models::AISecret
  @client.request(req, opts)
end

#find_and_delete(params = {}, opts = {}) ⇒ Braintrust::Models::AISecret

Delete a single ai_secret

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :name (String)

    Name of the AI secret

  • :org_name (String)

    For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the AI Secret belongs in.

Returns:



132
133
134
135
136
137
138
139
# File 'lib/braintrust/resources/ai_secrets.rb', line 132

def find_and_delete(params = {}, opts = {})
  req = {}
  req[:method] = :delete
  req[:path] = "/v1/ai_secret"
  req[:body] = params
  req[:model] = Braintrust::Models::AISecret
  @client.request(req, opts)
end

#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::AISecret>

List out all ai_secrets. The ai_secrets are sorted by creation date, with the most recently-created ai_secrets coming first

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :ai_secret_name (String)

    Name of the ai_secret to search for

  • :ai_secret_type (Array<String>|String)
  • :ending_before (String)

    Pagination cursor id.

    For example, if the initial item in the last page you fetched had an id of foo, pass ending_before=foo to fetch the previous page. Note: you may only pass one of starting_after and ending_before

  • :ids (Array<String>|String)

    Filter search results to a particular set of object IDs. To specify a list of IDs, include the query param multiple times

  • :limit (Integer)

    Limit the number of objects to return

  • :org_name (String)

    Filter search results to within a particular organization

  • :starting_after (String)

    Pagination cursor id.

    For example, if the final item in the last page you fetched had an id of foo, pass starting_after=foo to fetch the next page. Note: you may only pass one of starting_after and ending_before

Returns:



97
98
99
100
101
102
103
104
105
# File 'lib/braintrust/resources/ai_secrets.rb', line 97

def list(params = {}, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/v1/ai_secret"
  req[:query] = params
  req[:page] = Braintrust::ListObjects
  req[:model] = Braintrust::Models::AISecret
  @client.request(req, opts)
end

#replace(params = {}, opts = {}) ⇒ Braintrust::Models::AISecret

Create or replace ai_secret. If there is an existing ai_secret with the same name as the one specified in the request, will replace the existing ai_secret with the provided fields

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :name (String)

    Name of the AI secret

  • :metadata (Hash)
  • :org_name (String)

    For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the AI Secret belongs in.

  • :secret (String)

    Secret value. If omitted in a PUT request, the existing secret value will be left intact, not replaced with null.

  • :type (String)

Returns:



158
159
160
161
162
163
164
165
# File 'lib/braintrust/resources/ai_secrets.rb', line 158

def replace(params = {}, opts = {})
  req = {}
  req[:method] = :put
  req[:path] = "/v1/ai_secret"
  req[:body] = params
  req[:model] = Braintrust::Models::AISecret
  @client.request(req, opts)
end

#retrieve(ai_secret_id, opts = {}) ⇒ Braintrust::Models::AISecret

Get an ai_secret object by its id

Parameters:

  • ai_secret_id (String)

    AiSecret id

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



41
42
43
44
45
46
47
# File 'lib/braintrust/resources/ai_secrets.rb', line 41

def retrieve(ai_secret_id, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/v1/ai_secret/#{ai_secret_id}"
  req[:model] = Braintrust::Models::AISecret
  @client.request(req, opts)
end

#update(ai_secret_id, params = {}, opts = {}) ⇒ Braintrust::Models::AISecret

Partially update an ai_secret object. Specify the fields to update in the payload. Any object-type fields will be deep-merged with existing content. Currently we do not support removing fields or setting them to null.

Parameters:

  • ai_secret_id (String)

    AiSecret id

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :metadata (Hash)
  • :name (String)

    Name of the AI secret

  • :secret (String)
  • :type (String)

Returns:



64
65
66
67
68
69
70
71
# File 'lib/braintrust/resources/ai_secrets.rb', line 64

def update(ai_secret_id, params = {}, opts = {})
  req = {}
  req[:method] = :patch
  req[:path] = "/v1/ai_secret/#{ai_secret_id}"
  req[:body] = params
  req[:model] = Braintrust::Models::AISecret
  @client.request(req, opts)
end