Class: Braintrust::Resources::Users

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Users

Returns a new instance of Users.



6
7
8
# File 'lib/braintrust/resources/users.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 (Array<String>|String)

    Email of the user to search for. You may pass the param multiple times to filter for more than one email

  • :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 (Array<String>|String)

    Family name of the user to search for. You may pass the param multiple times to filter for more than one family name

  • :given_name (Array<String>|String)

    Given name of the user to search for. You may pass the param multiple times to filter for more than one given name

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



52
53
54
55
56
57
58
59
60
# File 'lib/braintrust/resources/users.rb', line 52

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/users.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