fog 0.3.19 → 0.3.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/Gemfile.lock +1 -1
  2. data/README.rdoc +11 -1
  3. data/fog.gemspec +19 -3
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/iam.rb +8 -0
  6. data/lib/fog/aws/models/storage/file.rb +5 -0
  7. data/lib/fog/aws/parsers/iam/basic.rb +1 -1
  8. data/lib/fog/aws/parsers/iam/create_access_key.rb +26 -0
  9. data/lib/fog/aws/parsers/iam/list_access_keys.rb +32 -0
  10. data/lib/fog/aws/parsers/iam/{list_group_policies.rb → list_policies.rb} +1 -1
  11. data/lib/fog/aws/parsers/iam/list_users.rb +32 -0
  12. data/lib/fog/aws/requests/iam/create_access_key.rb +45 -0
  13. data/lib/fog/aws/requests/iam/create_user.rb +4 -4
  14. data/lib/fog/aws/requests/iam/delete_access_key.rb +42 -0
  15. data/lib/fog/aws/requests/iam/delete_group_policy.rb +1 -1
  16. data/lib/fog/aws/requests/iam/delete_user_policy.rb +42 -0
  17. data/lib/fog/aws/requests/iam/list_access_keys.rb +48 -0
  18. data/lib/fog/aws/requests/iam/list_group_policies.rb +2 -2
  19. data/lib/fog/aws/requests/iam/list_user_policies.rb +47 -0
  20. data/lib/fog/aws/requests/iam/list_users.rb +50 -0
  21. data/lib/fog/aws/requests/iam/put_group_policy.rb +1 -1
  22. data/lib/fog/aws/requests/iam/put_user_policy.rb +44 -0
  23. data/lib/fog/aws/requests/iam/update_access_key.rb +44 -0
  24. data/lib/fog/aws/requests/storage/put_object.rb +1 -0
  25. data/lib/fog/google/models/storage/file.rb +5 -0
  26. data/lib/fog/rackspace/models/storage/file.rb +5 -0
  27. data/tests/aws/helper.rb +12 -0
  28. data/tests/aws/requests/iam/access_key_tests.rb +60 -0
  29. data/tests/aws/requests/iam/group_policy_tests.rb +42 -0
  30. data/tests/aws/requests/iam/group_tests.rb +47 -0
  31. data/tests/aws/requests/iam/user_policy_tests.rb +42 -0
  32. data/tests/aws/requests/iam/user_tests.rb +65 -0
  33. metadata +20 -4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fog (0.3.19)
4
+ fog (0.3.20)
5
5
  builder
6
6
  excon (>= 0.2.4)
7
7
  formatador (>= 0.0.15)
