Class: Braintrust::Resources::ACL

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ACL

Returns a new instance of ACL.



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

def initialize(client:)
  @client = client
end

Instance Method Details

#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

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

  • :group_id (String)

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

  • :permission (Symbol)

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

  • :restrict_object_type (Symbol)

    Optionally restricts the permission grant to just the specified object type

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

Returns:



29
30
31
32
33
34
35
36
# File 'lib/braintrust/resources/acl.rb', line 29

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

Parameters:

  • acl_id (String)

    Acl id

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



89
90
91
92
93
94
95
# File 'lib/braintrust/resources/acl.rb', line 89

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

#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

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

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

Returns:



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

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

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

NOTE: This operation is deprecated and will be removed in a future revision of the API. Create or replace 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, will replace the existing acl 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):

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

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

  • :restrict_object_type (Symbol)

    Optionally restricts the permission grant to just the specified object type

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

Returns:



118
119
120
121
122
123
124
125
# File 'lib/braintrust/resources/acl.rb', line 118

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

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

Get an acl object by its id

Parameters:

  • acl_id (String)

    Acl id

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



44
45
46
47
48
49
50
# File 'lib/braintrust/resources/acl.rb', line 44

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