Class: Braintrust::Resources::Views
- Inherits:
-
Object
- Object
- Braintrust::Resources::Views
- Defined in:
- lib/braintrust/resources/views.rb
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Braintrust::Models::View
Create a new view.
-
#delete(view_id, params = {}, opts = {}) ⇒ Braintrust::Models::View
Delete a view object by its id.
-
#initialize(client:) ⇒ Views
constructor
A new instance of Views.
-
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::View>
List out all views.
-
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::View
Create or replace view.
-
#retrieve(view_id, params = {}, opts = {}) ⇒ Braintrust::Models::View
Get a view object by its id.
-
#update(view_id, params = {}, opts = {}) ⇒ Braintrust::Models::View
Partially update a view object.
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
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
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
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
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
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.
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 |