Class: DhApi::Account
- Inherits:
-
Object
- Object
- DhApi::Account
- Defined in:
- lib/dh_api.rb
Constant Summary collapse
- @@host =
'api.dreamhost.com'
Instance Method Summary collapse
- #dns(cmd = 'list', entry = {}) ⇒ Object
-
#domains ⇒ Object
Return Hash of domains objects.
-
#initialize(api_key) ⇒ Account
constructor
A new instance of Account.
-
#users(passwords = false) ⇒ Object
Return Hash of users objects.
Constructor Details
#initialize(api_key) ⇒ Account
Returns a new instance of Account.
10 11 12 |
# File 'lib/dh_api.rb', line 10 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#dns(cmd = 'list', entry = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dh_api.rb', line 29 def dns(cmd='list', entry={}) case cmd when 'list' request('dns-list_records').inject([]){ |dnses, dns| dnses << DNS.new(dns) } when 'add' request('dns-add_record', {'record' => entry['record'], 'type' => entry['type'], 'value' => entry['value']}) when 'remove' request('dns-remove_record', {'record' => entry['record'], 'type' => entry['type'], 'value' => entry['value']}) else raise APIParameterError, 'Unknown DNS command' end end |
#domains ⇒ Object
Return Hash of domains objects
15 16 17 18 19 |
# File 'lib/dh_api.rb', line 15 def domains request('domain-list_domains').inject([]) { |domains, domain| domains << Domain.new(domain) } end |
#users(passwords = false) ⇒ Object
Return Hash of users objects
22 23 24 25 26 27 |
# File 'lib/dh_api.rb', line 22 def users(passwords=false) response = passwords ? request('user-list_users') : request('user-list_users_no_pw') response.inject([]) { |users, user| users << User.new(user) } end |