Module: Wavefront::Mixin::Acl

Included in:
Alert, Dashboard
Defined in:
lib/wavefront-sdk/api_mixins/acl.rb

Overview

ACL mixins

Mix this module into class which supports ACLs, ensuring there is a valid_id? method to perform ID validation.

Instance Method Summary collapse

Instance Method Details

#acl_add(id, view = [], modify = []) ⇒ Wavefront::Response

POST /api/v2/entity/acl/add Adds the specified ids to the given object's ACL

Parameters:

  • id (String) —

    ID of object

  • view (Array[Hash]) (defaults to: []) —

    array of entities allowed to view the object. Entities may be users or groups, and are defined as a Hash with keys :id and :name. For users the two will be the same, for groups, not.

  • modify (Array[Hash]) (defaults to: []) —

    array of entities allowed to view and modify the object. Same rules as @view.

Returns:



31
32
33
34
35
36
37
# File 'lib/wavefront-sdk/api_mixins/acl.rb', line 31

def acl_add(id, view = [], modify = [])
  valid_id?(id)

  api.post(%w[acl add].uri_concat,
           acl_body(id, view, modify),
           'application/json')
end

#acl_delete(id, view = [], modify = []) ⇒ Object

POST /api/v2/entity/acl/remove Removes the specified ids from the given object's ACL

Though the API method is 'remove', the acl method names have been chosen to correspond with the tag methods.



45
46
47
48
49
50
51
# File 'lib/wavefront-sdk/api_mixins/acl.rb', line 45

def acl_delete(id, view = [], modify = [])
  valid_id?(id)

  api.post(%w[acl remove].uri_concat,
           acl_body(id, view, modify),
           'application/json')
end

#acl_set(id, view = [], modify = []) ⇒ Object

PUT /api/v2/entity/acl/set Set ACL for the specified object



56
57
58
# File 'lib/wavefront-sdk/api_mixins/acl.rb', line 56

def acl_set(id, view = [], modify = [])
  api.put(%w[acl set].uri_concat, acl_body(id, view, modify))
end

#acls(id_list) ⇒ Wavefront::Response

GET /api/v2/entity/acl Get list of Access Control Lists for the specified object

Parameters:

Returns:



15
16
17
18
# File 'lib/wavefront-sdk/api_mixins/acl.rb', line 15

def acls(id_list)
  id_list.each { |id| valid_id?(id) }
  api.get_flat_params('acl', id: id_list)
end