module Wavefront::Mixin::Acl

ACL mixins

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

Public Instance Methods

acl_add(id, view = [], modify = []) click to toggle source

POST /api/v2/{entity}/acl/add Adds the specified ids to the given object's ACL @param id [String] ID of object @param view [Array] array of entities allowed to view

the object. Entities may be users or groups

@param modify [Array] array of entities allowed to

view and modify the object. Same rules as @view.

@return [Wavefront::Response]

# 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 = []) click to toggle source

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. @param id [String] ID of object @param view [Array] array of entities allowed to view

the object. Entities may be users or groups

@param modify [Array] array of entities allowed to

view and modify the object. Same rules as @view.

@return [Wavefront::Response]

# 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 = []) click to toggle source

PUT /api/v2/{entity}/acl/set Set ACL for the specified object @param id [String] ID of object @param view [Array] array of entities allowed to view

the object. Entities may be users or groups

@param modify [Array] array of entities allowed to

view and modify the object. Same rules as @view.

@return [Wavefront::Response]

# 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) click to toggle source

GET /api/v2/{entity}/acl Get list of Access Control Lists for the specified object @param id_list [Array] array of object IDs @return [Wavefront::Response]

# 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

Private Instance Methods

acl_body(id, view, modify) click to toggle source
# File lib/wavefront-sdk/api_mixins/acl.rb, line 74
def acl_body(id, view, modify)
  valid_id?(id)
  valid_acl_body?(view)
  valid_acl_body?(modify)

  [{ entityId: id, viewAcl: view, modifyAcl: modify }]
end
valid_acl_body?(list) click to toggle source
# File lib/wavefront-sdk/api_mixins/acl.rb, line 82
def valid_acl_body?(list)
  return true if list.is_a?(Array) && list.all?(String)

  raise ArgumentError
end