class Wavefront::Role

Manage and query Wavefront roles

Public Instance Methods

add_assignees(id, assignees) click to toggle source

POST /api/v2/role/{id}/addAssignees Add multiple users and user groups to a specific role @param id [String] role ID @param assignees [Array] list of roles or accounts to be added @return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 84
def add_assignees(id, assignees)
  wf_role_id?(id)
  validate_user_list(assignees)
  api.post([id, 'addAssignees'].uri_concat, assignees, 'application/json')
end
create(body) click to toggle source

POST /api/v2/role Create a specific role @param body [Hash] a hash of parameters describing the role. Please

refer to the Wavefront Swagger docs for key:value information

@return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 33
def create(body)
  raise ArgumentError unless body.is_a?(Hash)

  api.post('', body, 'application/json')
end
delete(id) click to toggle source

DELETE /api/v2/role/{id} Delete a specific role @param id [String] ID of the role @return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 44
def delete(id)
  wf_role_id?(id)
  api.delete(id)
end
describe(id) click to toggle source

GET /api/v2/role/{id} Get a specific role @param id [String] ID of the role @return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 54
def describe(id)
  wf_role_id?(id)
  api.get(id)
end
grant(permission, roles) click to toggle source

POST /api/v2/role/grant/{permission} Grants a single permission to role(s) @param permission [String] permission to grant @param roles [Array] list of roles to receive permission @return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 110
def grant(permission, roles)
  wf_permission?(permission)
  validate_role_list(roles)
  api.post(['grant', permission].uri_concat, roles, 'application/json')
end
list(offset = 0, limit = 100) click to toggle source

GET /api/v2/role Get all roles for a customer @param offset [Int] alert at which the list begins @param limit [Int] the number of alerts to return @return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 23
def list(offset = 0, limit = 100)
  api.get('', offset: offset, limit: limit)
end
remove_assignees(id, assignees) click to toggle source

POST /api/v2/role/{id}/removeAssignees Remove multiple users and user groups from a specific role @param id [String] role ID @param assignees [Array] list of roles or accounts to be removed @return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 96
def remove_assignees(id, assignees)
  wf_role_id?(id)
  validate_user_list(assignees)
  api.post([id, 'removeAssignees'].uri_concat,
           assignees,
           'application/json')
end
revoke(permission, roles) click to toggle source

POST /api/v2/role/revoke/{permission} Revokes a single permission from role(s) @param permission [String] permission to revoke @param roles [Array] list of roles to lose permission @return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 122
def revoke(permission, roles)
  wf_permission?(permission)
  validate_role_list(roles)
  api.post(['revoke', permission].uri_concat, roles, 'application/json')
end
update(id, body, modify = true) click to toggle source

PUT /api/v2/role/{id} Update a specific role @param id [String] role ID @param body [Hash] key-value hash of the parameters you wish to change @param modify [true, false] if true, use {#describe()} to get a hash

describing the existing object, and modify that with the new body. If
false, pass the new body straight through.

@return [Wavefront::Response]

# File lib/wavefront-sdk/role.rb, line 68
def update(id, body, modify = true)
  wf_role_id?(id)
  raise ArgumentError unless body.is_a?(Hash)

  return api.put(id, body, 'application/json') unless modify

  api.put(id, hash_for_update(describe(id).response, body),
          'application/json')
end
update_keys() click to toggle source
# File lib/wavefront-sdk/role.rb, line 13
def update_keys
  %i[id name description]
end