Class: Braintrust::Resources::Projects

Inherits:
Object
  • Object
show all
Defined in:
lib/braintrust/resources/projects.rb,
lib/braintrust/resources/projects/logs.rb

Defined Under Namespace

Classes: Logs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Projects

Returns a new instance of Projects.



9
10
11
12
# File 'lib/braintrust/resources/projects.rb', line 9

def initialize(client:)
  @client = client
  @logs = Braintrust::Resources::Projects::Logs.new(client: client)
end

Instance Attribute Details

#logsBraintrust::Resources::Projects::Logs (readonly)



7
8
9
# File 'lib/braintrust/resources/projects.rb', line 7

def logs
  @logs
end

Instance Method Details

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

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

  • :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 project belongs in.

Returns:



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

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

#delete(project_id, opts = {}) ⇒ Braintrust::Models::Project

Delete a project object by its id

Parameters:

  • project_id (String)

    Project id

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

    Options to specify HTTP behaviour for this request.

Returns:



111
112
113
114
115
116
117
# File 'lib/braintrust/resources/projects.rb', line 111

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

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

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

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

  • :project_name (String)

    Name of the project to search for

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



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

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

#retrieve(project_id, opts = {}) ⇒ Braintrust::Models::Project

Get a project object by its id

Parameters:

  • project_id (String)

    Project 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/projects.rb', line 41

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

#update(project_id, params = {}, opts = {}) ⇒ Braintrust::Models::Project

Partially update a project 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:

  • project_id (String)

    Project 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)

    Name of the project

  • :settings (Braintrust::Models::ProjectSettings)

    Project settings. Patch operations replace all settings, so make sure you include all settings you want to keep.

Returns:



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

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