fog 0.0.56 → 0.0.57

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 (85) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION.yml +1 -1
  3. data/fog.gemspec +4 -4
  4. data/lib/fog/aws.rb +4 -3
  5. data/lib/fog/aws/ec2.rb +136 -150
  6. data/lib/fog/aws/models/ec2/address.rb +3 -1
  7. data/lib/fog/aws/models/ec2/addresses.rb +20 -6
  8. data/lib/fog/aws/models/ec2/flavor.rb +3 -1
  9. data/lib/fog/aws/models/ec2/flavors.rb +14 -3
  10. data/lib/fog/aws/models/ec2/image.rb +3 -1
  11. data/lib/fog/aws/models/ec2/images.rb +14 -3
  12. data/lib/fog/aws/models/ec2/key_pair.rb +3 -1
  13. data/lib/fog/aws/models/ec2/key_pairs.rb +14 -3
  14. data/lib/fog/aws/models/ec2/security_group.rb +3 -1
  15. data/lib/fog/aws/models/ec2/security_groups.rb +14 -3
  16. data/lib/fog/aws/models/ec2/server.rb +3 -1
  17. data/lib/fog/aws/models/ec2/servers.rb +14 -3
  18. data/lib/fog/aws/models/ec2/snapshot.rb +3 -1
  19. data/lib/fog/aws/models/ec2/snapshots.rb +18 -5
  20. data/lib/fog/aws/models/ec2/volume.rb +3 -1
  21. data/lib/fog/aws/models/ec2/volumes.rb +18 -5
  22. data/lib/fog/aws/models/s3/directories.rb +14 -3
  23. data/lib/fog/aws/models/s3/directory.rb +4 -1
  24. data/lib/fog/aws/models/s3/file.rb +3 -1
  25. data/lib/fog/aws/models/s3/files.rb +4 -1
  26. data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +2 -0
  27. data/lib/fog/aws/parsers/simpledb/get_attributes.rb +2 -0
  28. data/lib/fog/aws/parsers/simpledb/list_domains.rb +2 -0
  29. data/lib/fog/aws/parsers/simpledb/select.rb +2 -0
  30. data/lib/fog/aws/requests/ec2/allocate_address.rb +11 -16
  31. data/lib/fog/aws/requests/ec2/associate_address.rb +14 -19
  32. data/lib/fog/aws/requests/ec2/attach_volume.rb +16 -21
  33. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +29 -27
  34. data/lib/fog/aws/requests/ec2/create_key_pair.rb +13 -18
  35. data/lib/fog/aws/requests/ec2/create_security_group.rb +14 -19
  36. data/lib/fog/aws/requests/ec2/create_snapshot.rb +13 -18
  37. data/lib/fog/aws/requests/ec2/create_volume.rb +14 -19
  38. data/lib/fog/aws/requests/ec2/delete_key_pair.rb +12 -17
  39. data/lib/fog/aws/requests/ec2/delete_security_group.rb +13 -18
  40. data/lib/fog/aws/requests/ec2/delete_snapshot.rb +12 -17
  41. data/lib/fog/aws/requests/ec2/delete_volume.rb +13 -18
  42. data/lib/fog/aws/requests/ec2/describe_addresses.rb +11 -16
  43. data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +9 -14
  44. data/lib/fog/aws/requests/ec2/describe_images.rb +9 -14
  45. data/lib/fog/aws/requests/ec2/describe_instances.rb +17 -22
  46. data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +11 -16
  47. data/lib/fog/aws/requests/ec2/describe_regions.rb +9 -14
  48. data/lib/fog/aws/requests/ec2/describe_reserved_instances.rb +9 -14
  49. data/lib/fog/aws/requests/ec2/describe_security_groups.rb +11 -16
  50. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +12 -17
  51. data/lib/fog/aws/requests/ec2/describe_volumes.rb +14 -19
  52. data/lib/fog/aws/requests/ec2/detach_volume.rb +11 -16
  53. data/lib/fog/aws/requests/ec2/disassociate_address.rb +12 -17
  54. data/lib/fog/aws/requests/ec2/get_console_output.rb +12 -17
  55. data/lib/fog/aws/requests/ec2/reboot_instances.rb +11 -16
  56. data/lib/fog/aws/requests/ec2/release_address.rb +12 -17
  57. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +10 -15
  58. data/lib/fog/aws/requests/ec2/run_instances.rb +36 -38
  59. data/lib/fog/aws/requests/ec2/terminate_instances.rb +16 -20
  60. data/lib/fog/aws/requests/s3/copy_object.rb +9 -15
  61. data/lib/fog/aws/requests/s3/delete_bucket.rb +9 -16
  62. data/lib/fog/aws/requests/s3/delete_object.rb +6 -14
  63. data/lib/fog/aws/requests/s3/get_bucket.rb +9 -14
  64. data/lib/fog/aws/requests/s3/get_bucket_location.rb +8 -14
  65. data/lib/fog/aws/requests/s3/get_object.rb +7 -15
  66. data/lib/fog/aws/requests/s3/get_request_payment.rb +7 -13
  67. data/lib/fog/aws/requests/s3/get_service.rb +7 -13
  68. data/lib/fog/aws/requests/s3/head_object.rb +6 -14
  69. data/lib/fog/aws/requests/s3/put_bucket.rb +13 -21
  70. data/lib/fog/aws/requests/s3/put_object.rb +8 -16
  71. data/lib/fog/aws/requests/s3/put_request_payment.rb +7 -16
  72. data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +14 -21
  73. data/lib/fog/aws/requests/simpledb/create_domain.rb +11 -18
  74. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +15 -22
  75. data/lib/fog/aws/requests/simpledb/delete_domain.rb +11 -18
  76. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +14 -19
  77. data/lib/fog/aws/requests/simpledb/get_attributes.rb +19 -23
  78. data/lib/fog/aws/requests/simpledb/list_domains.rb +11 -16
  79. data/lib/fog/aws/requests/simpledb/put_attributes.rb +15 -15
  80. data/lib/fog/aws/requests/simpledb/select.rb +12 -17
  81. data/lib/fog/aws/s3.rb +117 -121
  82. data/lib/fog/aws/simpledb.rb +127 -127
  83. data/lib/fog/rackspace/models/servers/images.rb +1 -1
  84. data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +11 -1
  85. metadata +4 -4
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/basic'
6
7
 
