Class: Braintrust::Resources::ACLs

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ACLs



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

def initialize(client:)
  @client = client
end

Instance Method Details

#batch_update(params = {}, opts = {}) ⇒ Braintrust::Models::ACLBatchUpdateResponse

Batch update acls. This operation is idempotent, so adding acls which already exist will have no effect, and removing acls which do not exist will have no effect.

Options Hash (params):

  • :add_acls (Array<AddACL>)

    An ACL grants a certain permission or role to a certain user or group on an object.

    ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on a project, they will also have read permissions on any experiment, dataset, etc. created within that project.

    To restrict a grant to a particular sub-object, you may specify restrict_object_type in the ACL, as part of a direct permission grant or as part of a role.

  • :remove_acls (Array<RemoveACL>)

    An ACL grants a certain permission or role to a certain user or group on an object.

    ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on a project, they will also have read permissions on any experiment, dataset, etc. created within that project.

    To restrict a grant to a particular sub-object, you may specify restrict_object_type in the ACL, as part of a direct permission grant or as part of a role.



130
131
132
133
134
135
136
137
# File 'lib/braintrust/resources/acls.rb', line 130

def batch_update(params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/v1/acl/batch-update"
  req[:body] = params
  req[:model] = Braintrust::Models::ACLBatchUpdateResponse
  @client.request(req, opts)
end

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

Create a new acl. If there is an existing acl with the same contents as the one specified in the request, will return the existing acl unmodified

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

  • :group_id (String)

    Id of the group the ACL applies to. Exactly one of user_id and group_id will be provided

  • :permission (Symbol)

    Each permission permits a certain type of operation on an object in the system

    Permissions can be assigned to to objects on an individual basis, or grouped into roles

  • :restrict_object_type (Symbol)

    The object type that the ACL applies to

  • :role_id (String)

    Id of the role the ACL grants. Exactly one of permission and role_id will be provided

  • :user_id (String)

    Id of the user the ACL applies to. Exactly one of user_id and group_id will be provided



31
32
33
34
35
36
37
38
# File 'lib/braintrust/resources/acls.rb', line 31

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

#delete(acl_id, opts = {}) ⇒ Braintrust::Models::ACL

Delete an acl object by its id



93
94
95
96
97
98
99
# File 'lib/braintrust/resources/acls.rb', line 93

def delete(acl_id, opts = {})
  req = {}
  req[:method] = :delete
  req[:path] = "/v1/acl/#{acl_id}"
  req[:model] = Braintrust::Models::ACL
  @client.request(req, opts)
end

#find_and_delete(params = {}, opts = {}) ⇒ Braintrust::Models::ACL

Delete a single acl

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

  • :group_id (String)

    Id of the group the ACL applies to. Exactly one of user_id and group_id will be provided

  • :permission (Symbol)

    Each permission permits a certain type of operation on an object in the system

    Permissions can be assigned to to objects on an individual basis, or grouped into roles

  • :restrict_object_type (Symbol)

    The object type that the ACL applies to

  • :role_id (String)

    Id of the role the ACL grants. Exactly one of permission and role_id will be provided

  • :user_id (String)

    Id of the user the ACL applies to. Exactly one of user_id and group_id will be provided



159
160
161
162
163
164
165
166
# File 'lib/braintrust/resources/acls.rb', line 159

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

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

List out all acls. The acls are sorted by creation date, with the most recently-created acls coming first

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



77
78
79
80
81
82
83
84
85
# File 'lib/braintrust/resources/acls.rb', line 77

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

#retrieve(acl_id, opts = {}) ⇒ Braintrust::Models::ACL

Get an acl object by its id



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

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