Represent a market user and control their whitelist IPs and roles.
No PRD exists for user requirements. Some initial basic requirements have been created to unblock development
API used to manage this resource
Contact e-mail address (for alerts or notifications from the market)
Creation time
Is this user account deleted?
Deletion time
Is this user account enabled?
IP Addresses from which the user account can be accessed
Label for this user e.g. VPS.Net
Password e.g. 128 character random string
Actual value which will be stored following hash
Roles - one of: User::SUPPLIER, User::TRADER, User::ADMIN or User:RO_ADMIN
per password salt
User name
Market assigned #user_id
Create a new user object
# File lib/onapp_market/admin/user.rb, line 63 def initialize(hash = {}) super(hash, TYPE) # Restrictions restrict [:local_id, :pass_hash, :pass, :salt], [:admin] end
Add a new IP address to the white list
ip - The IP Address to add
OnappMarket::API::Response -added if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 77 def add_white_list_addr(ip) @api.post("/admin/user/#{self.user_id.url_safe}/whitelist", {:ip => ip}) end
Delete all white list IP addresses
OnappMarket::API::Response - all removed if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 100 def del_all_white_list_addrs @api.delete("/admin/user/#{self.user_id.url_safe}/whitelist/delete_all") end
Remove an IP address from the white list
ip - The IP Address to remove
OnappMarket::API::Response - removed if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 89 def del_white_list_addr(ip) @api.post("/admin/user/#{self.user_id.url_safe}/whitelist/delete_set", {:ips => ip}) if ip.is_a?(Array) @api.delete("/admin/user/#{self.user_id.url_safe}/whitelist/#{URI.escape(ip)}") unless ip.is_a?(Array) end
Delete a user from the market
OnappMarket::API::Response - deleted if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 152 def delete @api.delete("/admin/user/#{self.user_id.url_safe}") end
Enable a user account
OnappMarket::API::Response - enabled if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 131 def enable @enabled = true update end
Get a simple array of white list entries
OnappMarket::API::Response - Array of IP addresses if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 110 def get_white_list_addrs @api.get("/admin/user/#{self.user_id.url_safe}/whitelist") end
Suspend a user account
OnappMarket::API::Response - suspended if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 120 def suspend @enabled = false update end
Update a users information
OnappMarket::API::Response - updated if is_ok?
admin
# File lib/onapp_market/admin/user.rb, line 142 def update @api.put("/admin/user/#{self.user_id.url_safe}", OnappMarket::API::Serialize.to_hash(self)) end