Class: Dreamy::Base
- Inherits:
-
Object
- Object
- Dreamy::Base
- Defined in:
- lib/dreamy/base.rb
Direct Known Subclasses
Constant Summary collapse
- @@host =
"api.dreamhost.com"
Instance Method Summary collapse
-
#announce_add(listname, domain, email, name = "") ⇒ Object
adds new subscriber to announce list.
-
#announce_list(listname, domain) ⇒ Object
returns an array of subscriber objects.
- #announce_lists ⇒ Object
-
#announce_post(listname, domain, subject, message, name, options = {}) ⇒ Object
options: stamp - the time to send the message, like “2009-05-28” or “2009-05-28 14:24:36” charset - the character set in which the message is encoded type - the format of the message, either “text” or “html” duplicate_ok - whether to allow duplicate messages to be sent, like 1 or 0.
- #announce_remove(listname, domain, email) ⇒ Object
-
#dns ⇒ Object
returns an array of dns objects.
- #dns_add(record, type, value) ⇒ Object
- #dns_remove(record, type, value) ⇒ Object
-
#domains ⇒ Object
returns an array of domain objects.
-
#initialize(username, key) ⇒ Base
constructor
A new instance of Base.
- #mysql_dbs ⇒ Object
- #mysql_hosts ⇒ Object
- #mysql_users ⇒ Object
- #ps ⇒ Object
- #ps_add(type, movedata = "no") ⇒ Object
- #ps_pending ⇒ Object
- #ps_reboot!(name) ⇒ Object
- #ps_reboot_history(name) ⇒ Object
- #ps_remove ⇒ Object
- #ps_set(name, setting, value) ⇒ Object
- #ps_settings(name) ⇒ Object
- #ps_size_history(name) ⇒ Object
- #ps_size_set(name, size) ⇒ Object
- #ps_usage(name) ⇒ Object
-
#users(passwords = false) ⇒ Object
returns an array of user objects.
Constructor Details
#initialize(username, key) ⇒ Base
Returns a new instance of Base.
6 7 8 9 |
# File 'lib/dreamy/base.rb', line 6 def initialize(username, key) @username = username @key = key end |
Instance Method Details
#announce_add(listname, domain, email, name = "") ⇒ Object
adds new subscriber to announce list
62 63 64 65 66 67 |
# File 'lib/dreamy/base.rb', line 62 def announce_add(listname,domain,email,name="") doc = request("announcement_list-add_subscriber", {"listname" => listname, "domain" => domain, "email" => email, "name" => name}) api_error?(doc) true end |
#announce_list(listname, domain) ⇒ Object
returns an array of subscriber objects
55 56 57 58 59 |
# File 'lib/dreamy/base.rb', line 55 def announce_list(listname,domain) doc = request("announcement_list-list_subscribers",{ "listname" => listname, "domain" => domain}) api_error?(doc) (doc/:data).inject([]) { |subs, sub| subs << Subscriber.new_from_xml(sub); subs } end |
#announce_lists ⇒ Object
48 49 50 51 52 |
# File 'lib/dreamy/base.rb', line 48 def announce_lists doc = request("announcement_list-list_lists") api_error?(doc) (doc/:data).inject([]) { |lists, list| lists << AnnounceList.new_from_xml(list); lists } end |
#announce_post(listname, domain, subject, message, name, options = {}) ⇒ Object
options:
stamp - the time to send the message, like "2009-05-28" or "2009-05-28 14:24:36"
charset - the character set in which the message is encoded
type - the format of the message, either "text" or "html"
duplicate_ok - whether to allow duplicate messages to be sent, like 1 or 0
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/dreamy/base.rb', line 81 def announce_post(listname,domain,subject,,name,={}) values = { "listname" => listname, "domain" => domain, "subject" => subject, "message" => , "name" => name }.merge() doc = request("announcement_list-post_announcement", values, true) api_error?(doc) true end |
#announce_remove(listname, domain, email) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/dreamy/base.rb', line 69 def announce_remove(listname,domain,email) doc = request("announcement_list-remove_subscriber", {"listname" => listname, "domain" => domain, "email" => email}) api_error?(doc) true end |
#dns ⇒ Object
returns an array of dns objects
30 31 32 33 34 |
# File 'lib/dreamy/base.rb', line 30 def dns doc = request("dns-list_records") api_error?(doc) (doc/:data).inject([]) { |records, dns| records << Dns.new_from_xml(dns); records } end |
#dns_add(record, type, value) ⇒ Object
36 37 38 39 40 |
# File 'lib/dreamy/base.rb', line 36 def dns_add(record,type,value) doc = request("dns-add_record", {"record" => record, "type" => type, "value" => value}) api_error?(doc) true end |
#dns_remove(record, type, value) ⇒ Object
42 43 44 45 46 |
# File 'lib/dreamy/base.rb', line 42 def dns_remove(record,type,value) doc = request("dns-remove_record", {"record" => record, "type" => type, "value" => value}) api_error?(doc) true end |
#domains ⇒ Object
returns an array of domain objects
12 13 14 15 16 |
# File 'lib/dreamy/base.rb', line 12 def domains doc = request("domain-list_domains") api_error?(doc) (doc/:data).inject([]) { |domains, domain| domains << Domain.new_from_xml(domain); domains } end |
#mysql_dbs ⇒ Object
94 95 96 97 98 |
# File 'lib/dreamy/base.rb', line 94 def mysql_dbs doc = request("mysql-list_dbs") api_error?(doc) (doc/:data).inject([]) { |dbs, db| dbs << MysqlDb.new_from_xml(db); dbs } end |
#mysql_hosts ⇒ Object
100 101 102 103 104 |
# File 'lib/dreamy/base.rb', line 100 def mysql_hosts doc = request("mysql-list_hostnames") api_error?(doc) (doc/:data).inject([]) { |hosts, host| hosts << MysqlHost.new_from_xml(host); hosts } end |
#mysql_users ⇒ Object
106 107 108 109 110 |
# File 'lib/dreamy/base.rb', line 106 def mysql_users doc = request("mysql-list_users") api_error?(doc) (doc/:data).inject([]) { |users, user| users << MysqlUser.new_from_xml(user); users } end |
#ps ⇒ Object
112 113 114 115 116 |
# File 'lib/dreamy/base.rb', line 112 def ps doc = request("dreamhost_ps-list_ps") api_error?(doc) (doc/:data).inject([]) { |servers, server| servers << PrivateServer.new_from_xml(server); servers } end |
#ps_add(type, movedata = "no") ⇒ Object
160 161 162 163 164 |
# File 'lib/dreamy/base.rb', line 160 def ps_add(type,movedata="no") doc = request("dreamhost_ps-add_ps", {"type" => type, "movedata" => movedata}) api_error?(doc) true end |
#ps_pending ⇒ Object
172 173 174 175 176 |
# File 'lib/dreamy/base.rb', line 172 def ps_pending doc = request("dreamhost_ps-list_pending_ps") api_error?(doc) (doc/:data).inject([]) { |pends, pend| pends << PrivateServer.pending_from_xml(pend); pends } end |
#ps_reboot!(name) ⇒ Object
148 149 150 151 152 |
# File 'lib/dreamy/base.rb', line 148 def ps_reboot!(name) doc = request("dreamhost_ps-reboot", {"ps" => name}) api_error?(doc) true end |
#ps_reboot_history(name) ⇒ Object
142 143 144 145 146 |
# File 'lib/dreamy/base.rb', line 142 def ps_reboot_history(name) doc = request("dreamhost_ps-list_reboot_history", {"ps" => name}) api_error?(doc) (doc/:data).inject([]) { |reboots,reboot| reboots << reboot.at('stamp').innerHTML; reboots } end |
#ps_remove ⇒ Object
166 167 168 169 170 |
# File 'lib/dreamy/base.rb', line 166 def ps_remove doc = request("dreamhost_ps-remove_pending_ps") api_error?(doc) true end |
#ps_set(name, setting, value) ⇒ Object
124 125 126 127 128 |
# File 'lib/dreamy/base.rb', line 124 def ps_set(name,setting,value) doc = request("dreamhost_ps-set_settings", {"ps" => name, setting => value}) api_error?(doc) true end |
#ps_settings(name) ⇒ Object
118 119 120 121 122 |
# File 'lib/dreamy/base.rb', line 118 def ps_settings(name) doc = request("dreamhost_ps-list_settings", {"ps" => name}) api_error?(doc) PrivateServer.settings_from_xml(doc) end |
#ps_size_history(name) ⇒ Object
130 131 132 133 134 |
# File 'lib/dreamy/base.rb', line 130 def ps_size_history(name) doc = request("dreamhost_ps-list_size_history", {"ps" => name}) api_error?(doc) (doc/:data).inject([]) { |sizes, size| sizes << PrivateServer.size_from_xml(size); sizes } end |
#ps_size_set(name, size) ⇒ Object
136 137 138 139 140 |
# File 'lib/dreamy/base.rb', line 136 def ps_size_set(name,size) doc = request("dreamhost_ps-set_size", {"ps" => name, "size" => size}) api_error?(doc) true end |
#ps_usage(name) ⇒ Object
154 155 156 157 158 |
# File 'lib/dreamy/base.rb', line 154 def ps_usage(name) doc = request("dreamhost_ps-list_usage", {"ps" => name}) api_error?(doc) (doc/:data).inject([]) { |usages, usage| usages << PrivateServer.usage_from_xml(usage); usages } end |
#users(passwords = false) ⇒ Object
returns an array of user objects
19 20 21 22 23 24 25 26 27 |
# File 'lib/dreamy/base.rb', line 19 def users(passwords=false) if passwords doc = request("user-list_users") else doc = request("user-list_users_no_pw") end api_error?(doc) (doc/:data).inject([]) { |users, user| users << User.new_from_xml(user); users } end |