Class: Braintrust::Resources::Organizations

Inherits:
Object
  • Object
show all
Defined in:
lib/braintrust/resources/organizations.rb,
lib/braintrust/resources/organizations/members.rb

Defined Under Namespace

Classes: Members

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Organizations

Returns a new instance of Organizations.



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

def initialize(client:)
  @client = client
  @members = Braintrust::Resources::Organizations::Members.new(client: client)
end

Instance Attribute Details

#membersBraintrust::Resources::Organizations::Members (readonly)



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

def members
  @members
end

Instance Method Details

#delete(organization_id, opts = {}) ⇒ Braintrust::Models::Organization

Delete an organization object by its id

Parameters:

  • organization_id (String)

    Organization id

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

    Options to specify HTTP behaviour for this request.

Returns:



91
92
93
94
95
96
97
# File 'lib/braintrust/resources/organizations.rb', line 91

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

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

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

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



75
76
77
78
79
80
81
82
83
# File 'lib/braintrust/resources/organizations.rb', line 75

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

#retrieve(organization_id, opts = {}) ⇒ Braintrust::Models::Organization

Get an organization object by its id

Parameters:

  • organization_id (String)

    Organization id

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

    Options to specify HTTP behaviour for this request.

Returns:



20
21
22
23
24
25
26
# File 'lib/braintrust/resources/organizations.rb', line 20

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

#update(organization_id, params = {}, opts = {}) ⇒ Braintrust::Models::Organization

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

  • organization_id (String)

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

  • :api_url (String)
  • :is_universal_api (Boolean)
  • :name (String)

    Name of the organization

  • :proxy_url (String)
  • :realtime_url (String)

Returns:



44
45
46
47
48
49
50
51
# File 'lib/braintrust/resources/organizations.rb', line 44

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