7
8
  # Add permissions to a security group
8
9
  #
@@ -25,29 +26,32 @@ unless Fog.mocking?
25
26
  # * 'return'<~Boolean> - success?
26
27
  def authorize_security_group_ingress(options = {})
27
28
  request({
28
- 'Action' => 'AuthorizeSecurityGroupIngress'
29
- }.merge!(options), Fog::Parsers::AWS::EC2::Basic.new)
29
+ 'Action' => 'AuthorizeSecurityGroupIngress',
30
+ :parser => Fog::Parsers::AWS::EC2::Basic.new
31
+ }.merge!(options))
30
32
  end
31
33
 
32
34
  end
33
- end
34
- end
35
35
 
36
- else
36
+ class Mock
37
37
 
38
- module Fog
39
- module AWS
40
- class EC2
41
-
42
- # TODO: handle the GroupName/Source/Source case
43
38
  def authorize_security_group_ingress(options = {})
39
+ response = Excon::Response.new
40
+ group = @data[:security_groups][options['GroupName']]
41
+ group['ipPermissions'] ||= []
42
+
44
43
  if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
45
- raise MockNotImplemented.new("Contributions welcome!")
44
+ owner = Fog::AWS::Mock.owner_id
45
+ ['icmp', 'tcp', 'udp'].each do |protocol|
46
+ group['ipPermissions'] << {
47
+ 'groups' => [{'groupName' => options['GroupName'], 'userId' => owner}],
48
+ 'fromPort' => 1,
49
+ 'ipRanges' => [],
50
+ 'ipProtocol' => protocol,
51
+ 'toPort' => 65535
52
+ }
53
+ end
46
54
  else
47
- response = Excon::Response.new
48
- group = Fog::AWS::EC2.data[:security_groups][options['GroupName']]
49
-
50
- group['ipPermissions'] ||= []
51
55
  group['ipPermissions'] << {
52
56
  'groups' => [],
53
57
  'fromPort' => options['FromPort'],
@@ -55,18 +59,16 @@ else
55
59
  'ipProtocol' => options['IpProtocol'],
56
60
  'toPort' => options['ToPort']
57
61
  }
