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[String]) (defaults to: [])

    array of entities allowed to view the object. Entities may be users or groups

  • modify (Array[String]) (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 = []) ⇒ Wavefront::Response

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.

Parameters:

  • id (String)

    ID of object

  • view (Array[String]) (defaults to: [])

    array of entities allowed to view the object. Entities may be users or groups

  • modify (Array[String]) (defaults to: [])

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

Returns:



51
52
53
54
55
56
57
# File 'lib/wavefront-sdk/api_mixins/acl.rb', line 51

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 = []) ⇒ Wavefront::Response

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

Parameters:

  • id (String)

    ID of object

  • view (Array[String]) (defaults to: [])

    array of entities allowed to view the object. Entities may be users or groups

  • modify (Array[String]) (defaults to: [])

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

Returns:



68
69
70
# File 'lib/wavefront-sdk/api_mixins/acl.rb', line 68

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:



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

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