rest_connection 0.0.23 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. data/README.rdoc +3 -3
  2. data/Rakefile +5 -4
  3. data/VERSION +1 -1
  4. data/git_hooks/post-commit.disabled +4 -0
  5. data/git_hooks/post-merge.disabled +4 -0
  6. data/git_hooks/pre-commit +53 -0
  7. data/lib/rest_connection.rb +75 -12
  8. data/lib/rest_connection/patches.rb +106 -0
  9. data/lib/rest_connection/rightscale/account.rb +27 -0
  10. data/lib/rest_connection/rightscale/alert_spec.rb +2 -2
  11. data/lib/rest_connection/rightscale/audit_entry.rb +5 -5
  12. data/lib/rest_connection/rightscale/child_account.rb +27 -0
  13. data/lib/rest_connection/rightscale/cloud.rb +26 -0
  14. data/lib/rest_connection/rightscale/credential.rb +1 -1
  15. data/lib/rest_connection/rightscale/deployment.rb +33 -7
  16. data/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb +3 -1
  17. data/lib/rest_connection/rightscale/ec2_ebs_volume.rb +3 -1
  18. data/lib/rest_connection/rightscale/ec2_elastic_ip.rb +1 -1
  19. data/lib/rest_connection/rightscale/ec2_security_group.rb +2 -2
  20. data/lib/rest_connection/rightscale/ec2_server_array.rb +7 -5
  21. data/lib/rest_connection/rightscale/ec2_ssh_key.rb +11 -2
  22. data/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb +2 -2
  23. data/lib/rest_connection/rightscale/executable.rb +4 -4
  24. data/lib/rest_connection/rightscale/instance.rb +5 -3
  25. data/lib/rest_connection/rightscale/instance_type.rb +31 -0
  26. data/lib/rest_connection/rightscale/macro.rb +19 -0
  27. data/lib/rest_connection/rightscale/mc_datacenter.rb +53 -0
  28. data/lib/rest_connection/rightscale/mc_deployment.rb +60 -0
  29. data/lib/rest_connection/rightscale/mc_image.rb +42 -0
  30. data/lib/rest_connection/rightscale/mc_instance.rb +170 -0
  31. data/lib/rest_connection/rightscale/mc_instance_type.rb +47 -0
  32. data/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +58 -0
  33. data/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +46 -0
  34. data/lib/rest_connection/rightscale/mc_security_group.rb +42 -0
  35. data/lib/rest_connection/rightscale/mc_server.rb +250 -6
  36. data/lib/rest_connection/rightscale/mc_server_array.rb +44 -0
  37. data/lib/rest_connection/rightscale/mc_server_template.rb +53 -0
  38. data/lib/rest_connection/rightscale/mc_ssh_key.rb +50 -0
  39. data/lib/rest_connection/rightscale/mc_tag.rb +69 -0
  40. data/lib/rest_connection/rightscale/mc_volume.rb +53 -0
  41. data/lib/rest_connection/rightscale/mc_volume_attachment.rb +48 -0
  42. data/lib/rest_connection/rightscale/mc_volume_snapshot.rb +55 -0
  43. data/lib/rest_connection/rightscale/mc_volume_type.rb +47 -0
  44. data/lib/rest_connection/rightscale/monitoring_metric.rb +35 -0
  45. data/lib/rest_connection/rightscale/multi_cloud_image.rb +16 -2
  46. data/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb +2 -2
  47. data/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +25 -1
  48. data/lib/rest_connection/rightscale/permission.rb +27 -0
  49. data/lib/rest_connection/rightscale/right_script.rb +4 -4
  50. data/lib/rest_connection/rightscale/right_script_internal.rb +4 -4
  51. data/lib/rest_connection/rightscale/rightscale_api_base.rb +69 -20
  52. data/lib/rest_connection/rightscale/rightscale_api_gateway.rb +198 -13
  53. data/lib/rest_connection/rightscale/rightscale_api_internal.rb +3 -3
  54. data/lib/rest_connection/rightscale/rightscale_api_mc_input.rb +32 -0
  55. data/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +57 -0
  56. data/lib/rest_connection/rightscale/rightscale_api_resources.rb +32 -2
  57. data/lib/rest_connection/rightscale/rightscale_api_taggable.rb +116 -0
  58. data/lib/rest_connection/rightscale/rs_internal.rb +6 -6
  59. data/lib/rest_connection/rightscale/s3_bucket.rb +36 -0
  60. data/lib/rest_connection/rightscale/server.rb +186 -37
  61. data/lib/rest_connection/rightscale/server_interface.rb +264 -0
  62. data/lib/rest_connection/rightscale/server_internal.rb +3 -3
  63. data/lib/rest_connection/rightscale/server_template.rb +15 -4
  64. data/lib/rest_connection/rightscale/server_template_internal.rb +4 -4
  65. data/lib/rest_connection/rightscale/status.rb +2 -2
  66. data/lib/rest_connection/rightscale/tag.rb +2 -2
  67. data/lib/rest_connection/rightscale/task.rb +47 -0
  68. data/lib/rest_connection/rightscale/user.rb +27 -0
  69. data/lib/rest_connection/ssh_hax.rb +42 -40
  70. data/rest_connection.gemspec +5 -5
  71. data/spec/mcserver_spec.rb +17 -0
  72. data/spec/multi.rb +16 -0
  73. metadata +65 -12