58
-
59
- response.status = 200
60
- response.body = {
61
- 'requestId' => Fog::AWS::Mock.request_id,
62
- 'return' => true
63
- }
64
- response
65
62
  end
63
+ response.status = 200
64
+ response.body = {
65
+ 'requestId' => Fog::AWS::Mock.request_id,
66
+ 'return' => true
67
+ }
68
+ response
66
69
  end
67
70
 
68
71
  end
69
72
  end
70
73
  end
71
-
72
74
  end
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/create_key_pair'
6
7
 
7
8
  # Create a new key pair
8
9
  #
@@ -17,32 +18,27 @@ unless Fog.mocking?
17
18
  # * 'keyName'<~String> - Name of key
18
19
  # * 'requestId'<~String> - Id of request
19
20
  def create_key_pair(key_name)
20
- request({
21
- 'Action' => 'CreateKeyPair',
22
- 'KeyName' => key_name
23
- }, Fog::Parsers::AWS::EC2::CreateKeyPair.new)
21
+ request(
22
+ 'Action' => 'CreateKeyPair',
23
+ 'KeyName' => key_name,
24
+ :parser => Fog::Parsers::AWS::EC2::CreateKeyPair.new
25
+ )
24
26
  end
25
27
 
26
28
  end
27
- end
28
- end
29
29
 
30
- else
31
-
32
- module Fog
33
- module AWS
34
- class EC2
30
+ class Mock
35
31
 
36
32
  def create_key_pair(key_name)
37
33
  response = Excon::Response.new
38
- unless Fog::AWS::EC2.data[:key_pairs][key_name]
34
+ unless @data[:key_pairs][key_name]
39
35
  response.status = 200
40
36
  data = {
41
37
  'keyFingerprint' => Fog::AWS::Mock.key_fingerprint,
42
38
  'keyMaterial' => Fog::AWS::Mock.key_material,
43
39
  'keyName' => key_name
44
40
  }
45
- Fog::AWS::EC2.data[:key_pairs][key_name] = data
41
+ @data[:key_pairs][key_name] = data
46
42
  response.body = {
47
43
  'requestId' => Fog::AWS::Mock.request_id
48
44
  }.merge!(data)
@@ -56,5 +52,4 @@ else
56
52
  end
57
53
  end
58
54
  end
59
-
60
55
  end
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/basic'
6
7
 
7
8
  # Create a new security group
8
9
  #
@@ -16,33 +17,28 @@ unless Fog.mocking?
16
17
  # * 'requestId'<~String> - Id of request
17
18
  # * 'return'<~Boolean> - success?
18
19
  def create_security_group(name, description)
19
- request({
20
- 'Action' => 'CreateSecurityGroup',
21
- 'GroupName' => name,
22
- 'GroupDescription' => CGI.escape(description)
23
- }, Fog::Parsers::AWS::EC2::Basic.new)
20
+ request(
21
+ 'Action' => 'CreateSecurityGroup',
22
+ 'GroupName' => name,
23
+ 'GroupDescription' => CGI.escape(description),
24
+ :parser => Fog::Parsers::AWS::EC2::Basic.new
25
+ )
24
26
  end
25
27
 
26
28
  end
27
- end
28
- end
29
29
 
30
- else
31
-
32
- module Fog
33
- module AWS
34
- class EC2
30
+ class Mock
35
31
 
36
32
  def create_security_group(name, description)
37
33
  response = Excon::Response.new
38
- unless Fog::AWS::EC2.data[:security_groups][name]
34
+ unless @data[:security_groups][name]
39
35
  data = {
40
36
  'groupDescription' => description,
41
37
  'groupName' => name,
42
38
  'ipPermissions' => [],
43
39
  'ownerId' => Fog::AWS::Mock.owner_id
44
40
  }