@@ -97,7 +97,17 @@ It will return an {excon}[http://github.com/geemus/excon] response, which has #h
97
97
 
98
98
  == Go forth and conquer
99
99
 
100
- Play around and use the console to explore or check out the {getting started guide}[http://wiki.github.com/geemus/fog/getting-started-with-fog] for more details.
100
+ Play around and use the console to explore or check out the {getting started guide}[http://wiki.github.com/geemus/fog/getting-started-with-fog] for more details. Once you are reading to start scripting fog, here is a quick hint on how to make connections without the command line thing to help you.
101
+
102
+ # create a compute connection
103
+ compute = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
104
+ # compute operations go here
105
+
106
+ # create a storage connection
107
+ storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
108
+ # storage operations go here
109
+
110
+ geemus says: "That should give you everything you need to get started, but let me know if there is anything I can do to help!"
101
111
 
102
112
  You should try out the (varying) support fog has for:
103
113
  * {AWS}[http://aws.amazon.com] [{Compute}[http://aws.amazon.com/ec2], {ELB}[http://aws.amazon.com/elasticloadbalancing], {Storage}[http://aws.amazon.com/s3], {SimpleDB}[http://aws.amazon.com/simpledb]]
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.3.19'
11
- s.date = '2010-11-16'
10
+ s.version = '0.3.20'
11
+ s.date = '2010-11-17'
12
12
  s.rubyforge_project = 'fog'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
@@ -140,10 +140,13 @@ Gem::Specification.new do |s|
140
140
  lib/fog/aws/parsers/elb/enable_availability_zones_for_load_balancer.rb
141
141
  lib/fog/aws/parsers/elb/register_instances_with_load_balancer.rb
142
142
  lib/fog/aws/parsers/iam/basic.rb
143
+ lib/fog/aws/parsers/iam/create_access_key.rb
143
144
  lib/fog/aws/parsers/iam/create_group.rb
144
145
  lib/fog/aws/parsers/iam/create_user.rb
145
- lib/fog/aws/parsers/iam/list_group_policies.rb
146
+ lib/fog/aws/parsers/iam/list_access_keys.rb
146
147
  lib/fog/aws/parsers/iam/list_groups.rb
148
+ lib/fog/aws/parsers/iam/list_policies.rb
149
+ lib/fog/aws/parsers/iam/list_users.rb
147
150
  lib/fog/aws/parsers/simpledb/basic.rb
148
151
  lib/fog/aws/parsers/simpledb/domain_metadata.rb
149
152
  lib/fog/aws/parsers/simpledb/get_attributes.rb
@@ -218,15 +221,23 @@ Gem::Specification.new do |s|
218
221
  lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb
219
222
  lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb
220
223
  lib/fog/aws/requests/iam/add_user_to_group.rb
224
+ lib/fog/aws/requests/iam/create_access_key.rb
221
225
  lib/fog/aws/requests/iam/create_group.rb
222
226
  lib/fog/aws/requests/iam/create_user.rb
227
+ lib/fog/aws/requests/iam/delete_access_key.rb
223
228
  lib/fog/aws/requests/iam/delete_group.rb
224
229
  lib/fog/aws/requests/iam/delete_group_policy.rb
225
230
  lib/fog/aws/requests/iam/delete_user.rb
231
+ lib/fog/aws/requests/iam/delete_user_policy.rb
232
+ lib/fog/aws/requests/iam/list_access_keys.rb
226
233
  lib/fog/aws/requests/iam/list_group_policies.rb
227
234
  lib/fog/aws/requests/iam/list_groups.rb
235
+ lib/fog/aws/requests/iam/list_user_policies.rb
236
+ lib/fog/aws/requests/iam/list_users.rb
228
237
  lib/fog/aws/requests/iam/put_group_policy.rb
238
+ lib/fog/aws/requests/iam/put_user_policy.rb
229
239
  lib/fog/aws/requests/iam/remove_user_from_group.rb
240
+ lib/fog/aws/requests/iam/update_access_key.rb
230
241
  lib/fog/aws/requests/simpledb/batch_put_attributes.rb
231
242
  lib/fog/aws/requests/simpledb/create_domain.rb
232
243
  lib/fog/aws/requests/simpledb/delete_attributes.rb
@@ -730,6 +741,11 @@ Gem::Specification.new do |s|
730
741
  tests/aws/requests/compute/snapshot_tests.rb
731
742
  tests/aws/requests/compute/tag_tests.rb
732
743
  tests/aws/requests/compute/volume_tests.rb
744
+ tests/aws/requests/iam/access_key_tests.rb
745
+ tests/aws/requests/iam/group_policy_tests.rb
746
+ tests/aws/requests/iam/group_tests.rb
747
+ tests/aws/requests/iam/user_policy_tests.rb
748
+ tests/aws/requests/iam/user_tests.rb
733
749
  tests/aws/requests/storage/bucket_tests.rb
734
750
  tests/aws/requests/storage/multipart_upload_tests.rb
735
751
  tests/aws/requests/storage/object_tests.rb
data/lib/fog.rb CHANGED
@@ -18,7 +18,7 @@ module Fog
18
18
  @mocking = false
19
19
 
20
20
  unless const_defined?(:VERSION)
21
- VERSION = '0.3.19'
21
+ VERSION = '0.3.20'
22
22
  end
23
23
 
24
24
  module Mock
@@ -6,15 +6,23 @@ module Fog
6
6
 
7
7
  request_path 'fog/aws/requests/iam'
8
8
  request :add_user_to_group
9
+ request :create_access_key
9
10
  request :create_group
10
11
  request :create_user
12
+ request :delete_access_key
11
13
  request :delete_group
12
14
  request :delete_group_policy
13
15
  request :delete_user
16
+ request :delete_user_policy
17
+ request :list_access_keys
14
18
  request :list_groups
15
19
  request :list_group_policies
20
+ request :list_user_policies
21
+ request :list_users
16
22
  request :put_group_policy
23
+ request :put_user_policy
17
24
  request :remove_user_from_group
25
+ request :update_access_key
18
26
 
19
27
  class Mock
20
28
 
@@ -98,6 +98,11 @@ module Fog
98
98
 
99
99
  data = connection.put_object(directory.key, @key, @body, options)
100
100
  merge_attributes(data.headers)
101
+ if body.is_a?(String)
102
+ self.content_length = body.size
103
+ else
104
+ self.content_length = ::File.size(body.path)
105
+ end
101
106
  true
102
107
  end
103
108
 
@@ -7,7 +7,7 @@ module Fog
7
7
 
8
8
  def end_element(name)
9
9
  case name
10
- when 'requestId'
10
+ when 'RequestId'
11
11
  @response[name] = @value
12
12
  end
13
13
  end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module IAM
5
+
6
+ class CreateAccessKey < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'AccessKey' => {} }
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'AccessKeyId', 'UserName', 'SecretAccessKey', 'Status'
15
+ @response['AccessKey'][name] = @value
16
+ when 'RequestId'
17
+ @response[name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module IAM
5
+
6
+ class ListAccessKeys < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @access_key = {}
10
+ @response = { 'AccessKeys' => [] }
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'AccessKeyId', 'Status', 'Username'
16
+ @access_key[name] = @value
17
+ when 'member'
18
+ @response['AccessKeys'] << @access_key
19
+ @access_key = {}
20
+ when 'IsTruncated'
21
+ response[name] = (@value == 'true')
22
+ when 'Marker', 'RequestId'
23
+ response[name] = @value
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -3,7 +3,7 @@ module Fog
3
3
  module AWS
4
4
  module IAM
5
5
 
6
- class ListGroups < Fog::Parsers::Base
6
+ class ListPolicies < Fog::Parsers::Base
7
7
 
8
8
  def reset
9
9
  @response = { 'PolicyNames' => [] }
@@ -0,0 +1,32 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module IAM
5
+
6
+ class ListUsers < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @user = {}
10
+ @response = { 'Users' => [] }
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'Arn', 'UserId', 'UserName', 'Path'
16
+ @user[name] = @value
17
+ when 'member'
18
+ @response['Users'] << @user
19
+ @user = {}
20
+ when 'IsTruncated'
21
+ response[name] = (@value == 'true')
22
+ when 'Marker', 'RequestId'
23
+ response[name] = @value
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/create_access_key'
7
+
8
+ # Create a access keys for user (by default detects user from access credentials)
9
+ #
10
+ # ==== Parameters
11
+ # * options<~Hash>:
12
+ # * 'UserName'<~String> - name of the user to create (do not include path)
13
+ #
14
+ # ==== Returns
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * 'AccessKey'<~Hash>:
18
+ # * 'AccessKeyId'<~String> -
19
+ # * 'Username'<~String> -
20
+ # * 'SecretAccessKey'<~String> -
21
+ # * 'Status'<~String> -
22
+ # * 'RequestId'<~String> - Id of the request
23
+ #
24
+ # ==== See Also
25
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_CreateAccessKey.html
26
+ #
27
+ def create_access_key(options = {})
28
+ request({
29
+ 'Action' => 'CreateAccessKey',
30
+ :parser => Fog::Parsers::AWS::IAM::CreateAccessKey.new
31
+ }.merge!(options))
32
+ end
33
+
34
+ end
35
+
36
+ class Mock
37
+
38
+ def create_access_key(user_name = nil)
39
+ Fog::Mock.not_implemented
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -15,10 +15,10 @@ module Fog
15
15
  # * response<~Excon::Response>:
16
16
  # * body<~Hash>:
17
17
  # * 'User'<~Hash>:
18
- # * Arn<~String> -
19
- # * GroupId<~String> -
20
- # * GroupName<~String> -
21
- # * Path<~String> -
18
+ # * 'Arn'<~String> -
19
+ # * 'Path'<~String> -
20
+ # * 'UserId'<~String> -
21
+ # * 'UserName'<~String> -
22
22
  # * 'RequestId'<~String> - Id of the request
23
23
  #
24
24
  # ==== See Also
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/basic'
7
+
8
+ # Delete an access key
9
+ #
10
+ # ==== Parameters
11
+ # * access_key_id<~String> - Access key id to delete
12
+ # * options<~Hash>:
13
+ # * 'UserName'<~String> - name of the user to create (do not include path)
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * 'RequestId'<~String> - Id of the request
19
+ #
20
+ # ==== See Also
21
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_DeleteAccessKey.html
22
+ #
23
+ def delete_access_key(access_key_id, options = {})
24
+ request({
25
+ 'AccessKeyId' => access_key_id,
26
+ 'Action' => 'DeleteAccessKey',
27
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
28
+ }.merge!(options))
29
+ end
30
+
31
+ end
32
+
33
+ class Mock
34
+
35
+ def delete_access_key(access_key_id, user_name = nil)
36
+ Fog::Mock.not_implemented
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -14,7 +14,7 @@ module Fog
14
14
  # ==== Returns
15
15
  # * response<~Excon::Response>:
16
16
  # * body<~Hash>:
17
- # * 'RequestId'<~String> - Id of the request def put_group_policy(group_name, path = '/')
17
+ # * 'RequestId'<~String> - Id of the request
18
18
  #
19
19
  # ==== See Also
20
20
  # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_DeleteGroupPolicy.html
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/basic'
7
+
8
+ # Remove a policy from a user
9
+ #
10
+ # ==== Parameters
11
+ # * user_name<~String>: name of the user
12
+ # * policy_name<~String>: name of policy document
13
+ #
14
+ # ==== Returns
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * 'RequestId'<~String> - Id of the request
18
+ #
19
+ # ==== See Also
20
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_DeleteUserPolicy.html
21
+ #
22
+ def delete_user_policy(user_name, policy_name)
23
+ request(
24
+ 'Action' => 'DeleteUserPolicy',
25
+ 'PolicyName' => policy_name,
26
+ 'UserName' => user_name,
27
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
28
+ )
29
+ end
30
+
31
+ end
32
+
33
+ class Mock
34
+
35
+ def delete_user_policy(user_name, policy_name)
36
+ Fog::Mock.not_implemented
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,48 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/list_access_keys'
7
+
8
+ # List access_keys
9
+ #
10
+ # ==== Parameters
11
+ # * options<~Hash>:
12
+ # * 'Marker'<~String> - used to paginate subsequent requests
13
+ # * 'MaxItems'<~Integer> - limit results to this number per page
14
+ # * 'UserName'<~String> - optional: username to lookup access keys for, defaults to current user
15
+ #
16
+ # ==== Returns
17
+ # * response<~Excon::Response>:
18
+ # * body<~Hash>:
19
+ # * 'AccessKeys'<~Array> - Matching access keys
20
+ # * access_key<~Hash>:
21
+ # * AccessKeyId<~String> -
22
+ # * Status<~String> -
23
+ # * 'IsTruncated<~Boolean> - Whether or not results were truncated
24
+ # * 'Marker'<~String> - appears when IsTruncated is true as the next marker to use
25
+ # * 'RequestId'<~String> - Id of the request
26
+ #
27
+ # ==== See Also
28
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_ListAccessKeys.html
29
+ #
30
+ def list_access_keys(options = {})
31
+ request({
32
+ 'Action' => 'ListAccessKeys',
33
+ :parser => Fog::Parsers::AWS::IAM::ListAccessKeys.new
34
+ }.merge!(options))
35
+ end
36
+
37
+ end
38
+
39
+ class Mock
40
+
41
+ def list_access_keys(options = {})
42
+ Fog::Mock.not_implemented
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -3,7 +3,7 @@ module Fog
3
3
  class IAM
4
4
  class Real
5
5
 
6
- require 'fog/aws/parsers/iam/list_group_policies'
6
+ require 'fog/aws/parsers/iam/list_policies'
7
7
 
8
8
  # List policies for a group
9
9
  #
@@ -29,7 +29,7 @@ module Fog
29
29
  request({
30
30
  'Action' => 'ListGroupPolicies',
31
31
  'GroupName' => group_name,
32
- :parser => Fog::Parsers::AWS::IAM::ListGroupPolicies.new
32
+ :parser => Fog::Parsers::AWS::IAM::ListPolicies.new
33
33
  }.merge!(options))
34
34
  end
35
35
 
@@ -0,0 +1,47 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/list_policies'
7
+
8
+ # List policies for a user
9
+ #
10
+ # ==== Parameters
11
+ # * user_name<~String> - Name of user to list policies for
12
+ # * options<~Hash>: Optional
13
+ # * 'Marker'<~String>: used to paginate subsequent requests
14
+ # * 'MaxItems'<~Integer>: limit results to this number per page
15
+ # * 'PathPrefix'<~String>: prefix for filtering results
16
+ #
17
+ # ==== Returns
18
+ # * response<~Excon::Response>:
19
+ # * body<~Hash>:
20
+ # * 'PolicyNames'<~Array> - Matching policy names
21
+ # * 'IsTruncated<~Boolean> - Whether or not results were truncated
22
+ # * 'Marker'<~String> - appears when IsTruncated is true as the next marker to use
23
+ # * 'RequestId'<~String> - Id of the request
24
+ #
25
+ # ==== See Also
26
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_ListUserPolicies.html
27
+ #
28
+ def list_user_policies(user_name, options = {})
29
+ request({
30
+ 'Action' => 'ListUserPolicies',
31
+ 'UserName' => user_name,
32
+ :parser => Fog::Parsers::AWS::IAM::ListPolicies.new
33
+ }.merge!(options))
34
+ end
35
+
36
+ end
37
+
38
+ class Mock
39
+
40
+ def list_user_policies(user_name, options = {})
41
+ Fog::Mock.not_implemented
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/list_users'
7
+
8
+ # List users
9
+ #
10
+ # ==== Parameters
11
+ # * options<~Hash>:
12
+ # * 'Marker'<~String>: used to paginate subsequent requests
13
+ # * 'MaxItems'<~Integer>: limit results to this number per page
14
+ # * 'PathPrefix'<~String>: prefix for filtering results
15
+ #
16
+ # ==== Returns
17
+ # * response<~Excon::Response>:
18
+ # * body<~Hash>:
19
+ # * 'Users'<~Array> - Matching groups
20
+ # * user<~Hash>:
21
+ # * Arn<~String> -
22
+ # * Path<~String> -
23
+ # * UserId<~String> -
24
+ # * UserName<~String> -
25
+ # * 'IsTruncated<~Boolean> - Whether or not results were truncated
26
+ # * 'Marker'<~String> - appears when IsTruncated is true as the next marker to use
27
+ # * 'RequestId'<~String> - Id of the request
28
+ #
29
+ # ==== See Also
30
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_ListUsers.html
31
+ #
32
+ def list_users(options = {})
33
+ request({
34
+ 'Action' => 'ListUsers',
35
+ :parser => Fog::Parsers::AWS::IAM::ListUsers.new
36
+ }.merge!(options))
37
+ end
38
+
39
+ end
40
+
41
+ class Mock
42
+
43
+ def list_users(options = {})
44
+ Fog::Mock.not_implemented
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -15,7 +15,7 @@ module Fog
15
15
  # ==== Returns
16
16
  # * response<~Excon::Response>:
17
17
  # * body<~Hash>:
18
- # * 'RequestId'<~String> - Id of the request def put_group_policy(group_name, path = '/')
18
+ # * 'RequestId'<~String> - Id of the request
19
19
  #
20
20
  # ==== See Also
21
21
  # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_PutGroupPolicy.html
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/basic'
7
+
8
+ # Add or update a policy for a user
9
+ #
10
+ # ==== Parameters
11
+ # * user_name<~String>: name of the user
12
+ # * policy_name<~String>: name of policy document
13
+ # * policy_document<~Hash>: policy document, see: http://docs.amazonwebservices.com/IAM/latest/UserGuide/PoliciesOverview.html
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * 'RequestId'<~String> - Id of the request
19
+ #
20
+ # ==== See Also
21
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_PutUserPolicy.html
22
+ #
23
+ def put_user_policy(user_name, policy_name, policy_document)
24
+ request(
25
+ 'Action' => 'PutUserPolicy',
26
+ 'PolicyName' => policy_name,
27
+ 'PolicyDocument' => policy_document.to_json,
28
+ 'UserName' => user_name,
29
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
30
+ )
31
+ end
32
+
33
+ end
34
+
35
+ class Mock
36
+
37
+ def put_user_policy(user_name, policy_name, policy_document)
38
+ Fog::Mock.not_implemented
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module AWS
3
+ class IAM
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/iam/basic'
7
+
8
+ # Update an access key for a user
9
+ #
10
+ # ==== Parameters
11
+ # * access_key_id<~String> - Access key id to delete
12
+ # * status<~String> - status of keys in ['Active', 'Inactive']
13
+ # * options<~Hash>:
14
+ # * 'UserName'<~String> - name of the user to create (do not include path)
15
+ #
16
+ # ==== Returns
17
+ # * response<~Excon::Response>:
18
+ # * body<~Hash>:
19
+ # * 'RequestId'<~String> - Id of the request
20
+ #
21
+ # ==== See Also
22
+ # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_UpdateAccessKey.html
23
+ #
24
+ def update_access_key(access_key_id, status, options = {})
25
+ request({
26
+ 'AccessKeyId' => access_key_id,
27
+ 'Action' => 'UpdateAccessKey',
28
+ 'Status' => status,
29
+ :parser => Fog::Parsers::AWS::IAM::Basic.new
30
+ }.merge!(options))
31
+ end
32
+
33
+ end
34
+
35
+ class Mock
36
+
37
+ def update_access_key(access_key_id, status, user_name = nil)
38
+ Fog::Mock.not_implemented
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -16,6 +16,7 @@ module Fog
16
16
  # * 'Content-Length'<~String> - Size of object in bytes (defaults to object.read.length)
17
17
  # * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message
18
18
  # * 'Content-Type'<~String> - Standard MIME type describing contents (defaults to MIME::Types.of.first)
19
+ # * 'Expires'<~String> - Cache expiry
19
20
  # * 'x-amz-acl'<~String> - Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
20
21
  # * "x-amz-meta-#{name}" - Headers to be returned with object, note total size of request without body must be less than 8 KB.
21
22
  #
@@ -100,6 +100,11 @@ module Fog
100
100
 
101
101
  data = connection.put_object(directory.key, @key, @body, options)
102
102
  merge_attributes(data.headers)
103
+ if body.is_a?(String)
104
+ self.content_length = body.size
105
+ else
106
+ self.content_length = ::File.size(body.path)
107
+ end
103
108
  true
104
109
  end
105
110
 
@@ -52,6 +52,11 @@ module Fog
52
52
  requires :body, :directory, :key
53
53
  data = connection.put_object(directory.key, @key, @body, options)
54
54
  merge_attributes(data.headers)
55
+ if body.is_a?(String)
56
+ self.content_length = body.size
57
+ else
58
+ self.content_length = ::File.size(body.path)
59
+ end
55
60
  true
56
61
  end
57
62
 
@@ -13,6 +13,18 @@ class AWS
13
13
 
14
14
  end
15
15
 
16
+ module IAM
17
+
18
+ module Formats
19
+
20
+ BASIC = {
21
+ 'RequestId' => String
22
+ }
23
+
24
+ end
25
+
26
+ end
27
+
16
28
  end
17
29
 
18
30
  unless defined?(GENTOO_AMI)
@@ -0,0 +1,60 @@
1
+ Shindo.tests('AWS::IAM | access key requests', ['aws']) do
2
+
3
+ unless Fog.mocking?
4
+ AWS[:iam].create_user('fog_access_key_tests')
5
+ end
6
+
7
+ tests('success') do
8
+
9
+ @access_key_format = {
10
+ 'AccessKey' => {
11
+ 'AccessKeyId' => String,
12
+ 'UserName' => String,
13
+ 'SecretAccessKey' => String,
14
+ 'Status' => String
15
+ },
16
+ 'RequestId' => String
17
+ }
18
+
19
+ tests("#create_access_key('UserName' => 'fog_access_key_tests')").formats(@access_key_format) do
20
+ pending if Fog.mocking?
21
+ data = AWS[:iam].create_access_key('UserName' => 'fog_access_key_tests').body
22
+ @access_key_id = data['AccessKey']['AccessKeyId']
23
+ data
24
+ end
25
+
26
+ @access_keys_format = {
27
+ 'AccessKeys' => [{
28
+ 'AccessKeyId' => String,
29
+ 'Status' => String
30
+ }],
31
+ 'IsTruncated' => Fog::Boolean,
32
+ 'RequestId' => String
33
+ }
34
+
35
+ tests("#list_access_keys('Username' => 'fog_access_key_tests')").formats(@access_keys_format) do
36
+ pending if Fog.mocking?
37
+ AWS[:iam].list_access_keys('UserName' => 'fog_access_key_tests').body
38
+ end
39
+
40
+ tests("#update_access_key('#{@access_key_id}', 'Inactive', 'UserName' => 'fog_access_key_tests')").formats(AWS::IAM::Formats::BASIC) do
41
+ pending if Fog.mocking?
42
+ AWS[:iam].update_access_key(@access_key_id, 'Inactive', 'UserName' => 'fog_access_key_tests').body
43
+ end
44
+
45
+ tests("#delete_access_key('#{@access_key_id}', 'UserName' => 'fog_access_key_tests)").formats(AWS::IAM::Formats::BASIC) do
46
+ pending if Fog.mocking?
47
+ AWS[:iam].delete_access_key(@access_key_id, 'UserName' => 'fog_access_key_tests').body
48
+ end
49
+
50
+ end
51
+
52
+ tests('failure') do
53
+ test('failing conditions')
54
+ end
55
+
56
+ unless Fog.mocking?
57
+ AWS[:iam].delete_user('fog_access_key_tests')
58
+ end
59
+
60
+ end
@@ -0,0 +1,42 @@
1
+ Shindo.tests('AWS::IAM | group policy requests', ['aws']) do
2
+
3
+ unless Fog.mocking?
4
+ AWS[:iam].create_group('fog_group_policy_tests')
5
+ end
6
+
7
+ tests('success') do
8
+
9
+ @policy = {"Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]}
10
+
11
+ tests("#put_group_policy('fog_group_policy_tests', 'fog_policy', #{@policy.inspect})").formats(AWS::IAM::Formats::BASIC) do
12
+ pending if Fog.mocking?
13
+ AWS[:iam].put_group_policy('fog_group_policy_tests', 'fog_policy', @policy).body
14
+ end
15
+
16
+ @group_policies_format = {
17
+ 'IsTruncated' => Fog::Boolean,
18
+ 'PolicyNames' => [String],
19
+ 'RequestId' => String
20
+ }
21
+
22
+ tests("list_group_policies('fog_group_policy_tests')").formats(@group_policies_format) do
23
+ pending if Fog.mocking?
24
+ AWS[:iam].list_group_policies('fog_group_policy_tests').body
25
+ end
26
+
27
+ tests("#delete_group_policy('fog_group_policy_tests', 'fog_policy')").formats(AWS::IAM::Formats::BASIC) do
28
+ pending if Fog.mocking?
29
+ AWS[:iam].delete_group_policy('fog_group_policy_tests', 'fog_policy').body
30
+ end
31
+
32
+ end
33
+
34
+ tests('failure') do
35
+ test('failing conditions')
36
+ end
37
+
38
+ unless Fog.mocking?
39
+ AWS[:iam].delete_group('fog_group_policy_tests')
40
+ end
41
+
42
+ end
@@ -0,0 +1,47 @@
1
+ Shindo.tests('AWS::IAM | group requests', ['aws']) do
2
+
3
+ tests('success') do
4
+
5
+ @group_format = {
6
+ 'Group' => {
7
+ 'Arn' => String,
8
+ 'GroupId' => String,
9
+ 'GroupName' => String,
10
+ 'Path' => String
11
+ },
12
+ 'RequestId' => String
13
+ }
14
+
15
+ tests("#create_group('fog_group')").formats(@group_format) do
16
+ pending if Fog.mocking?
17
+ AWS[:iam].create_group('fog_group').body
18
+ end
19
+
20
+ @groups_format = {
21
+ 'Groups' => [{
22
+ 'Arn' => String,
23
+ 'GroupId' => String,
24
+ 'GroupName' => String,
25
+ 'Path' => String
26
+ }],
27
+ 'IsTruncated' => Fog::Boolean,
28
+ 'RequestId' => String
29
+ }
30
+
31
+ tests("#list_groups").formats(@groups_format) do
32
+ pending if Fog.mocking?
33
+ AWS[:iam].list_groups.body
34
+ end
35
+
36
+ tests("#delete_group('fog_group')").formats(AWS::IAM::Formats::BASIC) do
37
+ pending if Fog.mocking?
38
+ AWS[:iam].delete_group('fog_group').body
39
+ end
40
+
41
+ end
42
+
43
+ tests('failure') do
44
+ test('failing conditions')
45
+ end
46
+
47
+ end
@@ -0,0 +1,42 @@
1
+ Shindo.tests('AWS::IAM | user policy requests', ['aws']) do
2
+
3
+ unless Fog.mocking?
4
+ AWS[:iam].create_user('fog_user_policy_tests')
5
+ end
6
+
7
+ tests('success') do
8
+
9
+ @policy = {"Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]}
10
+
11
+ tests("#put_user_policy('fog_user_policy_tests', 'fog_policy', #{@policy.inspect})").formats(AWS::IAM::Formats::BASIC) do
12
+ pending if Fog.mocking?
13
+ AWS[:iam].put_user_policy('fog_user_policy_tests', 'fog_policy', @policy).body
14
+ end
15
+
16
+ @user_policies_format = {
17
+ 'IsTruncated' => Fog::Boolean,
18
+ 'PolicyNames' => [String],
19
+ 'RequestId' => String
20
+ }
21
+
22
+ tests("list_user_policies('fog_user_policy_tests')").formats(@user_policies_format) do
23
+ pending if Fog.mocking?
24
+ AWS[:iam].list_user_policies('fog_user_policy_tests').body
25
+ end
26
+
27
+ tests("#delete_user_policy('fog_user_policy_tests', 'fog_policy')").formats(AWS::IAM::Formats::BASIC) do
28
+ pending if Fog.mocking?
29
+ AWS[:iam].delete_user_policy('fog_user_policy_tests', 'fog_policy').body
30
+ end
31
+
32
+ end
33
+
34
+ tests('failure') do
35
+ test('failing conditions')
36
+ end
37
+
38
+ unless Fog.mocking?
39
+ AWS[:iam].delete_user('fog_user_policy_tests')
40
+ end
41
+
42
+ end
@@ -0,0 +1,65 @@
1
+ Shindo.tests('AWS::IAM | user requests', ['aws']) do
2
+
3
+ unless Fog.mocking?
4
+ AWS[:iam].create_group('fog_user_tests')
5
+ end
6
+
7
+ tests('success') do
8
+
9
+ @user_format = {
10
+ 'User' => {
11
+ 'Arn' => String,
12
+ 'Path' => String,
13
+ 'UserId' => String,
14
+ 'UserName' => String
15
+ },
16
+ 'RequestId' => String
17
+ }
18
+
19
+ tests("#create_user('fog_user')").formats(@user_format) do
20
+ pending if Fog.mocking?
21
+ AWS[:iam].create_user('fog_user').body
22
+ end
23
+
24
+ @users_format = {
25
+ 'Users' => [{
26
+ 'Arn' => String,
27
+ 'Path' => String,
28
+ 'UserId' => String,
29
+ 'UserName' => String
30
+ }],
31
+ 'IsTruncated' => Fog::Boolean,
32
+ 'RequestId' => String
33
+ }
34
+
35
+ tests("#list_users").formats(@users_format) do
36
+ pending if Fog.mocking?
37
+ AWS[:iam].list_users.body
38
+ end
39
+
40
+ tests("#add_user_to_group('fog_user_tests', 'fog_user')").formats(AWS::IAM::Formats::BASIC) do
41
+ pending if Fog.mocking?
42
+ AWS[:iam].add_user_to_group('fog_user_tests', 'fog_user').body
43
+ end
44
+
45
+ tests("#remove_user_from_group('fog_user_tests', 'fog_user')").formats(AWS::IAM::Formats::BASIC) do
46
+ pending if Fog.mocking?
47
+ AWS[:iam].remove_user_from_group('fog_user_tests', 'fog_user').body
48
+ end
49
+
50
+ tests("#delete_user('fog_user')").formats(AWS::IAM::Formats::BASIC) do
51
+ pending if Fog.mocking?
52
+ AWS[:iam].delete_user('fog_user').body
53
+ end
54
+
55
+ end
56
+
57
+ tests('failure') do
58
+ test('failing conditions')
59
+ end
60
+
61
+ unless Fog.mocking?
62
+ AWS[:iam].delete_group('fog_user_tests')
63
+ end
64
+
65
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 19
9
- version: 0.3.19
8
+ - 20
9
+ version: 0.3.20
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-16 00:00:00 -08:00
17
+ date: 2010-11-17 00:00:00 -08:00
18
18
  default_executable: fog
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -249,10 +249,13 @@ files:
249
249
  - lib/fog/aws/parsers/elb/enable_availability_zones_for_load_balancer.rb
250
250
  - lib/fog/aws/parsers/elb/register_instances_with_load_balancer.rb
251
251
  - lib/fog/aws/parsers/iam/basic.rb
252
+ - lib/fog/aws/parsers/iam/create_access_key.rb
252
253
  - lib/fog/aws/parsers/iam/create_group.rb
253
254
  - lib/fog/aws/parsers/iam/create_user.rb
254
- - lib/fog/aws/parsers/iam/list_group_policies.rb
255
+ - lib/fog/aws/parsers/iam/list_access_keys.rb
255
256
  - lib/fog/aws/parsers/iam/list_groups.rb
257
+ - lib/fog/aws/parsers/iam/list_policies.rb
258
+ - lib/fog/aws/parsers/iam/list_users.rb
256
259
  - lib/fog/aws/parsers/simpledb/basic.rb
257
260
  - lib/fog/aws/parsers/simpledb/domain_metadata.rb
258
261
  - lib/fog/aws/parsers/simpledb/get_attributes.rb
@@ -327,15 +330,23 @@ files:
327
330
  - lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb
328
331
  - lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb
329
332
  - lib/fog/aws/requests/iam/add_user_to_group.rb
333
+ - lib/fog/aws/requests/iam/create_access_key.rb
330
334
  - lib/fog/aws/requests/iam/create_group.rb
331
335
  - lib/fog/aws/requests/iam/create_user.rb
336
+ - lib/fog/aws/requests/iam/delete_access_key.rb
332
337
  - lib/fog/aws/requests/iam/delete_group.rb
333
338
  - lib/fog/aws/requests/iam/delete_group_policy.rb
334
339
  - lib/fog/aws/requests/iam/delete_user.rb
340
+ - lib/fog/aws/requests/iam/delete_user_policy.rb
341
+ - lib/fog/aws/requests/iam/list_access_keys.rb
335
342
  - lib/fog/aws/requests/iam/list_group_policies.rb
336
343
  - lib/fog/aws/requests/iam/list_groups.rb
344
+ - lib/fog/aws/requests/iam/list_user_policies.rb
345
+ - lib/fog/aws/requests/iam/list_users.rb
337
346
  - lib/fog/aws/requests/iam/put_group_policy.rb
347
+ - lib/fog/aws/requests/iam/put_user_policy.rb
338
348
  - lib/fog/aws/requests/iam/remove_user_from_group.rb
349
+ - lib/fog/aws/requests/iam/update_access_key.rb
339
350
  - lib/fog/aws/requests/simpledb/batch_put_attributes.rb
340
351
  - lib/fog/aws/requests/simpledb/create_domain.rb
341
352
  - lib/fog/aws/requests/simpledb/delete_attributes.rb
@@ -839,6 +850,11 @@ files:
839
850
  - tests/aws/requests/compute/snapshot_tests.rb
840
851
  - tests/aws/requests/compute/tag_tests.rb
841
852
  - tests/aws/requests/compute/volume_tests.rb
853
+ - tests/aws/requests/iam/access_key_tests.rb
854
+ - tests/aws/requests/iam/group_policy_tests.rb
855
+ - tests/aws/requests/iam/group_tests.rb
856
+ - tests/aws/requests/iam/user_policy_tests.rb
857
+ - tests/aws/requests/iam/user_tests.rb
842
858
  - tests/aws/requests/storage/bucket_tests.rb
843
859
  - tests/aws/requests/storage/multipart_upload_tests.rb
844
860
  - tests/aws/requests/storage/object_tests.rb