@@ -0,0 +1,44 @@
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 McServerArray
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+ include RightScale::Api::McTaggable
23
+ extend RightScale::Api::McTaggableExtend
24
+
25
+ def resource_plural_name
26
+ "server_arrays"
27
+ end
28
+
29
+ def resource_singular_name
30
+ "server_array"
31
+ end
32
+
33
+ def self.resource_plural_name
34
+ "server_arrays"
35
+ end
36
+
37
+ def self.resource_singular_name
38
+ "server_array"
39
+ end
40
+
41
+ def self.parse_args(deployment_id=nil)
42
+ (deployment_id ? "deployments/#{deployment_id}/" : "")
43
+ end
44
+ end
@@ -0,0 +1,53 @@
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 McServerTemplate
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+ include RightScale::Api::McTaggable
23
+ extend RightScale::Api::McTaggableExtend
24
+ include RightScale::Api::McInput
25
+
26
+ def resource_plural_name
27
+ "server_templates"
28
+ end
29
+
30
+ def resource_singular_name
31
+ "server_template"
32
+ end
33
+
34
+ def self.resource_plural_name
35
+ "server_templates"
36
+ end
37
+
38
+ def self.resource_singular_name
39
+ "server_template"
40
+ end
41
+
42
+ def get_mcis_and_settings
43
+ @params["multi_cloud_images"] = McMultiCloudImage.find_all(self.rs_id)
44
+ @params["multi_cloud_images"].each { |mci| mci.get_settings }
45
+ end
46
+
47
+ def multi_cloud_images
48
+ unless @params["multi_cloud_images"]
49
+ get_mcis_and_settings
50
+ end
51
+ @params["multi_cloud_images"]
52
+ end
53
+ 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
+ class McSshKey
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ def resource_plural_name
24
+ "ssh_keys"
25
+ end
26
+
27
+ def resource_singular_name
28
+ "ssh_key"
29
+ end
30
+
31
+ def self.resource_plural_name
32
+ "ssh_keys"
33
+ end
34
+
35
+ def self.resource_singular_name
36
+ "ssh_key"
37
+ end
38
+
39
+ def self.parse_args(cloud_id)
40
+ "clouds/#{cloud_id}/"
41
+ end
42
+
43
+ def self.create(opts)
44
+ create_opts = { self.resource_singular_name.to_sym => opts }
45
+ location = connection.post("clouds/#{opts['cloud_id']}/#{self.resource_plural_name}", create_opts)
46
+ newrecord = self.new('href' => location)
47
+ newrecord.reload
48
+ newrecord
49
+ end
50
+ end
@@ -0,0 +1,69 @@
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 McTag
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ def resource_plural_name
24
+ "tags"
25
+ end
26
+
27
+ def resource_singular_name
28
+ "tag"
29
+ end
30
+
31
+ def self.resource_plural_name
32
+ "tags"
33
+ end
34
+
35
+ def self.resource_singular_name
36
+ "tag"
37
+ end
38
+
39
+ def self.search(resource_name, tags, opts=nil) #, include_tags_with_prefix = false)
40
+ parameters = { :resource_type => resource_name.to_s, :tags => tags }
41
+ parameters.merge!(opts) unless opts.nil?
42
+ result = connection.post("tags/by_tag", parameters)
43
+ end
44
+
45
+ def self.search_by_href(*resource_hrefs)
46
+ connection.post("tags/by_resource", :resource_hrefs => resource_hrefs)
47
+ end
48
+ #TAGGABLE_RESOURCES = [ 'Server', 'Ec2EbsSnapshot', 'Ec2EbsVolume', 'Ec2Image', 'Image', 'ServerArray', 'Ec2Instance',
49
+ # 'Instance', 'Deployment', 'ServerTemplate', 'Ec2ServerTemplate' ]
50
+ #
51
+ # Tag.set( resource_href, tags ) where tags is an array of tags to set on the resource.
52
+ def self.multi_add(resource_hrefs, tags)
53
+ resource_hrefs = [resource_hrefs] unless resource_hrefs.is_a?(Array)
54
+ connection.post("tags/multi_add", :resource_hrefs => resource_hrefs, :tags => tags)
55
+ end
56
+
57
+ def self.set(resource_hrefs, tags)
58
+ self.multi_add(resource_hrefs, tags)
59
+ end
60
+
61
+ def self.multi_delete(resource_hrefs, tags)
62
+ resource_hrefs = [resource_hrefs] unless resource_hrefs.is_a?(Array)
63
+ connection.post("tags/multi_delete", :resource_hrefs => resource_hrefs, :tags => tags)
64
+ end
65
+
66
+ def self.unset(resource_hrefs, tags)
67
+ self.multi_delete(resource_hrefs, tags)
68
+ end
69
+ end
@@ -0,0 +1,53 @@
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 McVolume
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+ include RightScale::Api::McTaggable
23
+ extend RightScale::Api::McTaggableExtend
24
+
25
+ def resource_plural_name
26
+ "volumes"
27
+ end
28
+
29
+ def resource_singular_name
30
+ "volume"
31
+ end
32
+
33
+ def self.resource_plural_name
34
+ "volumes"
35
+ end
36
+
37
+ def self.resource_singular_name
38
+ "volume"
39
+ end
40
+
41
+ def self.parse_args(cloud_id)
42
+ "clouds/#{cloud_id}/"
43
+ end
44
+
45
+ def show
46
+ inst_href = URI.parse(self.href)
47
+ @params.merge! connection.get(inst_href.path, 'view' => 'extended')
48
+ end
49
+
50
+ def attachment
51
+ connection.get(self.current_volume_attachment)
52
+ end
53
+ end
@@ -0,0 +1,48 @@
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 McVolumeAttachment
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ def resource_plural_name
24
+ "volume_attachments"
25
+ end
26
+
27
+ def resource_singular_name
28
+ "volume_attachment"
29
+ end
30
+
31
+ def self.resource_plural_name
32
+ "volume_attachments"
33
+ end
34
+
35
+ def self.resource_singular_name
36
+ "volume_attachment"
37
+ end
38
+
39
+ def self.parse_args(cloud_id, instance_id=nil)
40
+ return "clouds/#{cloud_id}/" unless instance_id
41
+ return "clouds/#{cloud_id}/volumes/#{instance_id}/" if instance_id
42
+ end
43
+
44
+ def show
45
+ inst_href = URI.parse(self.href)
46
+ @params.merge! connection.get(inst_href.path)
47
+ end
48
+ end
@@ -0,0 +1,55 @@
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 McVolumeSnapshot
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+ include RightScale::Api::McTaggable
23
+ extend RightScale::Api::McTaggableExtend
24
+
25
+ def resource_plural_name
26
+ "volume_snapshots"
27
+ end
28
+
29
+ def resource_singular_name
30
+ "volume_snapshot"
31
+ end
32
+
33
+ def self.resource_plural_name
34
+ "volume_snapshots"
35
+ end
36
+
37
+ def self.resource_singular_name
38
+ "volume_snapshot"
39
+ end
40
+
41
+ def self.parse_args(cloud_id, volume_id=nil)
42
+ return "clouds/#{cloud_id}/" unless volume_id
43
+ return "clouds/#{cloud_id}/volumes/#{volume_id}/" if volume_id
44
+ end
45
+
46
+ def show
47
+ inst_href = URI.parse(self.href)
48
+ @params.merge! connection.get(inst_href.path)
49
+ end
50
+
51
+ def save
52
+ inst_href = URI.parse(self.href)
53
+ connection.put(inst_href.path, @params)
54
+ end
55
+ end
@@ -0,0 +1,47 @@
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 McVolumeType
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ def resource_plural_name
24
+ "volume_types"
25
+ end
26
+
27
+ def resource_singular_name
28
+ "volume_type"
29
+ end
30
+
31
+ def self.resource_plural_name
32
+ "volume_types"
33
+ end
34
+
35
+ def self.resource_singular_name
36
+ "volume_type"
37
+ end
38
+
39
+ def self.parse_args(cloud_id)
40
+ "clouds/#{cloud_id}/"
41
+ end
42
+
43
+ def show
44
+ inst_href = URI.parse(self.href)
45
+ @params.merge! connection.get(inst_href.path)
46
+ end
47
+ end
@@ -0,0 +1,35 @@
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 MonitoringMetric
20
+ include RightScale::Api::Gateway
21
+ extend RightScale::Api::GatewayExtend
22
+
23
+ def self.parse_args(cloud_id, instance_id)
24
+ "clouds/#{cloud_id}/instances/#{instance_id}/"
25
+ end
26
+
27
+ def data(start_time = "-60", end_time = "0")
28
+ params = {'start' => start_time.to_s, 'end' => end_time.to_s}
29
+ monitor = connection.get(URI.parse(self.href).path + "/data", params)
30
+ # NOTE: The following is a dirty hack
31
+ monitor['data'] = monitor['variables_data'].first
32
+ monitor['data']['value'] = monitor['data']['points']
33
+ monitor
34
+ end
35
+ end