45
- Fog::AWS::EC2.data[:security_groups][name] = data
41
+ @data[:security_groups][name] = data
46
42
  response.body = {
47
43
  'requestId' => Fog::AWS::Mock.request_id,
48
44
  'return' => true
@@ -57,5 +53,4 @@ else
57
53
  end
58
54
  end
59
55
  end
60
-
61
56
  end
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/create_snapshot'
6
7
 
7
8
  # Create a snapshot of an EBS volume and store it in S3
8
9
  #
@@ -19,25 +20,20 @@ unless Fog.mocking?
19
20
  # * 'status'<~String> - state of snapshot
20
21
  # * 'volumeId'<~String> - id of volume snapshot targets
21
22
  def create_snapshot(volume_id)
22
- request({
23
- 'Action' => 'CreateSnapshot',
24
- 'VolumeId' => volume_id
25
- }, Fog::Parsers::AWS::EC2::CreateSnapshot.new)
23
+ request(
24
+ 'Action' => 'CreateSnapshot',
25
+ 'VolumeId' => volume_id,
26
+ :parser => Fog::Parsers::AWS::EC2::CreateSnapshot.new
27
+ )
26
28
  end
27
29
 
28
30
  end
29
- end
30
- end
31
31
 
32
- else
33
-
34
- module Fog
35
- module AWS
36
- class EC2
32
+ class Mock
37
33
 
38
34
  def create_snapshot(volume_id)
39
35
  response = Excon::Response.new
40
- if Fog::AWS::EC2.data[:volumes][volume_id]
36
+ if @data[:volumes][volume_id]
41
37
  response.status = 200
42
38
  snapshot_id = Fog::AWS::Mock.snapshot_id
43
39
  data = {
@@ -47,7 +43,7 @@ else
47
43
  'status' => 'pending',
48
44
  'volumeId' => volume_id
49
45
  }
50
- Fog::AWS::EC2.data[:snapshots][snapshot_id] = data
46
+ @data[:snapshots][snapshot_id] = data
51
47
  response.body = {
52
48
  'requestId' => Fog::AWS::Mock.request_id
53
49
  }.merge!(data)
@@ -61,5 +57,4 @@ else
61
57
  end
62
58
  end
63
59
  end
64
-
65
60
  end
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/create_volume'
6
7
 
7
8
  # Create an EBS volume
8
9
  #
@@ -21,23 +22,18 @@ unless Fog.mocking?
21
22
  # * 'status's<~String> - State of volume
22
23
  # * 'volumeId'<~String> - Reference to volume
23
24
  def create_volume(availability_zone, size, snapshot_id = nil)
24
- request({
25
- 'Action' => 'CreateVolume',
26
- 'AvailabilityZone' => availability_zone,
27
- 'Size' => size,
28
- 'SnapshotId' => snapshot_id
29
- }, Fog::Parsers::AWS::EC2::CreateVolume.new)
25
+ request(
26
+ 'Action' => 'CreateVolume',
27
+ 'AvailabilityZone' => availability_zone,
28
+ 'Size' => size,
29
+ 'SnapshotId' => snapshot_id,
30
+ :parser => Fog::Parsers::AWS::EC2::CreateVolume.new
31
+ )
30
32
  end
31
33
 
32
34
  end
33
- end
34
- end
35
35
 
36
- else
37
-
38
- module Fog
39
- module AWS
40
- class EC2
36
+ class Mock
41
37
 
42
38
  def create_volume(availability_zone, size, snapshot_id = nil)
43
39
  response = Excon::Response.new
@@ -53,7 +49,7 @@ else
53
49
  'status' => 'creating',
54
50
  'volumeId' => volume_id
55
51
  }
56
- Fog::AWS::EC2.data[:volumes][volume_id] = data
52
+ @data[:volumes][volume_id] = data
57
53
  response.body = {
58
54
  'requestId' => Fog::AWS::Mock.request_id
59
55
  }.merge!(data.reject {|key,value| !['availabilityZone','createTime','size','snapshotId','status','volumeId'].include?(key) })
@@ -74,5 +70,4 @@ else
74
70
  end
75
71
  end
76
72
  end
77
-
78
73
  end
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/basic'
6
7
 
7
8
  # Delete a key pair that you own
8
9
  #
@@ -15,25 +16,20 @@ unless Fog.mocking?
15
16
  # * 'requestId'<~String> id of request
16
17
  # * 'return'<~Boolean> - success?
17
18
  def delete_key_pair(key_name)
