Class: Braintrust::Resources::User

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ User

Returns a new instance of User.



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

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

  • :email (String)

    Email of the user to search for

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

  • :family_name (String)

    Family name of the user to search for

  • :given_name (String)

    Given name of the user 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

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



49
50
51
52
53
54
55
56
57
# File 'lib/braintrust/resources/user.rb', line 49

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

#retrieve(user_id, opts = {}) ⇒ Braintrust::Models::User

Get a user object by its id

Parameters:

  • user_id (String)

    User id

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

    Options to specify HTTP behaviour for this request.

Returns:



16
17
18
19
20
21
22
# File 'lib/braintrust/resources/user.rb', line 16

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