class Nessus6::Group

The Groups class is for interacting with Nessus6 user groups. Groups are utilized to make sharing easier. localhost:8834/api#/resources/groups

Public Class Methods

new(client) click to toggle source
# File lib/Nessus6/group.rb, line 11
def initialize(client)
  @client = client
end

Public Instance Methods

add_user(group_id, user_id) click to toggle source

Add a user to the group. This request requires administrator user permissions.

@param group_id [String, Fixnum] The unique id of the group. @param user_id [String, Fixnum] The unique id of the user. @return [Hash]

# File lib/Nessus6/group.rb, line 21
def add_user(group_id, user_id)
  response = @client.post("groups/#{group_id}/users/#{user_id}")
  verify response,
         forbidden: 'You do not have permission to add users to a group',
         not_found: 'Group or user does not exist',
         internal_server_error: 'Server failed to add the user to the group'
end
create(name) click to toggle source

Create a group. This request requires administrator user permissions.

@param name [String, Fixnum] The name of the group. @return [Hash]

# File lib/Nessus6/group.rb, line 34
def create(name)
  response = @client.post('groups', name: name)
  verify response,
         bad_request: 'Field is invalid',
         forbidden: 'You do not have permission to create a group',
         internal_server_error: 'Server failed to create the group'
end
delete(group_id) click to toggle source

Delete a group. This request requires administrator user permissions.

@param group_id [String, Fixnum] The unique id of the group. @return [Hash]

# File lib/Nessus6/group.rb, line 47
def delete(group_id)
  response = @client.delete("groups/#{group_id}")
  verify response,
         bad_request: 'Group does not exist',
         forbidden: 'You do not have permission to delete the group',
         internal_server_error: 'Server failed to delete the group'
end
delete_user(group_id, user_id) click to toggle source

Deletes a user from the group. This request requires administrator user permissions.

@param group_id [String, Fixnum] The unique id of the group. @param user_id [String, Fixnum] The unique id of the user. @return [Hash]

# File lib/Nessus6/group.rb, line 61
def delete_user(group_id, user_id)
  response = @client.delete("groups/#{group_id}/users/#{user_id}")
  verify response,
         forbidden: 'You do not have permission to delete users from a '\
                    'group',
         not_found: 'Group or user does not exist',
         internal_server_error: 'Server failed to remove the user from '\
                                'the group'
end
edit(group_id, name) click to toggle source

Edit a group. This request requires administrator user permissions.

@param group_id [String, Fixnum] The unique id of the group. @param name [String] The name of the group. @return [Hash]

# File lib/Nessus6/group.rb, line 76
def edit(group_id, name)
  response = @client.put("groups/#{group_id}", name: name)
  verify response,
         bad_request: 'Field is invalid',
         forbidden: 'You do not have permission to edit a group',
         not_found: 'Group does not exist',
         internal_server_error: 'Server failed to edit / rename the group'
end
Also aliased as: rename
list() click to toggle source

Returns the group list. This request requires read-only user permissions.

@return [Hash]

# File lib/Nessus6/group.rb, line 90
def list
  response = @client.get('groups')
  verify response,
         forbidden: 'You do not have permission to view the groups list'
end
list_users(group_id) click to toggle source

Return the group user list. This request requires administrator user permissions.

@param group_id [String, Fixnum] The unique id of the group. @return [Hash]

# File lib/Nessus6/group.rb, line 101
def list_users(group_id)
  response = @client.get("groups/#{group_id}/users")
  verify response,
         forbidden: 'You do not have permission to view the groups users '\
                    'list',
         not_found: 'Group does not exist'
end
rename(group_id, name)
Alias for: edit