nifty-cloud-sdk 1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/CHANGELOG +112 -0
  2. data/Gemfile +4 -0
  3. data/INSTALL +30 -0
  4. data/LICENSE.txt +58 -0
  5. data/README.rdoc +375 -0
  6. data/Rakefile +61 -0
  7. data/lib/NIFTY.rb +405 -0
  8. data/lib/NIFTY/Cloud.rb +24 -0
  9. data/lib/NIFTY/Cloud/availability_zones.rb +23 -0
  10. data/lib/NIFTY/Cloud/certificates.rb +283 -0
  11. data/lib/NIFTY/Cloud/images.rb +134 -0
  12. data/lib/NIFTY/Cloud/instances.rb +372 -0
  13. data/lib/NIFTY/Cloud/keypairs.rb +76 -0
  14. data/lib/NIFTY/Cloud/load_balancers.rb +433 -0
  15. data/lib/NIFTY/Cloud/security_groups.rb +357 -0
  16. data/lib/NIFTY/Cloud/volumes.rb +140 -0
  17. data/lib/NIFTY/config.rb +41 -0
  18. data/lib/NIFTY/exceptions.rb +32 -0
  19. data/lib/NIFTY/responses.rb +19 -0
  20. data/lib/NIFTY/version.rb +3 -0
  21. data/nifty-cloud-sdk.gemspec +28 -0
  22. data/sample/availability_zones/describe-availability-zones.rb +37 -0
  23. data/sample/certificate/create-ssl-certificate.rb +41 -0
  24. data/sample/certificate/delete-ssl-certificate.rb +28 -0
  25. data/sample/certificate/describe-ssl-certificate-attribute.rb +58 -0
  26. data/sample/certificate/describe-ssl-certificates.rb +49 -0
  27. data/sample/certificate/download-ssl-certificate.rb +31 -0
  28. data/sample/certificate/modify-ssl-certificate-attribute.rb +29 -0
  29. data/sample/certificate/register-corporate-info-for-certificate.rb +57 -0
  30. data/sample/certificate/upload-ssl-certificate.rb +32 -0
  31. data/sample/images/create-image.rb +33 -0
  32. data/sample/images/delete-image.rb +26 -0
  33. data/sample/images/describe-images.rb +70 -0
  34. data/sample/images/modify-image-attribute.rb +33 -0
  35. data/sample/instances/cancel_copy_instances.rb +26 -0
  36. data/sample/instances/copy-instances.rb +41 -0
  37. data/sample/instances/describe-instance-attribute.rb +78 -0
  38. data/sample/instances/describe-instances.rb +100 -0
  39. data/sample/instances/modify-instance-attribute.rb +30 -0
  40. data/sample/instances/reboot-instances.rb +29 -0
  41. data/sample/instances/run-instances.rb +104 -0
  42. data/sample/instances/start-instances.rb +36 -0
  43. data/sample/instances/stop-instances.rb +35 -0
  44. data/sample/instances/terminate-instances.rb +34 -0
  45. data/sample/keypairs/create-key-pair.rb +31 -0
  46. data/sample/keypairs/delete-key-pair.rb +28 -0
  47. data/sample/keypairs/describe-key-pairs.rb +31 -0
  48. data/sample/load_balancers/configure-health-check.rb +41 -0
  49. data/sample/load_balancers/create-load-balancer.rb +35 -0
  50. data/sample/load_balancers/delete-load-balancer.rb +28 -0
  51. data/sample/load_balancers/deregister-instances-from-load-balancer.rb +35 -0
  52. data/sample/load_balancers/describe-instance-health.rb +36 -0
  53. data/sample/load_balancers/describe-load-balancers.rb +89 -0
  54. data/sample/load_balancers/register-instances-with-load-balancer.rb +33 -0
  55. data/sample/load_balancers/register-port-with-load-balancer.rb +37 -0
  56. data/sample/load_balancers/set-filter-for-load-balancer.rb +38 -0
  57. data/sample/load_balancers/update-load-balancer.rb +33 -0
  58. data/sample/security_groups/authorize-security-group-ingress.rb +36 -0
  59. data/sample/security_groups/create-security-group.rb +29 -0
  60. data/sample/security_groups/delete-security-group.rb +28 -0
  61. data/sample/security_groups/deregister-instances-from-security-group.rb +31 -0
  62. data/sample/security_groups/describe-security-activities.rb +33 -0
  63. data/sample/security_groups/describe-security-groups.rb +59 -0
  64. data/sample/security_groups/register-instances-with-security-group.rb +31 -0
  65. data/sample/security_groups/revoke-security-group-ingress.rb +36 -0
  66. data/sample/security_groups/update-security-group.rb +30 -0
  67. data/sample/volumes/attach-volumes.rb +34 -0
  68. data/sample/volumes/create-volume.rb +38 -0
  69. data/sample/volumes/delete-volume.rb +28 -0
  70. data/sample/volumes/describe-volumes.rb +44 -0
  71. data/sample/volumes/detach-volume.rb +35 -0
  72. data/test/test_Cloud.rb +186 -0
  73. data/test/test_Cloud_availability_zones.rb +50 -0
  74. data/test/test_Cloud_certificates.rb +627 -0
  75. data/test/test_Cloud_images.rb +284 -0
  76. data/test/test_Cloud_instances.rb +941 -0
  77. data/test/test_Cloud_keypairs.rb +177 -0
  78. data/test/test_Cloud_load_balancers.rb +1183 -0
  79. data/test/test_Cloud_responses.rb +43 -0
  80. data/test/test_Cloud_security_groups.rb +699 -0
  81. data/test/test_Cloud_volumes.rb +325 -0
  82. data/test/test_helper.rb +23 -0
  83. metadata +275 -0
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:certificate => "xxxxx...xxxxx",
24
+ #:key => "xxxxx...xxxxx",
25
+ #:ca => "xxxxx...xxxxx"
26
+ }
27
+
28
+ pp response = ncs4r.upload_ssl_certificate(options)
29
+
30
+ p response.fqdnId
31
+ p response.fqdn
32
+ p response.keyFingerPrint
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:instance_id => "instanceId",
24
+ #:name => "name",
25
+ #:description => "description",
26
+ #:no_reboot => false,
27
+ #:left_instance => false
28
+ }
29
+
30
+ pp response = ncs4r.create_image(options)
31
+
32
+ p response.imageId
33
+ p response.imageState
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:image_id => "imageId"
24
+ }
25
+
26
+ pp response = ncs4r.delete_image(options)
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:executable_by => ["executableUser"],
24
+ #:image_id => ["imageId"],
25
+ #:image_name => ["imageName"],
26
+ #:owner => ["owner"]
27
+ }
28
+
29
+ pp response = ncs4r.describe_images(options)
30
+
31
+ response.imagesSet.item.each do |image|
32
+ p image.imageId
33
+ p image.imageLocation
34
+ p image.imageState
35
+ p image.imageOwnerId
36
+ p image.isPublic
37
+ if product_codes = image.productCodes
38
+ product_codes.item.each do |code|
39
+ p code.productCode
40
+ end
41
+ end
42
+ p image.architecture
43
+ p image.imageType
44
+ p image.kernelId
45
+ p image.ramdiskId
46
+ p image.platform
47
+ if reason = image.stateReason
48
+ p reason.code
49
+ p reason.message
50
+ end
51
+ p image.imageOwnerAlias
52
+ p image.name
53
+ p image.description
54
+ p image.detailDescription
55
+ p image.redistributable
56
+ p image.rootDeviceType
57
+ if block_device_mapping = image.blockDeviceMapping
58
+ block_device_mapping.item.each do |device|
59
+ p device.deviceName
60
+ p device.virtualName
61
+ if ebs = device.ebs
62
+ p ebs.volumeId
63
+ p ebs.status
64
+ p ebs.attachTime
65
+ p ebs.deleteOnTermination
66
+ end
67
+ p device.noDevice
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:image_id => "imageId",
24
+ #:attribute => "attribute",
25
+ #:value => "value",
26
+ #:launch_permission_add => [{:user_id => "userId",
27
+ # :group => "group"}],
28
+ #:launch_permission_remove => [{:user_id => "userId",
29
+ # :group => "group"}],
30
+ #:product_code => "productCode"
31
+ }
32
+
33
+ pp response = ncs4r.delete_image(options)
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:instance_id => "instanceId"
24
+ }
25
+
26
+ pp response = ncs4r.cancel_copy_instances(options)
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:instance_id => "instanceId",
24
+ #:instance_name => "instanceName",
25
+ #:instance_type => "instanceType",
26
+ #:accounting_type => "accountingType",
27
+ #:ip_type => "static",
28
+ #:load_balancers => [{ :load_balancer_name => "loadBalancerName",
29
+ # :load_balancer_port => 0,
30
+ # :instance_port => 0,
31
+ # }],
32
+ #:group_id => "groupId",
33
+ #:copy_count => 2
34
+ }
35
+
36
+ pp response = ncs4r.copy_instances(options)
37
+
38
+ response.copyInstanceSet.member.each do |instance|
39
+ p instance.instanceId
40
+ p instance.instanceState
41
+ end
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:instance_id => "instanceId",
24
+ #:attribute => "attribute"
25
+ }
26
+
27
+ pp response = ncs4r.describe_instance_attribute(options)
28
+
29
+ p response.instanceId
30
+ if instance_type = response.instanceType
31
+ p instance_type.value
32
+ end
33
+ if kernel_id = response.kernelId
34
+ p kernel_id.value
35
+ end
36
+ if ramdisk = response.ramdiskId
37
+ p ramdisk_id.value
38
+ end
39
+ if user_data = response.userData
40
+ p user_data.value
41
+ end
42
+ if disable_api_termination = response.disableApiTermination
43
+ p disable_api_termination.value
44
+ end
45
+ if instance_initiated_shutdown_behavior = response.instanceInitiatedShutdownBehavior
46
+ p instance_initiated_shutdown_behavior.value
47
+ end
48
+ if root_device_name = response.rootDeviceName
49
+ p root_device_name.value
50
+ end
51
+ if block_device_mapping = response.blockDeviceMapping
52
+ block_device_mapping.item.each do |mapping|
53
+ p mapping.deviceName
54
+ if ebs = mapping.ebs
55
+ p ebs.volumeId
56
+ p ebs.status
57
+ p ebs.attachTime
58
+ p ebs.deleteOnTermination
59
+ end
60
+ end
61
+ end
62
+ if accounting_type = response.accountingType
63
+ p accounting_type.value
64
+ end
65
+ if loadbalancing = response.loadbalancing
66
+ loadbalancing.item.each do |balancing|
67
+ p balancing.loadBalancerName
68
+ p balancing.loadBalancerPort
69
+ p balancing.instancePort
70
+ end
71
+ end
72
+ if copy_info = response.copyInfo
73
+ p copy_info.value
74
+ end
75
+ if autoscaling = response.autoscaling
76
+ p autoscaling.autoScalingGroupName
77
+ p autoscaling.expireTime
78
+ end
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require 'rubygems'
13
+ require File.dirname(__FILE__) + "/../../lib/NIFTY"
14
+ require 'pp'
15
+
16
+ ACCESS_KEY = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "<Your Access Key ID>"
17
+ SECRET_KEY = ENV["NIFTY_CLOUD_SECRET_KEY"] || "<Your Secret Access Key>"
18
+
19
+
20
+ ncs4r = NIFTY::Cloud::Base.new(:access_key => ACCESS_KEY, :secret_key => SECRET_KEY)
21
+
22
+ options = {
23
+ #:instance_id => ["instanceId"]
24
+ }
25
+
26
+ pp response = ncs4r.describe_instances(options)
27
+
28
+ response.reservationSet.item.each do |set|
29
+ p set.reservationId
30
+ p set.ownerId
31
+ if group_set = set.groupSet
32
+ group_set.item.each do |group|
33
+ p group.groupId
34
+ end
35
+ end
36
+ set.instancesSet.item.each do |instance|
37
+ p instance.instanceId
38
+ p instance.imageId
39
+ p instance.instanceState.code
40
+ p instance.instanceState.name
41
+ p instance.privateDnsName
42
+ p instance.dnsName
43
+ p instance.reason
44
+ p instance.keyName
45
+ p instance.amiLaunchIndex
46
+ if product_codes = instance.productCodes
47
+ product_codes.item.each do |code|
48
+ p code.productCode
49
+ end
50
+ end
51
+ p instance.instanceType
52
+ p instance.launchTime
53
+ p instance.placement.availabilityZone
54
+ p instance.kernelId
55
+ p instance.ramdiskId
56
+ p instance.platform
57
+ if monitoring = instance.monitoring
58
+ p monitoring.state
59
+ end
60
+ p instance.subnetId
61
+ p instance.vpcId
62
+ p instance.privateIpAddress
63
+ p instance.ipAddress
64
+ p instance.privateIpAddressV6
65
+ p instance.ipAddressV6
66
+ p instance.stateReason
67
+ p instance.code
68
+ p instance.message
69
+ p instance.architecture
70
+ p instance.rootDeviceType
71
+ p instance.accountingType
72
+ p instance.ipType
73
+ if block_device_mapping = instance.blockDeviceMapping
74
+ block_device_mapping.item.each do |device|
75
+ p device.deviceName
76
+ if ebs = device.ebs
77
+ p ebs.volumeId
78
+ p ebs.status
79
+ p ebs.attachTime
80
+ p ebs.deleteOnTermination
81
+ end
82
+ end
83
+ end
84
+ p instance.instanceLifecycle
85
+ p instance.spotInstanceRequestId
86
+ p instance.accountingType
87
+ if loadbalancing = response.loadbalancing
88
+ loadbalancing.item.each do |balancing|
89
+ p balancing.loadBalancerName
90
+ p balancing.loadBalancerPort
91
+ p balancing.instancePort
92
+ end
93
+ end
94
+ p instance.copyInfo
95
+ if autoscaling = response.autoscaling
96
+ p autoscaling.autoScalingGroupName
97
+ p autoscaling.expireTime
98
+ end
99
+ end
100
+ end