Class: Braintrust::Resources::Views

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Views

Returns a new instance of Views.



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

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

  • :object_id (String)

    The id of the object the view applies to

  • :object_type (Symbol)

    The object type that the ACL applies to

  • :view_type (Symbol)

    Type of table that the view corresponds to.

  • :deleted_at (DateTime)

    Date of role deletion, or null if the role is still active

  • :options (Braintrust::Models::ViewOptions)

    Options for the view in the app

  • :user_id (String)

    Identifies the user who created the view

  • :view_data (Braintrust::Models::ViewData)

    The view definition

Returns:



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

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

#delete(view_id, params = {}, opts = {}) ⇒ Braintrust::Models::View

Delete a view object by its id

Parameters:

  • view_id (String)

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

  • :object_id (String)

    The id of the object the view applies to

  • :object_type (Symbol)

    The object type that the ACL applies to

Returns:



128
129
130
131
132
133
134
135
# File 'lib/braintrust/resources/views.rb', line 128

def delete(view_id, params = {}, opts = {})
  req = {}
  req[:method] = :delete
  req[:path] = "/v1/view/#{view_id}"
  req[:body] = params
  req[:model] = Braintrust::Models::View
  @client.request(req, opts)
end

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

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

  • :object_id (String)

    The id of the object the ACL applies to

  • :object_type (Symbol)

    The object type that the ACL applies to

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

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

  • :view_name (String)

    Name of the view to search for

  • :view_type (Symbol)

    Type of table that the view corresponds to.

Returns:



107
108
109
110
111
112
113
114
115
# File 'lib/braintrust/resources/views.rb', line 107

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

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

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

    Name of the view

  • :object_id (String)

    The id of the object the view applies to

  • :object_type (Symbol)

    The object type that the ACL applies to

  • :view_type (Symbol)

    Type of table that the view corresponds to.

  • :deleted_at (DateTime)

    Date of role deletion, or null if the role is still active

  • :options (Braintrust::Models::ViewOptions)

    Options for the view in the app

  • :user_id (String)

    Identifies the user who created the view

  • :view_data (Braintrust::Models::ViewData)

    The view definition

Returns:



154
155
156
157
158
159
160
161
# File 'lib/braintrust/resources/views.rb', line 154

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

#retrieve(view_id, params = {}, opts = {}) ⇒ Braintrust::Models::View

Get a view object by its id

Parameters:

  • view_id (String)

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

  • :object_id (String)

    The id of the object the ACL applies to

  • :object_type (Symbol)

    The object type that the ACL applies to

Returns:



46
47
48
49
50
51
52
53
# File 'lib/braintrust/resources/views.rb', line 46

def retrieve(view_id, params = {}, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/v1/view/#{view_id}"
  req[:query] = params
  req[:model] = Braintrust::Models::View
  @client.request(req, opts)
end

#update(view_id, params = {}, opts = {}) ⇒ Braintrust::Models::View

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

  • view_id (String)

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

  • :object_id (String)

    The id of the object the view applies to

  • :object_type (Symbol)

    The object type that the ACL applies to

  • :name (String)

    Name of the view

  • :options (Braintrust::Models::ViewOptions)

    Options for the view in the app

  • :user_id (String)

    Identifies the user who created the view

  • :view_data (Braintrust::Models::ViewData)

    The view definition

  • :view_type (Symbol)

    Type of table that the view corresponds to.

Returns:



73
74
75
76
77
78
79
80
# File 'lib/braintrust/resources/views.rb', line 73

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