aws-sdk 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aws.rb +10 -9
- data/lib/aws/api_config/IAM-2010-07-15.yml +632 -0
- data/lib/aws/base_client.rb +1 -1
- data/lib/aws/cacheable.rb +34 -46
- data/lib/aws/client_logging.rb +19 -14
- data/lib/aws/collections.rb +230 -0
- data/lib/aws/common.rb +4 -0
- data/lib/aws/configuration.rb +7 -0
- data/lib/aws/ec2.rb +2 -2
- data/lib/aws/ec2/attachment.rb +64 -71
- data/lib/aws/ec2/attachment_collection.rb +11 -9
- data/lib/aws/ec2/availability_zone.rb +40 -31
- data/lib/aws/ec2/availability_zone_collection.rb +2 -3
- data/lib/aws/ec2/elastic_ip.rb +25 -22
- data/lib/aws/ec2/elastic_ip_collection.rb +5 -2
- data/lib/aws/ec2/image.rb +113 -129
- data/lib/aws/ec2/image_collection.rb +5 -6
- data/lib/aws/ec2/instance.rb +290 -233
- data/lib/aws/ec2/instance_collection.rb +72 -67
- data/lib/aws/ec2/key_pair.rb +16 -18
- data/lib/aws/ec2/region.rb +25 -17
- data/lib/aws/ec2/reserved_instances.rb +7 -1
- data/lib/aws/ec2/reserved_instances_collection.rb +3 -3
- data/lib/aws/ec2/reserved_instances_offering.rb +7 -1
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +3 -3
- data/lib/aws/ec2/resource.rb +41 -222
- data/lib/aws/ec2/security_group.rb +22 -18
- data/lib/aws/ec2/security_group_collection.rb +2 -5
- data/lib/aws/ec2/snapshot.rb +44 -35
- data/lib/aws/ec2/snapshot_collection.rb +43 -1
- data/lib/aws/ec2/tag.rb +14 -18
- data/lib/aws/ec2/volume.rb +59 -72
- data/lib/aws/ec2/volume_collection.rb +16 -12
- data/lib/aws/errors.rb +14 -5
- data/lib/aws/http/httparty_handler.rb +2 -2
- data/lib/aws/iam.rb +306 -0
- data/lib/aws/iam/access_key.rb +183 -0
- data/lib/aws/iam/access_key_collection.rb +131 -0
- data/lib/aws/iam/account_alias_collection.rb +81 -0
- data/lib/aws/iam/client.rb +44 -0
- data/lib/aws/iam/client/xml.rb +38 -0
- data/lib/aws/iam/collection.rb +87 -0
- data/lib/aws/iam/errors.rb +29 -0
- data/lib/aws/iam/group.rb +117 -0
- data/lib/aws/iam/group_collection.rb +135 -0
- data/lib/aws/iam/group_policy_collection.rb +49 -0
- data/lib/aws/iam/group_user_collection.rb +94 -0
- data/lib/aws/iam/login_profile.rb +97 -0
- data/lib/aws/iam/mfa_device.rb +52 -0
- data/lib/aws/iam/mfa_device_collection.rb +119 -0
- data/lib/aws/iam/policy.rb +48 -0
- data/lib/aws/iam/policy_collection.rb +191 -0
- data/lib/aws/iam/request.rb +27 -0
- data/lib/aws/iam/resource.rb +74 -0
- data/lib/aws/iam/server_certificate.rb +143 -0
- data/lib/aws/iam/server_certificate_collection.rb +174 -0
- data/lib/aws/iam/signing_certificate.rb +171 -0
- data/lib/aws/iam/signing_certificate_collection.rb +134 -0
- data/lib/aws/iam/user.rb +196 -0
- data/lib/aws/iam/user_collection.rb +136 -0
- data/lib/aws/iam/user_group_collection.rb +101 -0
- data/lib/aws/iam/user_policy.rb +90 -0
- data/lib/aws/iam/user_policy_collection.rb +48 -0
- data/lib/aws/resource.rb +381 -0
- data/lib/aws/resource_cache.rb +1 -2
- data/lib/aws/response.rb +5 -1
- data/lib/aws/response_cache.rb +1 -1
- data/lib/aws/s3/client.rb +3 -1
- data/lib/aws/s3/presigned_post.rb +1 -1
- data/lib/aws/simple_db.rb +1 -1
- metadata +113 -50
@@ -0,0 +1,131 @@
|
|
1
|
+
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/iam/collection'
|
15
|
+
require 'aws/iam/access_key'
|
16
|
+
|
17
|
+
module AWS
|
18
|
+
class IAM
|
19
|
+
|
20
|
+
# Both AWS accounts and IAM users can have access keys (maximum of 2).
|
21
|
+
# You can create new keys so that you can rotate out your old keys.
|
22
|
+
# You can create, delete, activate and deactivate access keys.
|
23
|
+
#
|
24
|
+
# == Create New Access Keys
|
25
|
+
#
|
26
|
+
# # for the aws account
|
27
|
+
# access_keys = iam.access_keys.create
|
28
|
+
#
|
29
|
+
# # for an iam user
|
30
|
+
# user_access_keys = iam.users['johndoe'].access_keys.create
|
31
|
+
#
|
32
|
+
# == Secret
|
33
|
+
#
|
34
|
+
# Make sure after creating an access to retrieve the secret access key
|
35
|
+
# and save it somewhere safe.
|
36
|
+
#
|
37
|
+
# access_keys = iam.access_keys.create
|
38
|
+
# secret = access_keys.secret
|
39
|
+
#
|
40
|
+
# If you try to access the secret on an access key that was not newly
|
41
|
+
# created an error will be raised. AWS will only give the secret for
|
42
|
+
# a newly created access key:
|
43
|
+
#
|
44
|
+
# access_keys = iam.access_keys.first
|
45
|
+
# access_keys.secret
|
46
|
+
# #=> oops, raises a runtime error
|
47
|
+
#
|
48
|
+
class AccessKeyCollection
|
49
|
+
|
50
|
+
include Collection
|
51
|
+
|
52
|
+
# @param [Hash] options
|
53
|
+
# @option options [User] :user If present, this collection will only
|
54
|
+
# represent the access keys for the given user.
|
55
|
+
def initialize options = {}
|
56
|
+
@user = options[:user]
|
57
|
+
@user ? super(@user, options) : super(options)
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [User,nil] Returns the user these accesss keys belong to.
|
61
|
+
# If this returns +nil+ then these access keys belong to the
|
62
|
+
# AWS account.
|
63
|
+
attr_reader :user
|
64
|
+
|
65
|
+
def create
|
66
|
+
|
67
|
+
options = {}
|
68
|
+
options[:user_name] = user.name if user
|
69
|
+
|
70
|
+
resp = client.create_access_key(options)
|
71
|
+
|
72
|
+
AccessKey.new_from(:create_access_key, resp.access_key,
|
73
|
+
resp.access_key.access_key_id, new_options)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param [String] access_key_id The ID of the access key.
|
78
|
+
# @return [AccessKey] Returns a reference to the access key with
|
79
|
+
# the given +access_key_id+.
|
80
|
+
def [] access_key_id
|
81
|
+
AccessKey.new(access_key_id, new_options)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Deletes all of the access keys from this collection.
|
85
|
+
#
|
86
|
+
# iam.users['someuser'].access_keys.clear
|
87
|
+
#
|
88
|
+
# @return [nil]
|
89
|
+
def clear
|
90
|
+
each{|access_key| access_key.delete }
|
91
|
+
nil
|
92
|
+
end
|
93
|
+
|
94
|
+
# Yields once for each access key. You can limit the number of
|
95
|
+
# access keys yielded using +:limit+.
|
96
|
+
#
|
97
|
+
# @param [Hash] options
|
98
|
+
# @option options [Integer] :limit The maximum number of access keys
|
99
|
+
# to yield.
|
100
|
+
# @option options [Integer] :batch_size The maximum number of
|
101
|
+
# access keys received each service reqeust.
|
102
|
+
# @yieldparam [AccessKey] access_key
|
103
|
+
# @return [nil]
|
104
|
+
def each options = {}, &block
|
105
|
+
each_options = options.dup
|
106
|
+
each_options[:user_name] = user.name if user
|
107
|
+
super(each_options, &block)
|
108
|
+
end
|
109
|
+
|
110
|
+
# @private
|
111
|
+
protected
|
112
|
+
def each_item response, &block
|
113
|
+
response.access_key_metadata.each do |item|
|
114
|
+
|
115
|
+
access_key = AccessKey.new_from(:list_access_keys, item,
|
116
|
+
item.access_key_id, new_options)
|
117
|
+
|
118
|
+
yield(access_key)
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# @private
|
124
|
+
protected
|
125
|
+
def new_options
|
126
|
+
user ? { :user => user } : { :config => config }
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/iam/collection'
|
15
|
+
|
16
|
+
module AWS
|
17
|
+
class IAM
|
18
|
+
|
19
|
+
# @private
|
20
|
+
#
|
21
|
+
# Currently IAM exposes the account alias in a collection, as if you
|
22
|
+
# could create/manage multiple aliases for a single account. However,
|
23
|
+
# creating a 2nd alias replaces the first, it does not add an additional
|
24
|
+
# alias.
|
25
|
+
#
|
26
|
+
# Because the API is modeled as a collection this class could be used
|
27
|
+
# to work with it, but instead we consume this by the IAM class for
|
28
|
+
# the following methods:
|
29
|
+
#
|
30
|
+
# * create_account_alias
|
31
|
+
# * account_alias
|
32
|
+
# * remove_account_alias
|
33
|
+
#
|
34
|
+
# If IAM allows accounts to have multiple aliases, then those previous
|
35
|
+
# 3 methods will be deprecated and this interface will be exposed.
|
36
|
+
class AccountAliasCollection
|
37
|
+
|
38
|
+
include Collection
|
39
|
+
|
40
|
+
# Creates an AWS account alias.
|
41
|
+
#
|
42
|
+
# iam.account_aliases.create('myaccountalias')
|
43
|
+
#
|
44
|
+
# For information about account alias restrictions and usage,
|
45
|
+
# see http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?AccountAlias.html.
|
46
|
+
#
|
47
|
+
# @param [String] account_alias
|
48
|
+
# @return [String] Returns the account_alias string that was passed.
|
49
|
+
def create account_alias
|
50
|
+
client.create_account_alias(:account_alias => account_alias)
|
51
|
+
account_alias
|
52
|
+
end
|
53
|
+
|
54
|
+
# Delete an AWS account alias.
|
55
|
+
#
|
56
|
+
# iam.account_aliases.delete('myaccountalias')
|
57
|
+
#
|
58
|
+
# @param [String] account_alias The account alias to delete.
|
59
|
+
# @return [nil]
|
60
|
+
def delete account_alias
|
61
|
+
client.delete_account_alias(:account_alias => account_alias)
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
# @private
|
66
|
+
protected
|
67
|
+
def request_method
|
68
|
+
:list_account_aliases
|
69
|
+
end
|
70
|
+
|
71
|
+
# @private
|
72
|
+
protected
|
73
|
+
def each_item response, &block
|
74
|
+
response.account_aliases.each do |account_alias|
|
75
|
+
yield(account_alias)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/base_client'
|
15
|
+
require 'aws/configured_client_methods'
|
16
|
+
require 'aws/iam/request'
|
17
|
+
require 'aws/iam/client/xml'
|
18
|
+
require 'aws/iam/errors'
|
19
|
+
|
20
|
+
module AWS
|
21
|
+
class IAM
|
22
|
+
|
23
|
+
# @private
|
24
|
+
class Client < BaseClient
|
25
|
+
|
26
|
+
include ConfiguredClientMethods
|
27
|
+
|
28
|
+
API_VERSION = '2010-05-08'
|
29
|
+
|
30
|
+
REQUEST_CLASS = IAM::Request
|
31
|
+
|
32
|
+
# @private
|
33
|
+
CACHEABLE_REQUESTS = Set[:list_groups,
|
34
|
+
:list_group_policies,
|
35
|
+
:list_groups_for_user,
|
36
|
+
:list_server_certificates,
|
37
|
+
:get_group,
|
38
|
+
:get_group_policy]
|
39
|
+
|
40
|
+
configure_client
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/configured_xml_grammars'
|
15
|
+
require 'aws/ignore_result_element'
|
16
|
+
require 'aws/xml_grammar'
|
17
|
+
|
18
|
+
module AWS
|
19
|
+
class IAM
|
20
|
+
class Client < BaseClient
|
21
|
+
|
22
|
+
# @private
|
23
|
+
module XML
|
24
|
+
|
25
|
+
include ConfiguredXmlGrammars
|
26
|
+
|
27
|
+
extend IgnoreResultElement
|
28
|
+
|
29
|
+
BaseError = XmlGrammar.customize do
|
30
|
+
element("Error") { ignore }
|
31
|
+
end
|
32
|
+
|
33
|
+
define_configured_grammars
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
3
|
+
# may not use this file except in compliance with the License. A copy of
|
4
|
+
# the License is located at
|
5
|
+
#
|
6
|
+
# http://aws.amazon.com/apache2.0/
|
7
|
+
#
|
8
|
+
# or in the "license" file accompanying this file. This file is
|
9
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
10
|
+
# ANY KIND, either express or implied. See the License for the specific
|
11
|
+
# language governing permissions and limitations under the License.
|
12
|
+
|
13
|
+
require 'aws/collections'
|
14
|
+
require 'aws/inflection'
|
15
|
+
|
16
|
+
module AWS
|
17
|
+
class IAM
|
18
|
+
module Collection
|
19
|
+
|
20
|
+
include Collections::PagedWithLimits
|
21
|
+
|
22
|
+
# Common methods for collection classes that can be filtered by
|
23
|
+
# a path prefix.
|
24
|
+
module WithPrefix
|
25
|
+
|
26
|
+
include Collection
|
27
|
+
|
28
|
+
# @return [String] The path prefix by which the collection is
|
29
|
+
# filtered.
|
30
|
+
attr_reader :prefix
|
31
|
+
|
32
|
+
# @private
|
33
|
+
def initialize(options = {})
|
34
|
+
@prefix = options[:prefix]
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def each options = {}, &block
|
39
|
+
options = {
|
40
|
+
:path_prefix => prefix
|
41
|
+
}.merge(options) if prefix
|
42
|
+
options[:path_prefix] = options.delete(:prefix) if
|
43
|
+
options.key?(:prefix)
|
44
|
+
if prefix = options[:path_prefix]
|
45
|
+
options[:path_prefix] = "/#{prefix}".sub(%r{^//}, "/")
|
46
|
+
end
|
47
|
+
super(options, &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns a collection object including only those groups whose
|
51
|
+
# paths begin with the supplied prefix.
|
52
|
+
#
|
53
|
+
# @param [String] prefix The path prefix for filtering the
|
54
|
+
# results.
|
55
|
+
#
|
56
|
+
# @return [GroupCollection]
|
57
|
+
def with_prefix(prefix)
|
58
|
+
prefix = "/#{prefix}".sub(%r{^//}, "/")
|
59
|
+
self.class.new(:prefix => prefix,
|
60
|
+
:config => config)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# @private
|
66
|
+
protected
|
67
|
+
def request_method
|
68
|
+
name = Inflection.ruby_name(self.class.name).sub(/_collection$/, '')
|
69
|
+
"list_#{name}s"
|
70
|
+
end
|
71
|
+
|
72
|
+
# @private
|
73
|
+
protected
|
74
|
+
def next_token_key
|
75
|
+
:marker
|
76
|
+
end
|
77
|
+
|
78
|
+
# @private
|
79
|
+
protected
|
80
|
+
def limit_key
|
81
|
+
:max_items
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/lazy_error_classes'
|
15
|
+
require 'aws/iam/client/xml'
|
16
|
+
|
17
|
+
module AWS
|
18
|
+
class IAM
|
19
|
+
|
20
|
+
# @private
|
21
|
+
module Errors
|
22
|
+
|
23
|
+
BASE_ERROR_GRAMMAR = Client::XML::BaseError
|
24
|
+
|
25
|
+
include LazyErrorClasses
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/iam/resource'
|
15
|
+
require 'aws/iam/errors'
|
16
|
+
require 'aws/iam/group_user_collection'
|
17
|
+
require 'aws/iam/group_policy_collection'
|
18
|
+
|
19
|
+
module AWS
|
20
|
+
class IAM
|
21
|
+
|
22
|
+
# Represents a group of users. Groups don't directly interact
|
23
|
+
# with AWS; only users do. The main reason to create groups is to
|
24
|
+
# collectively assign permissions to the users so they can do
|
25
|
+
# their jobs. For example, you could have a group called Admins
|
26
|
+
# and give that group the types of permissions admins typically
|
27
|
+
# need.
|
28
|
+
class Group < Resource
|
29
|
+
|
30
|
+
prefix_update_attributes
|
31
|
+
|
32
|
+
# @private
|
33
|
+
def initialize(name, options = {})
|
34
|
+
options[:name] = name
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
# @attr [String] The group's name.
|
39
|
+
mutable_attribute :name, :static => true, :as => :group_name
|
40
|
+
|
41
|
+
# @attr_reader [String] The group's unique ID.
|
42
|
+
attribute :id, :static => true, :as => :group_id
|
43
|
+
|
44
|
+
# @attr_reader [Time] When the group was created.
|
45
|
+
attribute :create_date, :static => true
|
46
|
+
|
47
|
+
# @attr_reader [String] The group's ARN (Amazon Resource Name).
|
48
|
+
attribute :arn
|
49
|
+
|
50
|
+
# @attr [String] The group's path. Paths are used to identify
|
51
|
+
# which division or part of an organization the group belongs
|
52
|
+
# to.
|
53
|
+
mutable_attribute :path do
|
54
|
+
translates_input do |path|
|
55
|
+
path = "/#{path}" unless path[0] == ?/
|
56
|
+
path = "#{path}/" unless path[-1] == ?/
|
57
|
+
path
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
populates_from(:get_group, :create_group) do |resp|
|
62
|
+
resp.group if resp.group.group_name == name
|
63
|
+
end
|
64
|
+
|
65
|
+
populates_from(:list_groups, :list_groups_for_user) do |resp|
|
66
|
+
resp.groups.find { |g| g.group_name == name }
|
67
|
+
end
|
68
|
+
|
69
|
+
# (see Resource#exists?)
|
70
|
+
def exists?; super; end
|
71
|
+
|
72
|
+
# Deletes the group. The group must not contain any users or
|
73
|
+
# have any attached policies.
|
74
|
+
def delete
|
75
|
+
client.delete_group(:group_name => name)
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
|
79
|
+
# Provides access to the users in the group. For example:
|
80
|
+
#
|
81
|
+
# # get the names of all the users in the group
|
82
|
+
# group.users.map(&:name)
|
83
|
+
#
|
84
|
+
# # remove all users from the group
|
85
|
+
# group.users.clear
|
86
|
+
#
|
87
|
+
# @return [GroupUserCollection] An object representing all the
|
88
|
+
# users in the group.
|
89
|
+
def users
|
90
|
+
GroupUserCollection.new(self)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Provides access to the policies associated with the group.
|
94
|
+
# For example:
|
95
|
+
#
|
96
|
+
# # get the policy named "ReadOnly"
|
97
|
+
# group.policies["ReadOnly"]
|
98
|
+
#
|
99
|
+
# # remove all policies associated with the group
|
100
|
+
# group.policies.clear
|
101
|
+
#
|
102
|
+
# @return [GroupPolicyCollection] An object representing all the
|
103
|
+
# policies associated with the group.
|
104
|
+
def policies
|
105
|
+
GroupPolicyCollection.new(self)
|
106
|
+
end
|
107
|
+
|
108
|
+
# @private
|
109
|
+
protected
|
110
|
+
def resource_identifiers
|
111
|
+
[[:group_name, name]]
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|