Class: Squall::Whitelist

Inherits:
Base
  • Object
show all
Defined in:
lib/squall/whitelist.rb

Overview

OnApp Whitelist

Instance Attribute Summary

Attributes inherited from Base

#result, #success

Instance Method Summary (collapse)

Methods inherited from Base

#check_config, #default_params, #key_for_class, #request

Instance Method Details

- (Object) create(user_id, options = {})

Create a whitelist for a user.

Examples:

create ip:          192.168.1.1,
       description: "Computer that someone I trust uses"

Parameters:

  • user_id

    ID of the user

  • options (defaults to: {})

    Params for creating the whitelist:

Options Hash (options):

  • :ip (Object)

    IP to be whitelisted

  • :description (Object)

    Description of the whitelist

Returns:

  • a Hash.



38
39
40
# File 'lib/squall/whitelist.rb', line 38

def create(user_id, options = {})
  request(:post, "/users/#{user_id}/user_white_lists.json", query: { user_white_list: options })
end

- (Object) delete(user_id, id)

Delete a whitelist.

Parameters:

  • user_id

    ID of the user

  • id

    ID of whitelist

Returns:

  • a Hash.



59
60
61
# File 'lib/squall/whitelist.rb', line 59

def delete(user_id, id)
  request(:delete, "/users/#{user_id}/user_white_lists/#{id}.json")
end

- (Object) edit(user_id, id, options = {})

Edit a whitelist.

Parameters:

  • user_id

    ID of the user

  • id

    ID of whitelist

  • options (defaults to: {})

    Params for editing the whitelist, see `#create`

Returns:

  • a Hash.



49
50
51
# File 'lib/squall/whitelist.rb', line 49

def edit(user_id, id, options = {})
  request(:put, "/users/#{user_id}/user_white_lists/#{id}.json", query: { user_white_list: options })
end

- (Object) list(user_id)

Lists all whitelists.

Parameters:

  • user_id

    ID of the user to display whitelists for

Returns:

  • an Array.



9
10
11
12
# File 'lib/squall/whitelist.rb', line 9

def list(user_id)
  response = request(:get, "/users/#{user_id}/user_white_lists.json")
  response.collect { |user| user['user_white_list'] }
end

- (Object) show(user_id, id)

Get the details for a whitelist.

Parameters:

  • user_id

    ID of the user

  • id

    ID of the whitelist

Returns:

  • a Hash.



20
21
22
23
# File 'lib/squall/whitelist.rb', line 20

def show(user_id, id)
  response = request(:get, "/users/#{user_id}/user_white_lists/#{id}.json")
  response['user_white_list']
end