Class: Braintrust::Resources::EnvVars

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ EnvVars

Returns a new instance of EnvVars.



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

def initialize(client:)
  @client = client
end

Instance Method Details

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

Create a new env_var. If there is an existing env_var with the same name as the one specified in the request, will return the existing env_var 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)

    The name of the environment variable

  • :object_id (String)

    The id of the object the environment variable is scoped for

  • :object_type (Symbol)

    The type of the object the environment variable is scoped for

  • :value (String)

    The value of the environment variable. Will be encrypted at rest.

Returns:



22
23
24
25
26
27
28
29
# File 'lib/braintrust/resources/env_vars.rb', line 22

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

#delete(env_var_id, opts = {}) ⇒ Braintrust::Models::EnvVar

Delete an env_var object by its id

Parameters:

  • env_var_id (String)

    EnvVar id

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

    Options to specify HTTP behaviour for this request.

Returns:



96
97
98
99
100
101
102
# File 'lib/braintrust/resources/env_vars.rb', line 96

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

#list(params = {}, opts = {}) ⇒ Braintrust::Models::EnvVarListResponse

List out all env_vars. The env_vars are sorted by creation date, with the most recently-created env_vars 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):

  • :env_var_name (String)

    Name of the env_var to search for

  • :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

  • :object_id (String)

    The id of the object the environment variable is scoped for

  • :object_type (Symbol)

    The type of the object the environment variable is scoped for

Returns:



81
82
83
84
85
86
87
88
# File 'lib/braintrust/resources/env_vars.rb', line 81

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

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

Create or replace env_var. If there is an existing env_var with the same name as the one specified in the request, will replace the existing env_var 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)

    The name of the environment variable

  • :object_id (String)

    The id of the object the environment variable is scoped for

  • :object_type (Symbol)

    The type of the object the environment variable is scoped for

  • :value (String)

    The value of the environment variable. Will be encrypted at rest.

Returns:



117
118
119
120
121
122
123
124
# File 'lib/braintrust/resources/env_vars.rb', line 117

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

#retrieve(env_var_id, opts = {}) ⇒ Braintrust::Models::EnvVar

Get an env_var object by its id

Parameters:

  • env_var_id (String)

    EnvVar id

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

    Options to specify HTTP behaviour for this request.

Returns:



37
38
39
40
41
42
43
# File 'lib/braintrust/resources/env_vars.rb', line 37

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

#update(env_var_id, params = {}, opts = {}) ⇒ Braintrust::Models::EnvVar

Partially update an env_var 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:

  • env_var_id (String)

    EnvVar 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):

  • :name (String)

    The name of the environment variable

  • :value (String)

    The value of the environment variable. Will be encrypted at rest.

Returns:



58
59
60
61
62
63
64
65
# File 'lib/braintrust/resources/env_vars.rb', line 58

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