rest_connection 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ Jeweler::Tasks.new do |gemspec|
4
4
  gemspec.name = "rest_connection"
5
5
  gemspec.summary = "Modular RESTful API library"
6
6
  gemspec.description = "A Modular RESTful API library. Current implemented modules: RightScale API"
7
- gemspec.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"]
7
+ gemspec.email = ["daniel.onorato@rightscale.com"]
8
8
  gemspec.homepage = "http://github.com/rightscale/rest_connection"
9
9
  gemspec.authors = ["Jeremy Deininger", "Timothy Rodriguez"]
10
10
  gemspec.add_dependency('activesupport', "=2.3.10")
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.5
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ puts <<EOS
3
+ ..,ONMMMMMO.
4
+ NM8~:~:.,+NMM=
5
+ MO .MM:
6
+ NM. ,MN
7
+ .. .7MN . . 8M,
8
+ ==. ?N: .MMN .,,.. 8$ZZ.~MN
9
+ .$. N8 ,DD. ,MMN ...+:. .MMM
10
+ D 8D.Z= .$. NMMM..,~8I ,88+. MMMM:.
11
+ ,~... ,MM .N . MMMM7. .... MMMMM,
12
+ DZ.. .:OZ.:M. ..8= .MMMM. .OMMMMM
13
+ :7 . 8+$M:.D+ +MMMM, .:N+,MMD: 7MMMMM.
14
+ .MM7:.... 8 .M. 7MMMMM. MMMMZMMMMO.7MMMMM.
15
+ ,?. .. ..8 ,M =MMMMM MMN8$7O8DMM.OMMM~ +.
16
+ N.. . .+ M, .MMMMMOM M8. .OM.MIMMMZ =,.
17
+ =NZI+~, + I8 .MMMMMMM= .=DD, MMMMMI ~~
18
+ O. .N + M. IMMMMMMMMMD ~MN 7MMMMMMM .Z
19
+ .MNZZNMZ. . MM 7MMMMMMMMMMMMMMMMMMMMMMMM, .~M,.
20
+ ID=. . . MMI MMMMMMMMMMMMMMMMMMMMMMMMMD. .+N
21
+ .DMO,ZND+. MMM. :MMMMMMMMN =MMMMMMMMN:ZMMM,. +M~,$OD$
22
+ .MMO... MMM OMMMMMMMM~ . ,I++O7. OMMM= .IM7 . .=..+MNI.
23
+ .8MO :MMM .MMMMMMMMMM. MMMMM= ~D ?MO:7MN...
24
+ +$ON. $NMM .NMMMMMMMMM7. .MMMMM. .8Z. :7N...MM:
25
+ O7?N M+MMNMMMMMMMMMMMMMMMMMN MMMMMM8D. . $, .$8 M ..,$MN~,,.
26
+ N$:=M. .NM.MM. ?MMMMMMO. .. D IO$IM:D.,$O, ,. O.I,Z :M: .+MI
27
+ MO, MMI ..NM8.MM. =. MM..IMN7,. .,IDN7~MMMMMM, N .Z N.M. ,M. =N.
28
+ .MO. MMMMMMMM::MM .: . .M :+I?=D.~.MMMMMMM?,,~INMMNNM+ ~ ~. D8. ,8.
29
+ .M8. MMMMMMMM ZM$. 8 7. ~ M,MM+MMMMMMMMMMMMMMM.. , : ,M. .O+
30
+ .MO. MMMMMMMI.MM, N = .....,IDI. MMMMMMMM8MMMMMM.. = M+ .M.
31
+ .MZ~.MMMMMMM..MM . N .=. ?M,NMMMMMM?~MM$IMMM7MMMMM7 :O M
32
+ M7I.NMMMMM8.$MZ.~ 8 .~, : MMMMMMMMMMMMM.~OOIMMM+MMMMM, .N M
33
+ N=D OMMMMM, MM O .I .7. MMMMMMMMMMMMMMMMMMMMMD7NMM:MMMMN D .M
34
+ O:M,~MMMMD NM? D.=, 8 OMMMMMMMMMMMMMMMMMMMMMZZMM?MMMM: ... Z .M
35
+ +=M$ MMMZ :MN ~, D. I. ~MMMMMMM+,,~I, .NMMMMMZ.MDNMM7 I. . .M.
36
+ .$NM .,.. MM .M :N. :~ .MMMMMM. MMMMMMZ=M,MM. .M. 7M
37
+ .N.MM~ $MZ. O. N? N. ,MMMMMMM. MMMMMMMM+8Z: NZ. . .MI.
38
+ .M.=MMMMN.. .+=..M. M. NMMMMMMMD 8MMMMMMM.MMM. $M. . ?, ~M.
39
+ +. ~MM .. $, M: N: . 7MMMMMMN .~MMMMMM8,MMMMMMMMMMM ..M. :MM
40
+ D N . ,M N NN. I8. $MMMMMMM?.. .?MMMMMMM?OMMMMMMMMMMMMMMMMMMMMI . ...MM$
41
+ 7? .?N.7O DM ,M ZMMMMMMMMMM7.IMMMMMMMMD$MMMMMMMMMMMMMMMMMMMMMMMMZ: IMMN.
42
+ .~MM?.=NM~DM8.. M 8MMMMMMMMMMMMMMMMM7=MMMMMMMMMMMMMMMMMD.IMMMNZZNMMN~
43
+ EOS
@@ -0,0 +1,21 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+ #
16
+ class AlertSpecSubject
17
+ include RightScale::Api::Base
18
+ extend RightScale::Api::BaseExtend
19
+
20
+ deny_methods :index, :destroy, :update, :show
21
+ end
@@ -0,0 +1,70 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ #
17
+ # You must have Beta v1.5 API access to use these internal API calls.
18
+ #
19
+ class Backup
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ deny_methods :index
24
+
25
+ def self.filters
26
+ [:cloud_href, :committed, :completed, :from_master, :latest_before]
27
+ end
28
+
29
+ def self.find_all(lineage)
30
+ index(lineage)
31
+ end
32
+
33
+ def self.find_with_filter(lineage, filter={})
34
+ index(lineage, filter)
35
+ end
36
+
37
+ def self.index(lineage, filter={})
38
+ filter_params = []
39
+ filter.each { |key,val|
40
+ unless self.filters.include?(key.to_sym)
41
+ raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}")
42
+ end
43
+ filter_params << "#{key}==#{val}"
44
+ }
45
+
46
+ a = Array.new
47
+ url = self.resource_plural_name
48
+ hsh = {'lineage' => lineage}
49
+ hsh.merge(:filter => filter_params) unless filter_params.empty?
50
+ connection.get(url, hsh).each do |object|
51
+ a << self.new(object)
52
+ end
53
+
54
+ return a
55
+ end
56
+
57
+ def self.cleanup(lineage, keep_last, params={})
58
+ params.merge!('keep_last' => keep_last, 'lineage' => lineage)
59
+ connection.post(resource_plural_name + "/cleanup", params)
60
+ end
61
+
62
+ def restore(instance_href, name=nil, description=nil)
63
+ uri = URI.parse(self.href)
64
+ params = {'instance_href' => instance_href}
65
+ params.deep_merge!({'backup' => {'name' => name}}) if name
66
+ params.deep_merge!({'backup' => {'description' => description}}) if description
67
+ location = connection.post(uri.path + "/restore", params)
68
+ Task.new('href' => location)
69
+ end
70
+ end
@@ -0,0 +1,39 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ #
17
+ # You must have Beta v1.5 API access to use these internal API calls.
18
+ #
19
+ class CloudAccount
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ deny_methods :update
24
+
25
+ def cloud_id
26
+ self.cloud.split("/").last
27
+ end
28
+
29
+ def create(opts)
30
+ location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts)
31
+ if location =~ /aws/
32
+ return "AWS Cloud Added successfully"
33
+ else
34
+ newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ])
35
+ newrecord.reload
36
+ return newrecord
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,43 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ class Ec2ServerArray
17
+ include RightScale::Api::Base
18
+ extend RightScale::Api::BaseExtend
19
+ include RightScale::Api::Taggable
20
+ extend RightScale::Api::TaggableExtend
21
+
22
+ deny_methods :index, :show, :create, :update, :destroy
23
+
24
+ def run_script_on_instances(script, ec2_instance_hrefs=[], opts={})
25
+ uri = URI.parse(self.href)
26
+ case script
27
+ when Executable then script = script.right_script
28
+ when String then script = RightScript.new('href' => script)
29
+ end
30
+
31
+ params = {:right_script_href => script.href}
32
+ unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty?
33
+ params[:ec2_instance_hrefs] = ec2_instance_hrefs
34
+ end
35
+ unless opts.nil? || opts.empty?
36
+ params[:parameters] = opts
37
+ end
38
+ params = {:ec2_server_array => params}
39
+ connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit|
40
+ Status.new('href' => location)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,101 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ #
17
+ # You must have Beta v1.5 API access to use these internal API calls.
18
+ #
19
+ class McAuditEntry
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ deny_methods :destroy, :index
24
+
25
+ def resource_plural_name
26
+ "audit_entries"
27
+ end
28
+
29
+ def resource_singular_name
30
+ "audit_entry"
31
+ end
32
+
33
+ def self.resource_plural_name
34
+ "audit_entries"
35
+ end
36
+
37
+ def self.resource_singular_name
38
+ "audit_entry"
39
+ end
40
+
41
+ def self.filters
42
+ [:auditee_href, :user_email]
43
+ end
44
+
45
+ def self.find_all(start_date=nil, end_date=nil, limit=1000)
46
+ start_date ||= (Time.now.utc - (60*60*24*31)).strftime(RightScale::Api::DATETIME_FMT)
47
+ end_date ||= Time.now.utc.strftime(RightScale::Api::DATETIME_FMT)
48
+ index(start_date, end_date, limit)
49
+ end
50
+
51
+ def self.find_with_filter(start_date, end_date, limit, filter)
52
+ index(start_date, end_date, limit, filter)
53
+ end
54
+
55
+ def self.index(start_date, end_date, limit=1000, filter={})
56
+ # Validate index params
57
+ ex_fmt = "2011/06/25 00:00:00 +0000"
58
+ regex = /^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-]\d{4})$/
59
+ unless start_date =~ regex
60
+ raise ArgumentError.new("start_date doesn't match format. e.g., #{ex_fmt}")
61
+ end
62
+ unless end_date =~ regex
63
+ raise ArgumentError.new("end_date doesn't match format. e.g., #{ex_fmt}")
64
+ end
65
+ unless (1..1000) === limit.to_i
66
+ raise ArgumentError.new("limit is not within the range of 1..1000")
67
+ end
68
+ filter_params = []
69
+ filter.each { |key,val|
70
+ unless self.filters.include?(key.to_sym)
71
+ raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}")
72
+ end
73
+ filter_params << "#{key}==#{val}"
74
+ }
75
+
76
+ a = Array.new
77
+ url = self.resource_plural_name
78
+ if filter_params.empty?
79
+ connection.get(url).each do |object|
80
+ a << self.new(object)
81
+ end
82
+ else
83
+ connection.get(url, :filter => filter_params).each do |object|
84
+ a << self.new(object)
85
+ end
86
+ end
87
+
88
+ return a
89
+ end
90
+
91
+ def append(detail, offset)
92
+ uri = URI.parse(self.href)
93
+ connection.post(uri.path + "/append", 'detail' => detail, 'offset' => offset)
94
+ end
95
+
96
+ def detail
97
+ uri = URI.parse(self.href)
98
+ res = connection.post(uri.path + "/detail")
99
+ return res.body
100
+ end
101
+ end
@@ -0,0 +1,50 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ #
17
+ # You must have Beta v1.5 API access to use these internal API calls.
18
+ #
19
+
20
+ class McServerTemplateMultiCloudImage
21
+ include RightScale::Api::Gateway
22
+ extend RightScale::Api::GatewayExtend
23
+
24
+ deny_methods :update
25
+
26
+ def resource_plural_name
27
+ "server_template_multi_cloud_images"
28
+ end
29
+
30
+ def resource_singular_name
31
+ "server_template_multi_cloud_image"
32
+ end
33
+
34
+ def self.resource_plural_name
35
+ "server_template_multi_cloud_images"
36
+ end
37
+
38
+ def self.resource_singular_name
39
+ "server_template_multi_cloud_image"
40
+ end
41
+
42
+ def self.filters
43
+ [:is_default, :multi_cloud_image_href, :server_template_href]
44
+ end
45
+
46
+ def make_default
47
+ my_href = URI.parse(self.href)
48
+ connection.post(my_href + "/make_default")
49
+ end
50
+ end
@@ -0,0 +1,92 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require 'rest-client'
17
+ RestClient.log = ENV["REST_CONNECTION_LOG"] || "stdout"
18
+
19
+ class RightScriptAttachmentInternal
20
+ include RightScale::Api::Base
21
+ extend RightScale::Api::BaseExtend
22
+ include RightScale::Api::Internal
23
+ extend RightScale::Api::InternalExtend
24
+
25
+ deny_methods :index, :create, :update
26
+
27
+ def resource_plural_name
28
+ "right_script_attachments"
29
+ end
30
+
31
+ def resource_singular_name
32
+ "right_script_attachment"
33
+ end
34
+
35
+ def self.resource_plural_name
36
+ "right_script_attachments"
37
+ end
38
+
39
+ def self.resource_singular_name
40
+ "right_script_attachment"
41
+ end
42
+
43
+ def self.get_s3_upload_params(right_script_href)
44
+ url = self.resource_plural_name + "/get_s3_upload_params"
45
+ params = {"right_script_href" => right_script_href}
46
+ params = {self.resource_singular_name => params}
47
+ connection.get(url, params)
48
+ end
49
+
50
+ =begin
51
+ def self.upload(filepath, right_script_href)
52
+ hsh = get_s3_upload_params(right_script_href)
53
+ params = {}
54
+ hsh.keys.each { |k| params[k.gsub(/-/,"_").to_sym] = hsh[k] }
55
+ params[:file] = File.new(filepath, 'rb')
56
+ req = RestClient::Request.new({
57
+ :method => :post,
58
+ :url => hsh["url"],
59
+ :payload => params,
60
+ :multipart => true,
61
+ })
62
+ s = req.payload.to_s
63
+ splitter = s.split("\r\n").first
64
+ a = s.split(/#{splitter}-?-?\r\n/)
65
+ a.push(a.delete(a.detect { |n| n =~ %r{name="file";} }))
66
+ new_payload = a.join(splitter + "\r\n") + splitter + "--\r\n"
67
+
68
+ uri = URI.parse(hsh["url"])
69
+ net_http = Net::HTTP::Post.new(uri.request_uri)
70
+ req.transmit(uri, net_http, new_payload)
71
+ # TODO: Precondition Failing
72
+
73
+ callback_uri = URI.parse(hsh["success_action_redirect"])
74
+ connection.get(callback_uri.request_uri)
75
+ end
76
+ =end
77
+
78
+ def download
79
+ self.reload unless @params["authenticated_s3_url"]
80
+ RestClient.get(@params["authenticated_s3_url"])
81
+ end
82
+
83
+ def download_to_file(path=Dir.pwd)
84
+ data = self.download
85
+ File.open(File.join(path, @params["filename"]), 'w') { |f| f.write(data) }
86
+ end
87
+
88
+ def reload
89
+ uri = URI.parse(self.href || "#{resource_plural_name}/#{@params["id"]}")
90
+ @params ? @params.merge!(connection.get(uri.path)) : @params = connection.get(uri.path)
91
+ end
92
+ end
@@ -0,0 +1,31 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ #
17
+ # You must have Beta v1.5 API access to use these internal API calls.
18
+ #
19
+ class SecurityGroupRule
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ deny_methods :update
24
+
25
+ def self.parse_args(cloud_id=nil, security_group_id=nil)
26
+ if cloud_id.nil? ^ security_group_id.nil?
27
+ raise ArgumentError.new("#{self} requires either 0 arguments, or 2 arguments")
28
+ end
29
+ "clouds/#{cloud_id}/security_groups/#{security_group_id}/"
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+ #
16
+
17
+ class ServerEc2EbsVolume
18
+ include RightScale::Api::Base
19
+ extend RightScale::Api::BaseExtend
20
+ include RightScale::Api::Taggable
21
+ extend RightScale::Api::TaggableExtend
22
+
23
+ deny_methods :index, :update
24
+
25
+ def resource_plural_name
26
+ "component_ec2_ebs_volumes"
27
+ end
28
+
29
+ def resource_singular_name
30
+ "component_ec2_ebs_volume"
31
+ end
32
+
33
+ def self.resource_plural_name
34
+ "component_ec2_ebs_volumes"
35
+ end
36
+
37
+ def self.resource_singular_name
38
+ "component_ec2_ebs_volume"
39
+ end
40
+ end
@@ -0,0 +1,61 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ #
17
+ # You must have Beta v1.5 API access to use these internal API calls.
18
+ #
19
+ class Session
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ deny_methods :index, :destroy, :update, :show
24
+
25
+ def self.index
26
+ self.new(connection.get(resource_singular_name))
27
+ end
28
+
29
+ def self.create(opts={})
30
+ settings = connection.settings
31
+ ignored, account = settings[:api_url].split(/\/acct\//) if settings[:api_url].include?("acct")
32
+ params = {
33
+ "email" => settings[:user],
34
+ "password" => settings[:pass],
35
+ "account_href" => "/api/accounts/#{account}"
36
+ }.merge(opts)
37
+ resp = connection.post(resource_singular_name, params)
38
+ connection.cookie = resp.response['set-cookie']
39
+ end
40
+
41
+ def self.accounts(opts={})
42
+ settings = connection.settings
43
+ params = {
44
+ "email" => settings[:user],
45
+ "password" => settings[:pass],
46
+ }.merge(opts)
47
+ a = Array.new
48
+ connection.get(resource_singular_name + "/accounts").each do |object|
49
+ a << Account.new(object)
50
+ end
51
+ return a
52
+ end
53
+
54
+ def self.create_instance_session
55
+ # TODO
56
+ end
57
+
58
+ def self.index_instance_session
59
+ # TODO
60
+ end
61
+ end
@@ -0,0 +1,22 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+ #
16
+
17
+ class SqsQueue
18
+ include RightScale::Api::Base
19
+ extend RightScale::Api::BaseExtend
20
+
21
+ deny_methods :update
22
+ end
@@ -0,0 +1,19 @@
1
+ # This file is part of RestConnection
2
+ #
3
+ # RestConnection is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # RestConnection is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ class VpcDhcpOption
17
+ include RightScale::Api::Base
18
+ extend RightScale::Api::BaseExtend
19
+ end
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rest_connection"
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremy Deininger", "Timothy Rodriguez"]
12
12
  s.date = "2012-02-27"
13
- s.description = "provides rest_connection"
13
+ s.description = "A Modular RESTful API library. Current implemented modules: RightScale API"
14
14
  s.email = ["daniel.onorato@rightscale.com"]
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "examples/cucumber/step_definitions/spot_check_steps.rb",
30
30
  "examples/relaunch_deployment.rb",
31
31
  "examples/right_scale_ec2_instances_api_test.rb",
32
+ "git_hooks/post-commit",
32
33
  "git_hooks/post-commit.disabled",
33
34
  "git_hooks/post-merge.disabled",
34
35
  "git_hooks/pre-commit",
@@ -36,9 +37,12 @@ Gem::Specification.new do |s|
36
37
  "lib/rest_connection/patches.rb",
37
38
  "lib/rest_connection/rightscale/account.rb",
38
39
  "lib/rest_connection/rightscale/alert_spec.rb",
40
+ "lib/rest_connection/rightscale/alert_spec_subject.rb",
39
41
  "lib/rest_connection/rightscale/audit_entry.rb",
42
+ "lib/rest_connection/rightscale/backup.rb",
40
43
  "lib/rest_connection/rightscale/child_account.rb",
41
44
  "lib/rest_connection/rightscale/cloud.rb",
45
+ "lib/rest_connection/rightscale/cloud_account.rb",
42
46
  "lib/rest_connection/rightscale/credential.rb",
43
47
  "lib/rest_connection/rightscale/deployment.rb",
44
48
  "lib/rest_connection/rightscale/ec2_ebs_snapshot.rb",
@@ -46,12 +50,14 @@ Gem::Specification.new do |s|
46
50
  "lib/rest_connection/rightscale/ec2_elastic_ip.rb",
47
51
  "lib/rest_connection/rightscale/ec2_security_group.rb",
48
52
  "lib/rest_connection/rightscale/ec2_server_array.rb",
53
+ "lib/rest_connection/rightscale/ec2_server_array_internal.rb",
49
54
  "lib/rest_connection/rightscale/ec2_ssh_key.rb",
50
55
  "lib/rest_connection/rightscale/ec2_ssh_key_internal.rb",
51
56
  "lib/rest_connection/rightscale/executable.rb",
52
57
  "lib/rest_connection/rightscale/instance.rb",
53
58
  "lib/rest_connection/rightscale/instance_type.rb",
54
59
  "lib/rest_connection/rightscale/macro.rb",
60
+ "lib/rest_connection/rightscale/mc_audit_entry.rb",
55
61
  "lib/rest_connection/rightscale/mc_datacenter.rb",
56
62
  "lib/rest_connection/rightscale/mc_deployment.rb",
57
63
  "lib/rest_connection/rightscale/mc_image.rb",
@@ -63,6 +69,7 @@ Gem::Specification.new do |s|
63
69
  "lib/rest_connection/rightscale/mc_server.rb",
64
70
  "lib/rest_connection/rightscale/mc_server_array.rb",
65
71
  "lib/rest_connection/rightscale/mc_server_template.rb",
72
+ "lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb",
66
73
  "lib/rest_connection/rightscale/mc_ssh_key.rb",
67
74
  "lib/rest_connection/rightscale/mc_tag.rb",
68
75
  "lib/rest_connection/rightscale/mc_volume.rb",
@@ -75,6 +82,7 @@ Gem::Specification.new do |s|
75
82
  "lib/rest_connection/rightscale/multi_cloud_image_internal.rb",
76
83
  "lib/rest_connection/rightscale/permission.rb",
77
84
  "lib/rest_connection/rightscale/right_script.rb",
85
+ "lib/rest_connection/rightscale/right_script_attachment_internal.rb",
78
86
  "lib/rest_connection/rightscale/right_script_internal.rb",
79
87
  "lib/rest_connection/rightscale/rightscale_api_base.rb",
80
88
  "lib/rest_connection/rightscale/rightscale_api_gateway.rb",
@@ -85,15 +93,20 @@ Gem::Specification.new do |s|
85
93
  "lib/rest_connection/rightscale/rightscale_api_taggable.rb",
86
94
  "lib/rest_connection/rightscale/rs_internal.rb",
87
95
  "lib/rest_connection/rightscale/s3_bucket.rb",
96
+ "lib/rest_connection/rightscale/security_group_rule.rb",
88
97
  "lib/rest_connection/rightscale/server.rb",
98
+ "lib/rest_connection/rightscale/server_ec2_ebs_volume.rb",
89
99
  "lib/rest_connection/rightscale/server_interface.rb",
90
100
  "lib/rest_connection/rightscale/server_internal.rb",
91
101
  "lib/rest_connection/rightscale/server_template.rb",
92
102
  "lib/rest_connection/rightscale/server_template_internal.rb",
103
+ "lib/rest_connection/rightscale/session.rb",
104
+ "lib/rest_connection/rightscale/sqs_queue.rb",
93
105
  "lib/rest_connection/rightscale/status.rb",
94
106
  "lib/rest_connection/rightscale/tag.rb",
95
107
  "lib/rest_connection/rightscale/task.rb",
96
108
  "lib/rest_connection/rightscale/user.rb",
109
+ "lib/rest_connection/rightscale/vpc_dhcp_option.rb",
97
110
  "lib/rest_connection/ssh_hax.rb",
98
111
  "rest_connection.gemspec",
99
112
  "spec/ec2_server_array_spec.rb",
@@ -110,10 +123,10 @@ Gem::Specification.new do |s|
110
123
  "spec/spec_helper.rb",
111
124
  "spec/tag_spec.rb"
112
125
  ]
113
- s.homepage = "http://github.com/rigthscale/rest_connection"
126
+ s.homepage = "http://github.com/rightscale/rest_connection"
114
127
  s.require_paths = ["lib"]
115
- s.rubygems_version = "1.7.2"
116
- s.summary = "lib for restful connections to the rightscale api"
128
+ s.rubygems_version = "1.8.17"
129
+ s.summary = "Modular RESTful API library"
117
130
 
118
131
  if s.respond_to? :specification_version then
119
132
  s.specification_version = 3
@@ -123,17 +136,20 @@ Gem::Specification.new do |s|
123
136
  s.add_runtime_dependency(%q<net-ssh>, ["= 2.1.4"])
124
137
  s.add_runtime_dependency(%q<json>, [">= 0"])
125
138
  s.add_runtime_dependency(%q<highline>, [">= 0"])
139
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
126
140
  else
127
141
  s.add_dependency(%q<activesupport>, ["= 2.3.10"])
128
142
  s.add_dependency(%q<net-ssh>, ["= 2.1.4"])
129
143
  s.add_dependency(%q<json>, [">= 0"])
130
144
  s.add_dependency(%q<highline>, [">= 0"])
145
+ s.add_dependency(%q<rest-client>, [">= 0"])
131
146
  end
132
147
  else
133
148
  s.add_dependency(%q<activesupport>, ["= 2.3.10"])
134
149
  s.add_dependency(%q<net-ssh>, ["= 2.1.4"])
135
150
  s.add_dependency(%q<json>, [">= 0"])
136
151
  s.add_dependency(%q<highline>, [">= 0"])
152
+ s.add_dependency(%q<rest-client>, [">= 0"])
137
153
  end
138
154
  end
139
155
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_connection
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Deininger
@@ -78,7 +78,21 @@ dependencies:
78
78
  version: "0"
79
79
  type: :runtime
80
80
  version_requirements: *id004
81
- description: provides rest_connection
81
+ - !ruby/object:Gem::Dependency
82
+ name: rest-client
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ type: :runtime
94
+ version_requirements: *id005
95
+ description: "A Modular RESTful API library. Current implemented modules: RightScale API"
82
96
  email:
83
97
  - daniel.onorato@rightscale.com
84
98
  executables: []
@@ -101,6 +115,7 @@ files:
101
115
  - examples/cucumber/step_definitions/spot_check_steps.rb
102
116
  - examples/relaunch_deployment.rb
103
117
  - examples/right_scale_ec2_instances_api_test.rb
118
+ - git_hooks/post-commit
104
119
  - git_hooks/post-commit.disabled
105
120
  - git_hooks/post-merge.disabled
106
121
  - git_hooks/pre-commit
@@ -108,9 +123,12 @@ files:
108
123
  - lib/rest_connection/patches.rb
109
124
  - lib/rest_connection/rightscale/account.rb
110
125
  - lib/rest_connection/rightscale/alert_spec.rb
126
+ - lib/rest_connection/rightscale/alert_spec_subject.rb
111
127
  - lib/rest_connection/rightscale/audit_entry.rb
128
+ - lib/rest_connection/rightscale/backup.rb
112
129
  - lib/rest_connection/rightscale/child_account.rb
113
130
  - lib/rest_connection/rightscale/cloud.rb
131
+ - lib/rest_connection/rightscale/cloud_account.rb
114
132
  - lib/rest_connection/rightscale/credential.rb
115
133
  - lib/rest_connection/rightscale/deployment.rb
116
134
  - lib/rest_connection/rightscale/ec2_ebs_snapshot.rb
@@ -118,12 +136,14 @@ files:
118
136
  - lib/rest_connection/rightscale/ec2_elastic_ip.rb
119
137
  - lib/rest_connection/rightscale/ec2_security_group.rb
120
138
  - lib/rest_connection/rightscale/ec2_server_array.rb
139
+ - lib/rest_connection/rightscale/ec2_server_array_internal.rb
121
140
  - lib/rest_connection/rightscale/ec2_ssh_key.rb
122
141
  - lib/rest_connection/rightscale/ec2_ssh_key_internal.rb
123
142
  - lib/rest_connection/rightscale/executable.rb
124
143
  - lib/rest_connection/rightscale/instance.rb
125
144
  - lib/rest_connection/rightscale/instance_type.rb
126
145
  - lib/rest_connection/rightscale/macro.rb
146
+ - lib/rest_connection/rightscale/mc_audit_entry.rb
127
147
  - lib/rest_connection/rightscale/mc_datacenter.rb
128
148
  - lib/rest_connection/rightscale/mc_deployment.rb
129
149
  - lib/rest_connection/rightscale/mc_image.rb
@@ -135,6 +155,7 @@ files:
135
155
  - lib/rest_connection/rightscale/mc_server.rb
136
156
  - lib/rest_connection/rightscale/mc_server_array.rb
137
157
  - lib/rest_connection/rightscale/mc_server_template.rb
158
+ - lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb
138
159
  - lib/rest_connection/rightscale/mc_ssh_key.rb
139
160
  - lib/rest_connection/rightscale/mc_tag.rb
140
161
  - lib/rest_connection/rightscale/mc_volume.rb
@@ -147,6 +168,7 @@ files:
147
168
  - lib/rest_connection/rightscale/multi_cloud_image_internal.rb
148
169
  - lib/rest_connection/rightscale/permission.rb
149
170
  - lib/rest_connection/rightscale/right_script.rb
171
+ - lib/rest_connection/rightscale/right_script_attachment_internal.rb
150
172
  - lib/rest_connection/rightscale/right_script_internal.rb
151
173
  - lib/rest_connection/rightscale/rightscale_api_base.rb
152
174
  - lib/rest_connection/rightscale/rightscale_api_gateway.rb
@@ -157,15 +179,20 @@ files:
157
179
  - lib/rest_connection/rightscale/rightscale_api_taggable.rb
158
180
  - lib/rest_connection/rightscale/rs_internal.rb
159
181
  - lib/rest_connection/rightscale/s3_bucket.rb
182
+ - lib/rest_connection/rightscale/security_group_rule.rb
160
183
  - lib/rest_connection/rightscale/server.rb
184
+ - lib/rest_connection/rightscale/server_ec2_ebs_volume.rb
161
185
  - lib/rest_connection/rightscale/server_interface.rb
162
186
  - lib/rest_connection/rightscale/server_internal.rb
163
187
  - lib/rest_connection/rightscale/server_template.rb
164
188
  - lib/rest_connection/rightscale/server_template_internal.rb
189
+ - lib/rest_connection/rightscale/session.rb
190
+ - lib/rest_connection/rightscale/sqs_queue.rb
165
191
  - lib/rest_connection/rightscale/status.rb
166
192
  - lib/rest_connection/rightscale/tag.rb
167
193
  - lib/rest_connection/rightscale/task.rb
168
194
  - lib/rest_connection/rightscale/user.rb
195
+ - lib/rest_connection/rightscale/vpc_dhcp_option.rb
169
196
  - lib/rest_connection/ssh_hax.rb
170
197
  - rest_connection.gemspec
171
198
  - spec/ec2_server_array_spec.rb
@@ -181,7 +208,7 @@ files:
181
208
  - spec/server_template_internal.rb
182
209
  - spec/spec_helper.rb
183
210
  - spec/tag_spec.rb
184
- homepage: http://github.com/rigthscale/rest_connection
211
+ homepage: http://github.com/rightscale/rest_connection
185
212
  licenses: []
186
213
 
187
214
  post_install_message:
@@ -213,6 +240,6 @@ rubyforge_project:
213
240
  rubygems_version: 1.8.17
214
241
  signing_key:
215
242
  specification_version: 3
216
- summary: lib for restful connections to the rightscale api
243
+ summary: Modular RESTful API library
217
244
  test_files: []
218
245