linode 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,16 @@
1
1
 
2
+ 0.7.9 / 2012-05-01
3
+ ==================
4
+
5
+ * Version bump to 0.7.9
6
+ * update README to thank Kenn Ejima
7
+ * Improved ruby language highlighting in README. (kenn)
8
+ * Fixed broken error messages in README. (kenn)
9
+ * Switch from Crack to JSON. Do not mutate yamler. (kenn)
10
+ * Remove and ignore Gemfile.lock. (kenn)
11
+ * Do not pollute OpenStruct globally. (kenn)
12
+ * Rspec is now deprecated, use RSpec instead. (kenn)
13
+
2
14
  0.7.8 / 2012-04-26
3
15
  ==================
4
16
 
data/Gemfile CHANGED
@@ -7,4 +7,4 @@ group :test do
7
7
  end
8
8
 
9
9
  gem "httparty"
10
- gem "crack"
10
+ gem "json"
data/README.md CHANGED
@@ -15,258 +15,127 @@ You will need to get an API key (check your account profile).
15
15
 
16
16
  Here is an annoyingly exhaustive IRB session where I play around with the API:
17
17
 
18
- irb> require 'rubygems'
19
- irb> require 'linode'
20
- irb> api_key = 'TOPSECRETAPIKEY'
21
- irb> l = Linode.new(:api_key => api_key)
22
- => #<Linode:0x100e03c @api_key="TOPSECRETAPIKEY">
23
-
24
- irb> result = l.test.echo(:foo => 'bar', :baz => 'xyzzy')
25
- => #<OpenStruct baz="xyzzy", foo="bar">
26
- irb> result.foo
27
- => "bar"
28
-
29
- irb> result.baz
30
- => "xyzzy"
31
-
32
- irb> result = l.avail.datacenters
33
- => [#<OpenStruct datacenterid=2, location="Dallas, TX, USA">, #<OpenStruct datacenterid=3, location="Fremont, CA,
34
- USA">, #<OpenStruct datacenterid=4, location="Atlanta, GA, USA">, #<OpenStruct datacenterid=6, location="Newark, NJ,
35
- USA">]
36
- irb> s = _
37
- => [#<OpenStruct datacenterid=2, location="Dallas, TX, USA">, #<OpenStruct datacenterid=3, location="Fremont, CA,
38
- USA">, #<OpenStruct datacenterid=4, location="Atlanta, GA, USA">, #<OpenStruct datacenterid=6, location="Newark, NJ,
39
- USA">]
40
- irb> result.first
41
- => #<OpenStruct datacenterid=2, location="Dallas, TX, USA">
42
- irb> result.first.location
43
- => "Dallas, TX, USA"
44
- irb> l.avail.datacenters.collect {|i| i.location }
45
- => ["Dallas, TX, USA", "Fremont, CA, USA", "Atlanta, GA, USA", "Newark, NJ, USA"]
46
- irb> l.avail.datacenters.collect {|i| i.datacenterid }
47
- => [2, 3, 4, 6]
48
-
49
- irb> l.user.getapikey(:username => 'me', :password => 'SECKRIT')
50
- => #<OpenStruct api_key="TOPSECRETAPIKEY", username="me">
51
- irb> l.user.getapikey(:username => 'me', :password => 'SECKRIT').api_key
52
- => "TOPSECRETAPIKEY"
53
- irb> l.user.getapikey(:username => 'me', :password => 'SECKRIT').username
54
- => "me"
55
-
56
- irb> l.avail.kernels
57
- => [#<OpenStruct isxen=1, label="2.6.16.38-x86_64-linode2", kernelid=85>, #<OpenStruct isxen=1,
58
- label="2.6.18.8-domU-linode7", kernelid=81>, #<OpenStruct isxen=1, label="2.6.18.8-linode10", kernelid=89>,
59
- #<OpenStruct isxen=1, label="2.6.18.8-linode16", kernelid=98>, #<OpenStruct isxen=1,
60
- label="2.6.18.8-x86_64-linode1", kernelid=86>, #<OpenStruct isxen=1, label="2.6.24.4-linode8", kernelid=84>,
61
- #<OpenStruct isxen=1, label="2.6.25-linode9", kernelid=88>, #<OpenStruct isxen=1, label="2.6.25.10-linode12",
62
- kernelid=90>, #<OpenStruct isxen=1, label="2.6.26-linode13", kernelid=91>, #<OpenStruct isxen=1,
63
- label="2.6.27.4-linode14", kernelid=93>, #<OpenStruct isxen=1, label="2.6.27.4-x86_64-linode3", kernelid=94>,
64
- #<OpenStruct isxen=1, label="2.6.28-linode15", kernelid=96>, #<OpenStruct isxen=1,
65
- label="2.6.28-x86_64-linode4", kernelid=97>, #<OpenStruct isxen=1, label="2.6.28.3-linode17", kernelid=99>,
66
- #<OpenStruct isxen=1, label="2.6.28.3-x86_64-linode5", kernelid=100>, #<OpenStruct isxen=1,
67
- label="2.6.29-linode18", kernelid=101>, #<OpenStruct isxen=1, label="2.6.29-x86_64-linode6", kernelid=102>,
68
- #<OpenStruct isxen=1, label="Latest 2.6 Series (2.6.18.8-linode16)", kernelid=60>, #<OpenStruct isxen=1,
69
- label="pv-grub-x86_32", kernelid=92>, #<OpenStruct isxen=1, label="pv-grub-x86_64", kernelid=95>, #<OpenStruct
70
- isxen=1, label="Recovery - Finnix (kernel)", kernelid=61>]
71
- irb> l.avail.kernels.size
72
- => 21
73
- irb> l.avail.kernels.first
74
- => #<OpenStruct isxen=1, label="2.6.16.38-x86_64-linode2", kernelid=85>
75
- irb> l.avail.kernels.first.label
76
- => "2.6.16.38-x86_64-linode2"
77
-
78
- irb> l.avail.linodeplans
79
- => [#<OpenStruct ram=360, label="Linode 360", avail={"6"=>26, "2"=>57, "3"=>20, "4"=>39}, price=19.95, planid=1,
80
- xfer=200, disk=16>, #<OpenStruct ram=540, label="Linode 540", avail={"6"=>11, "2"=>38, "3"=>14, "4"=>28},
81
- price=29.95, planid=2, xfer=300, disk=24>, #<OpenStruct ram=720, label="Linode 720", avail={"6"=>13, "2"=>27,
82
- "3"=>18, "4"=>30}, price=39.95, planid=3, xfer=400, disk=32>, #<OpenStruct ram=1080, label="Linode 1080",
83
- avail={"6"=>18, "2"=>7, "3"=>9, "4"=>4}, price=59.95, planid=4, xfer=600, disk=48>, #<OpenStruct ram=1440,
84
- label="Linode 1440", avail={"6"=>14, "2"=>5, "3"=>7, "4"=>3}, price=79.95, planid=5, xfer=800, disk=64>,
85
- #<OpenStruct ram=2880, label="Linode 2880", avail={"6"=>3, "2"=>3, "3"=>3, "4"=>3}, price=159.95, planid=6,
86
- xfer=1600, disk=128>, #<OpenStruct ram=5760, label="Linode 5760", avail={"6"=>5, "2"=>6, "3"=>5, "4"=>5},
87
- price=319.95, planid=7, xfer=2000, disk=256>, #<OpenStruct ram=8640, label="Linode 8640", avail={"6"=>5, "2"=>6,
88
- "3"=>5, "4"=>5}, price=479.95, planid=8, xfer=2000, disk=384>, #<OpenStruct ram=11520, label="Linode 11520",
89
- avail={"6"=>5, "2"=>6, "3"=>5, "4"=>5}, price=639.95, planid=9, xfer=2000, disk=512>, #<OpenStruct ram=14400,
90
- label="Linode 14400", avail={"6"=>5, "2"=>6, "3"=>5, "4"=>5}, price=799.95, planid=10, xfer=2000, disk=640>]
91
- irb> l.avail.linodeplans.size
92
- => 10
93
- irb> l.avail.linodeplans.first
94
- => #<OpenStruct ram=360, label="Linode 360", avail={"6"=>26, "2"=>57, "3"=>20, "4"=>39}, price=19.95, planid=1,
95
- xfer=200, disk=16>
96
- irb> l.avail.linodeplans.first.avail
97
- => {"6"=>26, "2"=>57, "3"=>20, "4"=>39}
98
-
99
- irb> l.avail.distributions
100
- => [#<OpenStruct label="Arch Linux 2007.08", minimagesize=436, create_dt="2007-10-24 00:00:00.0", is64bit=0,
101
- distributionid=38>, #<OpenStruct label="Centos 5.0", minimagesize=594, create_dt="2007-04-27 00:00:00.0",
102
- is64bit=0, distributionid=32>, #<OpenStruct label="Centos 5.2", minimagesize=950, create_dt="2008-11-30 00:00:00.0",
103
- is64bit=0, distributionid=46>, #<OpenStruct label="Centos 5.2 64bit", minimagesize=980,
104
- create_dt="2008-11-30 00:00:00.0", is64bit=1, distributionid=47>, #<OpenStruct label="Debian 4.0",
105
- minimagesize=200, create_dt="2007-04-18 00:00:00.0", is64bit=0, distributionid=28>, #<OpenStruct
106
- label="Debian 4.0 64bit", minimagesize=220, create_dt="2008-12-02 00:00:00.0", is64bit=1, distributionid=48>,
107
- #<OpenStruct label="Debian 5.0", minimagesize=200, create_dt="2009-02-19 00:00:00.0", is64bit=0, distributionid=50>,
108
- #<OpenStruct label="Debian 5.0 64bit", minimagesize=300, create_dt="2009-02-19 00:00:00.0", is64bit=1,
109
- distributionid=51>, #<OpenStruct label="Fedora 8", minimagesize=740, create_dt="2007-11-09 00:00:00.0", is64bit=0,
110
- distributionid=40>, #<OpenStruct label="Fedora 9", minimagesize=1175, create_dt="2008-06-09 15:15:21.0", is64bit=0,
111
- distributionid=43>, #<OpenStruct label="Gentoo 2007.0", minimagesize=1800, create_dt="2007-08-29 00:00:00.0",
112
- is64bit=0, distributionid=35>, #<OpenStruct label="Gentoo 2008.0", minimagesize=1500,
113
- create_dt="2009-03-20 00:00:00.0", is64bit=0, distributionid=52>, #<OpenStruct label="Gentoo 2008.0 64bit",
114
- minimagesize=2500, create_dt="2009-04-04 00:00:00.0", is64bit=1, distributionid=53>, #<OpenStruct
115
- label="OpenSUSE 11.0", minimagesize=850, create_dt="2008-08-21 08:32:16.0", is64bit=0, distributionid=44>,
116
- #<OpenStruct label="Slackware 12.0", minimagesize=315, create_dt="2007-07-16 00:00:00.0", is64bit=0,
117
- distributionid=34>, #<OpenStruct label="Slackware 12.2", minimagesize=500, create_dt="2009-04-04 00:00:00.0",
118
- is64bit=0, distributionid=54>, #<OpenStruct label="Ubuntu 8.04 LTS", minimagesize=400,
119
- create_dt="2008-04-23 15:11:29.0", is64bit=0, distributionid=41>, #<OpenStruct label="Ubuntu 8.04 LTS 64bit",
120
- minimagesize=350, create_dt="2008-06-03 12:51:11.0", is64bit=1, distributionid=42>,
121
- #<OpenStruct label="Ubuntu 8.10", minimagesize=220, create_dt="2008-10-30 23:23:03.0", is64bit=0,
122
- distributionid=45>, #<OpenStruct label="Ubuntu 8.10 64bit", minimagesize=230, create_dt="2008-12-02 00:00:00.0",
123
- is64bit=1, distributionid=49>, #<OpenStruct label="Ubuntu 9.04", minimagesize=350,
124
- create_dt="2009-04-23 00:00:00.0", is64bit=0, distributionid=55>, #<OpenStruct label="Ubuntu 9.04 64bit",
125
- minimagesize=350, create_dt="2009-04-23 00:00:00.0", is64bit=1, distributionid=56>]
126
- irb> l.avail.distributions.size
127
- => 22
128
- irb> l.avail.distributions.first
129
- => #<OpenStruct label="Arch Linux 2007.08", minimagesize=436, create_dt="2007-10-24 00:00:00.0", is64bit=0,
130
- distributionid=38>
131
- irb> l.avail.distributions.first.label
132
- => "Arch Linux 2007.08"
133
-
134
- irb> l.domain.resource.list
135
- RuntimeError: Error completing request [domain.resource.list] @ [https://api.linode.com/] with data [{}]:
136
- ERRORCODE6ERRORMESSAGEDOMAINID is required but was not passed in
137
- from ./lib/linode.rb:31:in `send_request'
138
- from ./lib/linode.rb:13:in `list'
139
- from (irb):3
140
- irb> l.domain.resource.list(:DomainId => '1')
141
- RuntimeError: Error completing request [domain.resource.list] @ [https://api.linode.com/] with data
142
- [{:DomainId=>"1"}]: ERRORCODE5ERRORMESSAGEObject not found
143
- from ./lib/linode.rb:31:in `send_request'
144
- from ./lib/linode.rb:13:in `list'
145
- from (irb):5
146
- irb> l.domain.resource.list(:DomainId => '1', :ResourceId => '2')
147
- RuntimeError: Error completing request [domain.resource.list] @ [https://api.linode.com/] with data
148
- [{:DomainId=>"1", :ResourceId=>"2"}]: ERRORCODE5ERRORMESSAGEObject not found
149
- from ./lib/linode.rb:31:in `send_request'
150
- from ./lib/linode.rb:13:in `list'
151
- from (irb):7
152
-
153
- irb> l.linode
154
- => #<Linode::Linode:0x10056e4 @api_url="https://api.linode.com/", @api_key="TOPSECRETAPIKEY">
155
- irb> l.linode.list
156
- => [#<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1,
157
- alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0,
158
- backupweeklyday="", status=1, alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0,
159
- alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152,
160
- alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=4, lpm_displaygroup="", totalxfer=200,
161
- alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5,
162
- backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="bragi", totalram=360, backupwindow=0,
163
- alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15418, totalhd=16384,
164
- alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=2, lpm_displaygroup="", totalxfer=200,
165
- alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5,
166
- backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="nerthus", totalram=360, backupwindow=0,
167
- alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15419, totalhd=16384,
168
- alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=3, lpm_displaygroup="", totalxfer=200,
169
- alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5,
170
- backupsenabled=0, backupweeklyday=0, status=1, alert_cpu_enabled=1, label="hoenir", totalram=360, backupwindow=0,
171
- alert_diskio_threshold=500, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=24405, totalhd=16384,
172
- alert_bwin_enabled=1, alert_bwout_enabled=1>]
173
- irb> l.linode.list.size
174
- => 4
175
- irb> l.linode.list.first
176
- => #<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1, alert_diskio_enabled=1,
177
- watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1,
178
- alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0, alert_diskio_threshold=300,
179
- alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152, alert_bwin_enabled=1,
180
- alert_bwout_enabled=1>
181
- irb> l.linode.list.first.datacenterid
182
- => 6
183
- irb> l.linode.list.first.label
184
- => "byggvir"
185
-
186
- irb(main):003:0* l.linode.config.list
187
- RuntimeError: Error completing request [linode.config.list] @ [https://api.linode.com/] with data [{}]:
188
- ERRORCODE6ERRORMESSAGELINODEID is required but was not passed in
189
- from ./lib/linode.rb:45:in `send_request'
190
- from ./lib/linode.rb:13:in `list'
191
- from (irb):3
192
- irb> l.linode.list
193
- => [#<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1,
194
- alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0,
195
- backupweeklyday="", status=1, alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0,
196
- alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152,
197
- alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=4, lpm_displaygroup="", totalxfer=200,
198
- alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5,
199
- backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="bragi", totalram=360, backupwindow=0,
200
- alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15418, totalhd=16384,
201
- alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=2, lpm_displaygroup="", totalxfer=200,
202
- alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5,
203
- backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="nerthus", totalram=360, backupwindow=0,
204
- alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15419, totalhd=16384,
205
- alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=3, lpm_displaygroup="", totalxfer=200,
206
- alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5,
207
- backupsenabled=0, backupweeklyday=0, status=1, alert_cpu_enabled=1, label="hoenir", totalram=360, backupwindow=0,
208
- alert_diskio_threshold=500, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=24405, totalhd=16384,
209
- alert_bwin_enabled=1, alert_bwout_enabled=1>]
210
- irb> l.linode.list.first
211
- => #<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1, alert_diskio_enabled=1,
212
- watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1,
213
- alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0, alert_diskio_threshold=300,
214
- alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152, alert_bwin_enabled=1,
215
- alert_bwout_enabled=1>
216
- irb> l.linode.list.first.linodeid
217
- => 12446
218
- irb> l.linode.config.list(:LinodeId => 12446)
219
- => [#<OpenStruct helper_disableupdatedb=1, ramlimit=0, kernelid=60, helper_depmod=1, rootdevicecustom="",
220
- disklist="79850,79851,79854,,,,,,", label="byggvir", runlevel="default", rootdevicero=true, configid=43615,
221
- rootdevicenum=1, linodeid=12446, helper_libtls=false, helper_xen=1, comments="">]
222
- irb> l.linode.config.list(:LinodeId => 12446).first.disklist
223
- => "79850,79851,79854,,,,,,"
224
-
225
- irb> l.linode.job.list
226
- RuntimeError: Error completing request [linode.job.list] @ [https://api.linode.com/] with data [{}]:
227
- ERRORCODE6ERRORMESSAGELINODEID is required but was not passed in
228
- from ./lib/linode.rb:45:in `send_request'
229
- from ./lib/linode.rb:13:in `list'
230
- from (irb):7
231
-
232
- irb> l.linode.job.list(:LinodeId => 12446)
233
- => [#<OpenStruct action="linode.boot", jobid=1241724, duration=8, host_finish_dt="2009-07-14 17:07:29.0",
234
- host_message="", linodeid=12446, host_success=1, host_start_dt="2009-07-14 17:07:21.0",
235
- entered_dt="2009-07-14 17:06:25.0", label="System Boot - byggvir">, #<OpenStruct action="linode.shutdown",
236
- jobid=1241723, duration=14, host_finish_dt="2009-07-14 17:07:20.0", host_message="", linodeid=12446, host_success=1,
237
- host_start_dt="2009-07-14 17:07:06.0", entered_dt="2009-07-14 17:06:25.0", label="System Shutdown">,
238
- #<OpenStruct action="linode.boot", jobid=1182441, duration=0, host_finish_dt="2009-06-10 04:27:49.0",
239
- host_message="Linode already running", linodeid=12446, host_success=0, host_start_dt="2009-06-10 04:27:49.0",
240
- entered_dt="2009-06-10 04:26:05.0", label="Lassie initiated boot">, #<OpenStruct action="linode.boot",
241
- jobid=1182436, duration=8, host_finish_dt="2009-06-10 04:27:49.0", host_message="", linodeid=12446, host_success=1,
242
- host_start_dt="2009-06-10 04:27:41.0", entered_dt="1974-01-04 00:00:00.0", label="Host initiated restart">,
243
- #<OpenStruct action="linode.boot", jobid=1182273, duration=0, host_finish_dt="2009-06-10 03:02:31.0",
244
- host_message="Linode already running", linodeid=12446, host_success=0, host_start_dt="2009-06-10 03:02:31.0",
245
- entered_dt="2009-06-10 02:59:49.0", label="Lassie initiated boot">, #<OpenStruct action="linode.boot",
246
- jobid=1182268, duration=8, host_finish_dt="2009-06-10 03:02:31.0", host_message="", linodeid=12446, host_success=1,
247
- host_start_dt="2009-06-10 03:02:23.0", entered_dt="1974-01-04 00:00:00.0", label="Host initiated restart">,
248
- #<OpenStruct action="linode.boot", jobid=1182150, duration=1, host_finish_dt="2009-06-10 01:28:40.0",
249
- host_message="Linode already running", linodeid=12446, host_success=0, host_start_dt="2009-06-10 01:28:39.0",
250
- entered_dt="2009-06-10 01:26:55.0", label="Lassie initiated boot">, #<OpenStruct action="linode.boot",
251
- jobid=1182145, duration=8, host_finish_dt="2009-06-10 01:28:39.0", host_message="", linodeid=12446, host_success=1,
252
- host_start_dt="2009-06-10 01:28:31.0", entered_dt="1974-01-04 00:00:00.0", label="Host initiated restart">]
253
- irb> l.linode.job.list(:LinodeId => 12446).size
254
- => 8
255
-
256
- irb> l.linode.ip.list
257
- RuntimeError: Error completing request [linode.ip.list] @ [https://api.linode.com/] with data [{}]:
258
- ERRORCODE6ERRORMESSAGELINODEID is required but was not passed in
259
- from ./lib/linode.rb:45:in `send_request'
260
- from ./lib/linode.rb:13:in `list'
261
- from (irb):10
262
- irb> l.linode.ip.list(:LinodeId => 12446)
263
- => [#<OpenStruct rdns_name="byggvir.websages.com", ipaddressid=12286, linodeid=12446, ispublic=1,
264
- ipaddress="209.123.234.161">, #<OpenStruct rdns_name="li101-51.members.linode.com", ipaddressid=23981,
265
- linodeid=12446, ispublic=1, ipaddress="97.107.140.51">]
266
- irb> ^D@ Wed Aug 05 01:50:52 rick@Yer-Moms-Computer
18
+ ```ruby
19
+ irb> require 'rubygems'
20
+ irb> require 'linode'
21
+ irb> api_key = 'TOPSECRETAPIKEY'
22
+ irb> l = Linode.new(:api_key => api_key)
23
+ => #<Linode:0x100e03c @api_key="TOPSECRETAPIKEY">
24
+
25
+ irb> result = l.test.echo(:foo => 'bar', :baz => 'xyzzy')
26
+ => #<OpenStruct baz="xyzzy", foo="bar">
27
+ irb> result.foo
28
+ => "bar"
29
+
30
+ irb> result.baz
31
+ => "xyzzy"
32
+
33
+ irb> result = l.avail.datacenters
34
+ => [#<OpenStruct datacenterid=2, location="Dallas, TX, USA">, #<OpenStruct datacenterid=3, location="Fremont, CA, USA">, #<OpenStruct datacenterid=4, location="Atlanta, GA, USA">, #<OpenStruct datacenterid=6, location="Newark, NJ, USA">]
35
+ irb> s = _
36
+ => [#<OpenStruct datacenterid=2, location="Dallas, TX, USA">, #<OpenStruct datacenterid=3, location="Fremont, CA, USA">, #<OpenStruct datacenterid=4, location="Atlanta, GA, USA">, #<OpenStruct datacenterid=6, location="Newark, NJ, USA">]
37
+ irb> result.first
38
+ => #<OpenStruct datacenterid=2, location="Dallas, TX, USA">
39
+ irb> result.first.location
40
+ => "Dallas, TX, USA"
41
+ irb> l.avail.datacenters.collect {|i| i.location }
42
+ => ["Dallas, TX, USA", "Fremont, CA, USA", "Atlanta, GA, USA", "Newark, NJ, USA"]
43
+ irb> l.avail.datacenters.collect {|i| i.datacenterid }
44
+ => [2, 3, 4, 6]
45
+
46
+ irb> l.user.getapikey(:username => 'me', :password => 'SECKRIT')
47
+ => #<OpenStruct api_key="TOPSECRETAPIKEY", username="me">
48
+ irb> l.user.getapikey(:username => 'me', :password => 'SECKRIT').api_key
49
+ => "TOPSECRETAPIKEY"
50
+ irb> l.user.getapikey(:username => 'me', :password => 'SECKRIT').username
51
+ => "me"
52
+
53
+ irb> l.avail.kernels
54
+ => [#<OpenStruct isxen=1, label="2.6.16.38-x86_64-linode2", kernelid=85>, #<OpenStruct isxen=1, label="2.6.18.8-domU-linode7", kernelid=81>, #<OpenStruct isxen=1, label="2.6.18.8-linode10", kernelid=89>, #<OpenStruct isxen=1, label="2.6.18.8-linode16", kernelid=98>, #<OpenStruct isxen=1, label="2.6.18.8-x86_64-linode1", kernelid=86>, #<OpenStruct isxen=1, label="2.6.24.4-linode8", kernelid=84>, #<OpenStruct isxen=1, label="2.6.25-linode9", kernelid=88>, #<OpenStruct isxen=1, label="2.6.25.10-linode12", kernelid=90>, #<OpenStruct isxen=1, label="2.6.26-linode13", kernelid=91>, #<OpenStruct isxen=1, label="2.6.27.4-linode14", kernelid=93>, #<OpenStruct isxen=1, label="2.6.27.4-x86_64-linode3", kernelid=94>, #<OpenStruct isxen=1, label="2.6.28-linode15", kernelid=96>, #<OpenStruct isxen=1, label="2.6.28-x86_64-linode4", kernelid=97>, #<OpenStruct isxen=1, label="2.6.28.3-linode17", kernelid=99>, #<OpenStruct isxen=1, label="2.6.28.3-x86_64-linode5", kernelid=100>, #<OpenStruct isxen=1, label="2.6.29-linode18", kernelid=101>, #<OpenStruct isxen=1, label="2.6.29-x86_64-linode6", kernelid=102>, #<OpenStruct isxen=1, label="Latest 2.6 Series (2.6.18.8-linode16)", kernelid=60>, #<OpenStruct isxen=1, label="pv-grub-x86_32", kernelid=92>, #<OpenStruct isxen=1, label="pv-grub-x86_64", kernelid=95>, #<OpenStruct isxen=1, label="Recovery - Finnix (kernel)", kernelid=61>]
55
+ irb> l.avail.kernels.size
56
+ => 21
57
+ irb> l.avail.kernels.first
58
+ => #<OpenStruct isxen=1, label="2.6.16.38-x86_64-linode2", kernelid=85>
59
+ irb> l.avail.kernels.first.label
60
+ => "2.6.16.38-x86_64-linode2"
61
+
62
+ irb> l.avail.linodeplans
63
+ => [#<OpenStruct ram=360, label="Linode 360", avail={"6"=>26, "2"=>57, "3"=>20, "4"=>39}, price=19.95, planid=1, xfer=200, disk=16>, #<OpenStruct ram=540, label="Linode 540", avail={"6"=>11, "2"=>38, "3"=>14, "4"=>28}, price=29.95, planid=2, xfer=300, disk=24>, #<OpenStruct ram=720, label="Linode 720", avail={"6"=>13, "2"=>27, "3"=>18, "4"=>30}, price=39.95, planid=3, xfer=400, disk=32>, #<OpenStruct ram=1080, label="Linode 1080", avail={"6"=>18, "2"=>7, "3"=>9, "4"=>4}, price=59.95, planid=4, xfer=600, disk=48>, #<OpenStruct ram=1440, label="Linode 1440", avail={"6"=>14, "2"=>5, "3"=>7, "4"=>3}, price=79.95, planid=5, xfer=800, disk=64>, #<OpenStruct ram=2880, label="Linode 2880", avail={"6"=>3, "2"=>3, "3"=>3, "4"=>3}, price=159.95, planid=6, xfer=1600, disk=128>, #<OpenStruct ram=5760, label="Linode 5760", avail={"6"=>5, "2"=>6, "3"=>5, "4"=>5}, price=319.95, planid=7, xfer=2000, disk=256>, #<OpenStruct ram=8640, label="Linode 8640", avail={"6"=>5, "2"=>6, "3"=>5, "4"=>5}, price=479.95, planid=8, xfer=2000, disk=384>, #<OpenStruct ram=11520, label="Linode 11520", avail={"6"=>5, "2"=>6, "3"=>5, "4"=>5}, price=639.95, planid=9, xfer=2000, disk=512>, #<OpenStruct ram=14400, label="Linode 14400", avail={"6"=>5, "2"=>6, "3"=>5, "4"=>5}, price=799.95, planid=10, xfer=2000, disk=640>]
64
+ irb> l.avail.linodeplans.size
65
+ => 10
66
+ irb> l.avail.linodeplans.first
67
+ => #<OpenStruct ram=360, label="Linode 360", avail={"6"=>26, "2"=>57, "3"=>20, "4"=>39}, price=19.95, planid=1,
68
+ xfer=200, disk=16>
69
+ irb> l.avail.linodeplans.first.avail
70
+ => {"6"=>26, "2"=>57, "3"=>20, "4"=>39}
71
+
72
+ irb> l.avail.distributions
73
+ => [#<OpenStruct label="Arch Linux 2007.08", minimagesize=436, create_dt="2007-10-24 00:00:00.0", is64bit=0, distributionid=38>, #<OpenStruct label="Centos 5.0", minimagesize=594, create_dt="2007-04-27 00:00:00.0", is64bit=0, distributionid=32>, #<OpenStruct label="Centos 5.2", minimagesize=950, create_dt="2008-11-30 00:00:00.0", is64bit=0, distributionid=46>, #<OpenStruct label="Centos 5.2 64bit", minimagesize=980, create_dt="2008-11-30 00:00:00.0", is64bit=1, distributionid=47>, #<OpenStruct label="Debian 4.0", minimagesize=200, create_dt="2007-04-18 00:00:00.0", is64bit=0, distributionid=28>, #<OpenStruct label="Debian 4.0 64bit", minimagesize=220, create_dt="2008-12-02 00:00:00.0", is64bit=1, distributionid=48>, #<OpenStruct label="Debian 5.0", minimagesize=200, create_dt="2009-02-19 00:00:00.0", is64bit=0, distributionid=50>, #<OpenStruct label="Debian 5.0 64bit", minimagesize=300, create_dt="2009-02-19 00:00:00.0", is64bit=1, distributionid=51>, #<OpenStruct label="Fedora 8", minimagesize=740, create_dt="2007-11-09 00:00:00.0", is64bit=0, distributionid=40>, #<OpenStruct label="Fedora 9", minimagesize=1175, create_dt="2008-06-09 15:15:21.0", is64bit=0, distributionid=43>, #<OpenStruct label="Gentoo 2007.0", minimagesize=1800, create_dt="2007-08-29 00:00:00.0", is64bit=0, distributionid=35>, #<OpenStruct label="Gentoo 2008.0", minimagesize=1500, create_dt="2009-03-20 00:00:00.0", is64bit=0, distributionid=52>, #<OpenStruct label="Gentoo 2008.0 64bit", minimagesize=2500, create_dt="2009-04-04 00:00:00.0", is64bit=1, distributionid=53>, #<OpenStruct label="OpenSUSE 11.0", minimagesize=850, create_dt="2008-08-21 08:32:16.0", is64bit=0, distributionid=44>, #<OpenStruct label="Slackware 12.0", minimagesize=315, create_dt="2007-07-16 00:00:00.0", is64bit=0, distributionid=34>, #<OpenStruct label="Slackware 12.2", minimagesize=500, create_dt="2009-04-04 00:00:00.0", is64bit=0, distributionid=54>, #<OpenStruct label="Ubuntu 8.04 LTS", minimagesize=400, create_dt="2008-04-23 15:11:29.0", is64bit=0, distributionid=41>, #<OpenStruct label="Ubuntu 8.04 LTS 64bit", minimagesize=350, create_dt="2008-06-03 12:51:11.0", is64bit=1, distributionid=42>, #<OpenStruct label="Ubuntu 8.10", minimagesize=220, create_dt="2008-10-30 23:23:03.0", is64bit=0, distributionid=45>, #<OpenStruct label="Ubuntu 8.10 64bit", minimagesize=230, create_dt="2008-12-02 00:00:00.0", is64bit=1, distributionid=49>, #<OpenStruct label="Ubuntu 9.04", minimagesize=350, create_dt="2009-04-23 00:00:00.0", is64bit=0, distributionid=55>, #<OpenStruct label="Ubuntu 9.04 64bit", minimagesize=350, create_dt="2009-04-23 00:00:00.0", is64bit=1, distributionid=56>]
74
+ irb> l.avail.distributions.size
75
+ => 22
76
+ irb> l.avail.distributions.first
77
+ => #<OpenStruct label="Arch Linux 2007.08", minimagesize=436, create_dt="2007-10-24 00:00:00.0", is64bit=0,
78
+ distributionid=38>
79
+ irb> l.avail.distributions.first.label
80
+ => "Arch Linux 2007.08"
81
+
82
+ irb> l.domain.resource.list
83
+ RuntimeError: Errors completing request [domain.resource.list] @ [https://api.linode.com/] with data [{}]:
84
+ - Error #6 - DOMAINID is required but was not passed in. (Please consult http://www.linode.com/api/dns/domain.resource.list)
85
+ irb> l.domain.resource.list(:DomainId => '1')
86
+ RuntimeError: Errors completing request [domain.resource.list] @ [https://api.linode.com/] with data [{:DomainId=>"1"}]:
87
+ - Error #5 - Object not found. (Please consult http://www.linode.com/api/dns/domain.resource.list)
88
+ irb> l.domain.resource.list(:DomainId => '1', :ResourceId => '2')
89
+ RuntimeError: Errors completing request [domain.resource.list] @ [https://api.linode.com/] with data [{:DomainId=>"1", :ResourceId=>"2"}]:
90
+ - Error #5 - Object not found. (Please consult http://www.linode.com/api/dns/domain.resource.list)
91
+
92
+ irb> l.linode
93
+ => #<Linode::Linode:0x10056e4 @api_url="https://api.linode.com/", @api_key="TOPSECRETAPIKEY">
94
+ irb> l.linode.list
95
+ => [#<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152, alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=4, lpm_displaygroup="", totalxfer=200, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="bragi", totalram=360, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15418, totalhd=16384, alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=2, lpm_displaygroup="", totalxfer=200, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="nerthus", totalram=360, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15419, totalhd=16384, alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=3, lpm_displaygroup="", totalxfer=200, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday=0, status=1, alert_cpu_enabled=1, label="hoenir", totalram=360, backupwindow=0, alert_diskio_threshold=500, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=24405, totalhd=16384, alert_bwin_enabled=1, alert_bwout_enabled=1>]
96
+ irb> l.linode.list.size
97
+ => 4
98
+ irb> l.linode.list.first
99
+ => #<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152, alert_bwin_enabled=1, alert_bwout_enabled=1>
100
+ irb> l.linode.list.first.datacenterid
101
+ => 6
102
+ irb> l.linode.list.first.label
103
+ => "byggvir"
104
+
105
+ irb> l.linode.config.list
106
+ RuntimeError: Errors completing request [linode.config.list] @ [https://api.linode.com/] with data [{}]:
107
+ - Error #6 - LINODEID is required but was not passed in. (Please consult http://www.linode.com/api/linode/linode.config.list)
108
+ irb> l.linode.list
109
+ => [#<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152, alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=4, lpm_displaygroup="", totalxfer=200, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="bragi", totalram=360, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15418, totalhd=16384, alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=2, lpm_displaygroup="", totalxfer=200, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="nerthus", totalram=360, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=15419, totalhd=16384, alert_bwin_enabled=1, alert_bwout_enabled=1>, #<OpenStruct datacenterid=3, lpm_displaygroup="", totalxfer=200, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday=0, status=1, alert_cpu_enabled=1, label="hoenir", totalram=360, backupwindow=0, alert_diskio_threshold=500, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=24405, totalhd=16384,alert_bwin_enabled=1, alert_bwout_enabled=1>]
110
+ irb> l.linode.list.first
111
+ => #<OpenStruct datacenterid=6, lpm_displaygroup="", totalxfer=600, alert_bwquota_enabled=1, alert_diskio_enabled=1, watchdog=1, alert_cpu_threshold=90, alert_bwout_threshold=5, backupsenabled=0, backupweeklyday="", status=1, alert_cpu_enabled=1, label="byggvir", totalram=1080, backupwindow=0, alert_diskio_threshold=300, alert_bwin_threshold=5, alert_bwquota_threshold=80, linodeid=12446, totalhd=49152, alert_bwin_enabled=1, alert_bwout_enabled=1>
112
+ irb> l.linode.list.first.linodeid
113
+ => 12446
114
+ irb> l.linode.config.list(:LinodeId => 12446)
115
+ => [#<OpenStruct helper_disableupdatedb=1, ramlimit=0, kernelid=60, helper_depmod=1, rootdevicecustom="", disklist="79850,79851,79854,,,,,,", label="byggvir", runlevel="default", rootdevicero=true, configid=43615, rootdevicenum=1, linodeid=12446, helper_libtls=false, helper_xen=1, comments="">]
116
+ irb> l.linode.config.list(:LinodeId => 12446).first.disklist
117
+ => "79850,79851,79854,,,,,,"
118
+
119
+ irb> l.linode.job.list
120
+ RuntimeError: Errors completing request [linode.job.list] @ [https://api.linode.com/] with data [{}]:
121
+ - Error #6 - LINODEID is required but was not passed in. (Please consult http://www.linode.com/api/linode/linode.job.list)
122
+
123
+ irb> l.linode.job.list(:LinodeId => 12446)
124
+ => [#<OpenStruct action="linode.boot", jobid=1241724, duration=8, host_finish_dt="2009-07-14 17:07:29.0", host_message="", linodeid=12446, host_success=1, host_start_dt="2009-07-14 17:07:21.0", entered_dt="2009-07-14 17:06:25.0", label="System Boot - byggvir">, #<OpenStruct action="linode.shutdown", jobid=1241723, duration=14, host_finish_dt="2009-07-14 17:07:20.0", host_message="", linodeid=12446, host_success=1, host_start_dt="2009-07-14 17:07:06.0", entered_dt="2009-07-14 17:06:25.0", label="System Shutdown">, #<OpenStruct action="linode.boot", jobid=1182441, duration=0, host_finish_dt="2009-06-10 04:27:49.0", host_message="Linode already running", linodeid=12446, host_success=0, host_start_dt="2009-06-10 04:27:49.0", entered_dt="2009-06-10 04:26:05.0", label="Lassie initiated boot">, #<OpenStruct action="linode.boot", jobid=1182436, duration=8, host_finish_dt="2009-06-10 04:27:49.0", host_message="", linodeid=12446, host_success=1, host_start_dt="2009-06-10 04:27:41.0", entered_dt="1974-01-04 00:00:00.0", label="Host initiated restart">, #<OpenStruct action="linode.boot", jobid=1182273, duration=0, host_finish_dt="2009-06-10 03:02:31.0", host_message="Linode already running", linodeid=12446, host_success=0, host_start_dt="2009-06-10 03:02:31.0", entered_dt="2009-06-10 02:59:49.0", label="Lassie initiated boot">, #<OpenStruct action="linode.boot", jobid=1182268, duration=8, host_finish_dt="2009-06-10 03:02:31.0", host_message="", linodeid=12446, host_success=1, host_start_dt="2009-06-10 03:02:23.0", entered_dt="1974-01-04 00:00:00.0", label="Host initiated restart">, #<OpenStruct action="linode.boot", jobid=1182150, duration=1, host_finish_dt="2009-06-10 01:28:40.0", host_message="Linode already running", linodeid=12446, host_success=0, host_start_dt="2009-06-10 01:28:39.0", entered_dt="2009-06-10 01:26:55.0", label="Lassie initiated boot">, #<OpenStruct action="linode.boot", jobid=1182145, duration=8, host_finish_dt="2009-06-10 01:28:39.0", host_message="", linodeid=12446, host_success=1, host_start_dt="2009-06-10 01:28:31.0", entered_dt="1974-01-04 00:00:00.0", label="Host initiated restart">]
125
+ irb> l.linode.job.list(:LinodeId => 12446).size
126
+ => 8
127
+
128
+ irb> l.linode.ip.list
129
+ RuntimeError: Errors completing request [linode.ip.list] @ [https://api.linode.com/] with data [{}]:
130
+ - Error #6 - LINODEID is required but was not passed in. (Please consult http://www.linode.com/api/linode/linode.ip.list)
131
+ irb> l.linode.ip.list(:LinodeId => 12446)
132
+ => [#<OpenStruct rdns_name="byggvir.websages.com", ipaddressid=12286, linodeid=12446, ispublic=1, ipaddress="209.123.234.161">, #<OpenStruct rdns_name="li101-51.members.linode.com", ipaddressid=23981, linodeid=12446, ispublic=1, ipaddress="97.107.140.51">]
133
+ irb> ^D@ Wed Aug 05 01:50:52 rick@Yer-Moms-Computer
134
+ ```
267
135
 
268
136
  ## CREDITS:
269
137
 
138
+ * Thanks to Kenn Ejima ([kenn](http://github.com/kenn)) for json library improvements, OStruct cleanups, README improvements, etc.
270
139
  * Thanks to Aditya Sanghi ([asanghi](http://github.com/asanghi)) for a patch to properly namespace stackscripts functionality.
271
140
  * Thanks to Dan Hodos ([danhodos](http://github.com/danhodos)) for diagnosing and fixing an issue with sending GET requests instead of POST request.
272
141
  * Thanks to Aaron Hamid for updates for RSpec 2 and work on user.getapikey + username/password initialization.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.8
1
+ 0.7.9
data/lib/linode.rb CHANGED
@@ -1,13 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'ostruct'
3
- require 'ostruct_tweak'
4
3
  require 'httparty'
5
- require 'crack'
6
-
7
- begin
8
- YAML::ENGINE.yamler = 'syck'
9
- rescue # see: https://github.com/rick/linode/issues/12
10
- end
4
+ require 'json'
11
5
 
12
6
  class Linode
13
7
  attr_reader :username, :password
@@ -96,7 +90,7 @@ class Linode
96
90
  end
97
91
 
98
92
  def post(data)
99
- Crack::JSON.parse(HTTParty.post(api_url, :body => data))
93
+ JSON.parse(HTTParty.post(api_url, :body => data))
100
94
  end
101
95
 
102
96
  def error?(response)
@@ -122,7 +116,16 @@ class Linode
122
116
  item[k.downcase] = item[k]
123
117
  item.delete(k) if k != k.downcase
124
118
  end
125
- ::OpenStruct.new(item)
119
+ Linode::OpenStruct.new(item)
120
+ end
121
+
122
+ # some of our Linode API data results include a 'type' data member.
123
+ # OpenStruct will have problems providing a .type method, so we special-case this.
124
+ #
125
+ class OpenStruct < ::OpenStruct
126
+ def type
127
+ @table[:type]
128
+ end
126
129
  end
127
130
  end
128
131
 
data/linode.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "linode"
8
- s.version = "0.7.8"
8
+ s.version = "0.7.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rick Bradley"]
12
- s.date = "2012-04-26"
12
+ s.date = "2012-05-01"
13
13
  s.description = "This is a wrapper around Linode's automation facilities."
14
14
  s.email = "rick@rickbradley.com"
15
15
  s.extra_rdoc_files = [
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  ".rspec",
20
20
  "CHANGELOG",
21
21
  "Gemfile",
22
- "Gemfile.lock",
23
22
  "MIT-LICENSE",
24
23
  "README.md",
25
24
  "Rakefile",
@@ -40,7 +39,6 @@ Gem::Specification.new do |s|
40
39
  "lib/linode/stackscript.rb",
41
40
  "lib/linode/test.rb",
42
41
  "lib/linode/user.rb",
43
- "lib/ostruct_tweak.rb",
44
42
  "linode.gemspec",
45
43
  "spec/linode/avail_spec.rb",
46
44
  "spec/linode/domain/resource_spec.rb",
@@ -69,18 +67,18 @@ Gem::Specification.new do |s|
69
67
 
70
68
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
71
69
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
72
- s.add_runtime_dependency(%q<crack>, [">= 0"])
70
+ s.add_runtime_dependency(%q<json>, [">= 0"])
73
71
  s.add_runtime_dependency(%q<httparty>, [">= 0.4.4"])
74
72
  s.add_runtime_dependency(%q<crack>, [">= 0.3.1"])
75
73
  else
76
74
  s.add_dependency(%q<httparty>, [">= 0"])
77
- s.add_dependency(%q<crack>, [">= 0"])
75
+ s.add_dependency(%q<json>, [">= 0"])
78
76
  s.add_dependency(%q<httparty>, [">= 0.4.4"])
79
77
  s.add_dependency(%q<crack>, [">= 0.3.1"])
80
78
  end
81
79
  else
82
80
  s.add_dependency(%q<httparty>, [">= 0"])
83
- s.add_dependency(%q<crack>, [">= 0"])
81
+ s.add_dependency(%q<json>, [">= 0"])
84
82
  s.add_dependency(%q<httparty>, [">= 0.4.4"])
85
83
  s.add_dependency(%q<crack>, [">= 0.3.1"])
86
84
  end
data/spec/spec_helper.rb CHANGED
@@ -15,7 +15,7 @@ rescue LoadError
15
15
  require 'mocha'
16
16
  end
17
17
 
18
- Rspec.configure do |config|
18
+ RSpec.configure do |config|
19
19
  config.mock_with :mocha
20
20
  end
21
21
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linode
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 8
10
- version: 0.7.8
9
+ - 9
10
+ version: 0.7.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rick Bradley
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-26 00:00:00 Z
18
+ date: 2012-05-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  - 0
43
43
  version: "0"
44
44
  version_requirements: *id002
45
- name: crack
45
+ name: json
46
46
  prerelease: false
47
47
  type: :runtime
48
48
  - !ruby/object:Gem::Dependency
@@ -89,7 +89,6 @@ files:
89
89
  - .rspec
90
90
  - CHANGELOG
91
91
  - Gemfile
92
- - Gemfile.lock
93
92
  - MIT-LICENSE
94
93
  - README.md
95
94
  - Rakefile
@@ -110,7 +109,6 @@ files:
110
109
  - lib/linode/stackscript.rb
111
110
  - lib/linode/test.rb
112
111
  - lib/linode/user.rb
113
- - lib/ostruct_tweak.rb
114
112
  - linode.gemspec
115
113
  - spec/linode/avail_spec.rb
116
114
  - spec/linode/domain/resource_spec.rb
data/Gemfile.lock DELETED
@@ -1,27 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- crack (0.1.8)
5
- diff-lcs (1.1.2)
6
- httparty (0.7.8)
7
- crack (= 0.1.8)
8
- mocha (0.9.12)
9
- rake (0.8.7)
10
- rspec (2.4.0)
11
- rspec-core (~> 2.4.0)
12
- rspec-expectations (~> 2.4.0)
13
- rspec-mocks (~> 2.4.0)
14
- rspec-core (2.4.0)
15
- rspec-expectations (2.4.0)
16
- diff-lcs (~> 1.1.2)
17
- rspec-mocks (2.4.0)
18
-
19
- PLATFORMS
20
- ruby
21
-
22
- DEPENDENCIES
23
- crack
24
- httparty
25
- mocha
26
- rake (= 0.8.7)
27
- rspec (= 2.4.0)
data/lib/ostruct_tweak.rb DELETED
@@ -1,8 +0,0 @@
1
- # some of our Linode API data results include a 'type' data member.
2
- # OpenStruct will have problems providing a .type method, so we special-case this.
3
-
4
- class OpenStruct
5
- def type
6
- @table[:type]
7
- end
8
- end