18
- request({
19
- 'Action' => 'DeleteKeyPair',
20
- 'KeyName' => key_name
21
- }, Fog::Parsers::AWS::EC2::Basic.new)
19
+ request(
20
+ 'Action' => 'DeleteKeyPair',
21
+ 'KeyName' => key_name,
22
+ :parser => Fog::Parsers::AWS::EC2::Basic.new
23
+ )
22
24
  end
23
25
 
24
26
  end
25
- end
26
- end
27
27
 
28
- else
29
-
30
- module Fog
31
- module AWS
32
- class EC2
28
+ class Mock
33
29
 
34
30
  def delete_key_pair(key_name)
35
31
  response = Excon::Response.new
36
- Fog::AWS::EC2.data[:key_pairs].delete(key_name)
32
+ @data[:key_pairs].delete(key_name)
37
33
  response.status = 200
38
34
  response.body = {
39
35
  'requestId' => Fog::AWS::Mock.request_id,
@@ -45,5 +41,4 @@ else
45
41
  end
46
42
  end
47
43
  end
48
-
49
44
  end
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/basic'
6
7
 
7
8
  # Delete a security group that you own
8
9
  #
@@ -15,25 +16,20 @@ unless Fog.mocking?
15
16
  # * 'requestId'<~String> - Id of request
16
17
  # * 'return'<~Boolean> - success?
17
18
  def delete_security_group(name)
18
- request({
19
- 'Action' => 'DeleteSecurityGroup',
20
- 'GroupName' => name
21
- }, Fog::Parsers::AWS::EC2::Basic.new)
19
+ request(
20
+ 'Action' => 'DeleteSecurityGroup',
21
+ 'GroupName' => name,
22
+ :parser => Fog::Parsers::AWS::EC2::Basic.new
23
+ )
22
24
  end
23
25
 
24
26
  end
25
- end
26
- end
27
27
 
28
- else
29
-
30
- module Fog
31
- module AWS
32
- class EC2
28
+ class Mock
33
29
  def delete_security_group(name)
34
30
  response = Excon::Response.new
35
- if Fog::AWS::EC2.data[:security_groups][name]
36
- Fog::AWS::EC2.data[:security_groups].delete(name)
31
+ if @data[:security_groups][name]
32
+ @data[:security_groups].delete(name)
37
33
  response.status = 200
38
34
  response.body = {
39
35
  'requestId' => Fog::AWS::Mock.request_id,
@@ -48,5 +44,4 @@ else
48
44
  end
49
45
  end
50
46
  end
51
-
52
47
  end
@@ -1,8 +1,9 @@
1
- unless Fog.mocking?
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
2
5
 
3
- module Fog
4
- module AWS
5
- class EC2
6
+ require 'fog/aws/parsers/ec2/basic'
6
7
 
7
8
  # Delete a snapshot of an EBS volume that you own
8
9
  #
@@ -15,25 +16,20 @@ unless Fog.mocking?
15
16
  # * 'requestId'<~String> - Id of request
16
17
  # * 'return'<~Boolean> - success?
17
18
  def delete_snapshot(snapshot_id)
18
- request({
19
- 'Action' => 'DeleteSnapshot',
20
- 'SnapshotId' => snapshot_id
21
- }, Fog::Parsers::AWS::EC2::Basic.new)
19
+ request(
20
+ 'Action' => 'DeleteSnapshot',
21
+ 'SnapshotId' => snapshot_id,
22
+ :parser => Fog::Parsers::AWS::EC2::Basic.new
23
+ )
22
24
  end
23
25
 
24
26
  end
25
- end
26
- end
27
27
 
28
- else
29
-
30
- module Fog
31
- module AWS
32
- class EC2
28
+ class Mock
33
29
 
34
30
  def delete_snapshot(snapshot_id)
35
31
  response = Excon::Response.new
36
- if snapshot = Fog::AWS::EC2.data[:snapshots].delete(snapshot_id)
32
+ if snapshot = @data[:snapshots].delete(snapshot_id)
37
33
  response.status = true
38
34
  response.body = {
39
35
  'requestId' => Fog::AWS::Mock.request_id,
@@ -49,5 +45,4 @@ else
49
45
  end
50
46
  end
51
47
  end
52
-
53
48
  end