Class: Braintrust::Resources::Roles
- Inherits:
-
Object
- Object
- Braintrust::Resources::Roles
- Defined in:
- lib/braintrust/resources/roles.rb
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Braintrust::Models::Role
Create a new role.
-
#delete(role_id, opts = {}) ⇒ Braintrust::Models::Role
Delete a role object by its id.
-
#initialize(client:) ⇒ Roles
constructor
A new instance of Roles.
-
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::Role>
List out all roles.
-
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::Role
Create or replace role.
-
#retrieve(role_id, opts = {}) ⇒ Braintrust::Models::Role
Get a role object by its id.
-
#update(role_id, params = {}, opts = {}) ⇒ Braintrust::Models::Role
Partially update a role object.
Constructor Details
#initialize(client:) ⇒ Roles
Returns a new instance of Roles.
6 7 8 |
# File 'lib/braintrust/resources/roles.rb', line 6 def initialize(client:) @client = client end |
Instance Method Details
#create(params = {}, opts = {}) ⇒ Braintrust::Models::Role
Create a new role. If there is an existing role with the same name as the one specified in the request, will return the existing role unmodified
28 29 30 31 32 33 34 35 |
# File 'lib/braintrust/resources/roles.rb', line 28 def create(params = {}, opts = {}) req = {} req[:method] = :post req[:path] = "/v1/role" req[:body] = params req[:model] = Braintrust::Models::Role @client.request(req, opts) end |
#delete(role_id, opts = {}) ⇒ Braintrust::Models::Role
Delete a role object by its id
116 117 118 119 120 121 122 |
# File 'lib/braintrust/resources/roles.rb', line 116 def delete(role_id, opts = {}) req = {} req[:method] = :delete req[:path] = "/v1/role/#{role_id}" req[:model] = Braintrust::Models::Role @client.request(req, opts) end |
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::Role>
List out all roles. The roles are sorted by creation date, with the most recently-created roles coming first
100 101 102 103 104 105 106 107 108 |
# File 'lib/braintrust/resources/roles.rb', line 100 def list(params = {}, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/role" req[:query] = params req[:page] = Braintrust::ListObjects req[:model] = Braintrust::Models::Role @client.request(req, opts) end |
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::Role
Create or replace role. If there is an existing role with the same name as the one specified in the request, will replace the existing role with the provided fields
143 144 145 146 147 148 149 150 |
# File 'lib/braintrust/resources/roles.rb', line 143 def replace(params = {}, opts = {}) req = {} req[:method] = :put req[:path] = "/v1/role" req[:body] = params req[:model] = Braintrust::Models::Role @client.request(req, opts) end |
#retrieve(role_id, opts = {}) ⇒ Braintrust::Models::Role
Get a role object by its id
43 44 45 46 47 48 49 |
# File 'lib/braintrust/resources/roles.rb', line 43 def retrieve(role_id, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/role/#{role_id}" req[:model] = Braintrust::Models::Role @client.request(req, opts) end |
#update(role_id, params = {}, opts = {}) ⇒ Braintrust::Models::Role
Partially update a role 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.
68 69 70 71 72 73 74 75 |
# File 'lib/braintrust/resources/roles.rb', line 68 def update(role_id, params = {}, opts = {}) req = {} req[:method] = :patch req[:path] = "/v1/role/#{role_id}" req[:body] = params req[:model] = Braintrust::Models::Role @client.request(req, opts) end |