fog-aws 0.7.6 → 0.8.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -0
- data/lib/fog/aws/compute.rb +1 -1
- data/lib/fog/aws/iam/paged_collection.rb +4 -2
- data/lib/fog/aws/models/compute/server.rb +0 -1
- data/lib/fog/aws/models/elasticache/cluster.rb +2 -1
- data/lib/fog/aws/models/iam/roles.rb +11 -14
- data/lib/fog/aws/models/rds/server.rb +2 -1
- data/lib/fog/aws/models/storage/directory.rb +1 -1
- data/lib/fog/aws/parsers/elasticache/cache_cluster_parser.rb +29 -4
- data/lib/fog/aws/parsers/storage/get_bucket_lifecycle.rb +30 -0
- data/lib/fog/aws/requests/compute/describe_instances.rb +1 -1
- data/lib/fog/aws/requests/compute/start_instances.rb +1 -0
- data/lib/fog/aws/requests/compute/stop_instances.rb +1 -0
- data/lib/fog/aws/requests/dynamodb/batch_get_item.rb +8 -11
- data/lib/fog/aws/requests/dynamodb/batch_write_item.rb +11 -9
- data/lib/fog/aws/requests/dynamodb/create_table.rb +9 -14
- data/lib/fog/aws/requests/dynamodb/delete_item.rb +5 -15
- data/lib/fog/aws/requests/dynamodb/delete_table.rb +4 -8
- data/lib/fog/aws/requests/dynamodb/describe_table.rb +7 -8
- data/lib/fog/aws/requests/dynamodb/get_item.rb +9 -7
- data/lib/fog/aws/requests/dynamodb/list_tables.rb +4 -1
- data/lib/fog/aws/requests/dynamodb/put_item.rb +6 -10
- data/lib/fog/aws/requests/dynamodb/query.rb +14 -6
- data/lib/fog/aws/requests/dynamodb/scan.rb +6 -6
- data/lib/fog/aws/requests/dynamodb/update_item.rb +22 -20
- data/lib/fog/aws/requests/dynamodb/update_table.rb +6 -7
- data/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +1 -0
- data/lib/fog/aws/requests/iam/create_role.rb +1 -1
- data/lib/fog/aws/requests/iam/get_role.rb +5 -2
- data/lib/fog/aws/requests/iam/list_roles.rb +50 -16
- data/lib/fog/aws/requests/rds/modify_db_instance.rb +53 -54
- data/lib/fog/aws/requests/storage/get_object.rb +5 -3
- data/lib/fog/aws/requests/storage/put_bucket_lifecycle.rb +28 -5
- data/lib/fog/aws/requests/storage/put_object.rb +4 -0
- data/lib/fog/aws/storage.rb +3 -0
- data/lib/fog/aws/sts.rb +4 -3
- data/lib/fog/aws/version.rb +1 -1
- data/tests/models/compute/server_tests.rb +11 -0
- data/tests/models/iam/roles_tests.rb +12 -4
- data/tests/models/storage/directory_tests.rb +4 -0
- data/tests/requests/compute/instance_tests.rb +44 -2
- data/tests/requests/dynamodb/item_tests.rb +2 -2
- data/tests/requests/storage/bucket_tests.rb +5 -0
- metadata +4 -3
@@ -11,18 +11,14 @@ module Fog
|
|
11
11
|
# * response<~Excon::Response>:
|
12
12
|
# * body<~Hash>:
|
13
13
|
# * 'TableDescription'<~Hash>
|
14
|
-
# * 'KeySchema'<~Hash> - schema for table
|
15
|
-
# * 'HashKeyElement'<~Hash>: info for primary key
|
16
|
-
# * 'AttributeName'<~String> - name of attribute
|
17
|
-
# * 'AttributeType'<~String> - type of attribute, in %w{N NS S SS} for number, number set, string, string set
|
18
|
-
# * 'RangeKeyElement'<~Hash>: optional, info for range key
|
19
|
-
# * 'AttributeName'<~String> - name of attribute
|
20
|
-
# * 'AttributeType'<~String> - type of attribute, in %w{N NS S SS} for number, number set, string, string set
|
21
14
|
# * 'ProvisionedThroughput'<~Hash>:
|
22
15
|
# * 'ReadCapacityUnits'<~Integer> - read capacity for table, in 5..10000
|
23
16
|
# * 'WriteCapacityUnits'<~Integer> - write capacity for table, in 5..10000
|
24
17
|
# * 'TableName'<~String> - name of table
|
25
18
|
# * 'TableStatus'<~String> - status of table
|
19
|
+
#
|
20
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteTable.html
|
21
|
+
#
|
26
22
|
def delete_table(table_name)
|
27
23
|
body = {
|
28
24
|
'TableName' => table_name
|
@@ -30,7 +26,7 @@ module Fog
|
|
30
26
|
|
31
27
|
request(
|
32
28
|
:body => Fog::JSON.encode(body),
|
33
|
-
:headers => {'x-amz-target' => '
|
29
|
+
:headers => {'x-amz-target' => 'DynamoDB_20120810.DeleteTable'},
|
34
30
|
:idempotent => true
|
35
31
|
)
|
36
32
|
end
|
@@ -12,19 +12,18 @@ module Fog
|
|
12
12
|
# * body<~Hash>:
|
13
13
|
# * 'Table'<~Hash>
|
14
14
|
# * 'CreationDateTime'<~Float> - Unix epoch time of table creation
|
15
|
-
# * 'KeySchema'<~
|
16
|
-
# * '
|
17
|
-
#
|
18
|
-
# * 'AttributeType'<~String> - type of attribute, in %w{N NS S SS} for number, number set, string, string set
|
19
|
-
# * 'RangeKeyElement'<~Hash>: optional, info for range key
|
20
|
-
# * 'AttributeName'<~String> - name of attribute
|
21
|
-
# * 'AttributeType'<~String> - type of attribute, in %w{N NS S SS} for number, number set, string, string set
|
15
|
+
# * 'KeySchema'<~Array> - schema for table
|
16
|
+
# * 'AttributeName'<~String> - name of attribute
|
17
|
+
# * 'KeyType'<~String> - type of attribute, in %w{N NS S SS} for number, number set, string, string set
|
22
18
|
# * 'ProvisionedThroughput'<~Hash>:
|
23
19
|
# * 'ReadCapacityUnits'<~Integer> - read capacity for table, in 5..10000
|
24
20
|
# * 'WriteCapacityUnits'<~Integer> - write capacity for table, in 5..10000
|
25
21
|
# * 'TableName'<~String> - name of table
|
26
22
|
# * 'TableSizeBytes'<~Integer> - size of table in bytes
|
27
23
|
# * 'TableStatus'<~String> - status of table
|
24
|
+
#
|
25
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html
|
26
|
+
#
|
28
27
|
def describe_table(table_name)
|
29
28
|
body = {
|
30
29
|
'TableName' => table_name
|
@@ -32,7 +31,7 @@ module Fog
|
|
32
31
|
|
33
32
|
request(
|
34
33
|
:body => Fog::JSON.encode(body),
|
35
|
-
:headers => {'x-amz-target' => '
|
34
|
+
:headers => {'x-amz-target' => 'DynamoDB_20120810.DescribeTable'},
|
36
35
|
:idempotent => true
|
37
36
|
)
|
38
37
|
end
|
@@ -7,12 +7,11 @@ module Fog
|
|
7
7
|
# ==== Parameters
|
8
8
|
# * 'table_name'<~String> - name of table for item
|
9
9
|
# * 'key'<~Hash>:
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# * 'AttributeName'<~String> - name of attribute
|
10
|
+
# {
|
11
|
+
# "ForumName": {
|
12
|
+
# "S": "Amazon DynamoDB"
|
13
|
+
# }
|
14
|
+
# }
|
16
15
|
# * 'options'<~Hash>:
|
17
16
|
# * 'AttributesToGet'<~Array>: list of array names to return, defaults to returning all
|
18
17
|
# * 'ConsistentRead'<~Boolean>: whether to wait for updates, defaults to false
|
@@ -23,6 +22,9 @@ module Fog
|
|
23
22
|
# * 'ConsumedCapacityUnits'<~Float> - Capacity units used in read
|
24
23
|
# * 'Item':<~Hash>:
|
25
24
|
# * 'AttributeName'<~Hash>: in form of {"type":value}
|
25
|
+
#
|
26
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html
|
27
|
+
#
|
26
28
|
def get_item(table_name, key, options = {})
|
27
29
|
body = {
|
28
30
|
'Key' => key,
|
@@ -31,7 +33,7 @@ module Fog
|
|
31
33
|
|
32
34
|
request(
|
33
35
|
:body => Fog::JSON.encode(body),
|
34
|
-
:headers => {'x-amz-target' => '
|
36
|
+
:headers => {'x-amz-target' => 'DynamoDB_20120810.GetItem'},
|
35
37
|
:idempotent => true
|
36
38
|
)
|
37
39
|
end
|
@@ -14,10 +14,13 @@ module Fog
|
|
14
14
|
# * body<~Hash>:
|
15
15
|
# * 'LastEvaluatedTableName'<~String> - last table name, for pagination
|
16
16
|
# * 'TableNames'<~Array> - table names
|
17
|
+
#
|
18
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html
|
19
|
+
#
|
17
20
|
def list_tables(options = {})
|
18
21
|
request(
|
19
22
|
:body => Fog::JSON.encode(options),
|
20
|
-
:headers => {'x-amz-target' => '
|
23
|
+
:headers => {'x-amz-target' => 'DynamoDB_20120810.ListTables'},
|
21
24
|
:idempotent => true
|
22
25
|
)
|
23
26
|
end
|
@@ -7,21 +7,17 @@ module Fog
|
|
7
7
|
# ==== Parameters
|
8
8
|
# * 'table_name'<~String> - name of table for item
|
9
9
|
# * 'item'<~Hash>: data to update, must include primary key
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# * 'options'<~Hash>:
|
14
|
-
# * 'Expected'<~Hash>: data to check against
|
15
|
-
# * 'AttributeName'<~String> - name of attribute
|
16
|
-
# * 'Value'<~Hash> - a value to check for the value of
|
17
|
-
# or
|
18
|
-
# * 'Exists'<~Boolean> - set as false to only allow update if attribute doesn't exist
|
19
|
-
# * 'ReturnValues'<~String> - data to return in %w{ALL_NEW ALL_OLD NONE UPDATED_NEW UPDATED_OLD}, defaults to NONE
|
10
|
+
# {
|
11
|
+
# "LastPostDateTime": {"S": "201303190422"}
|
12
|
+
# }
|
20
13
|
#
|
21
14
|
# ==== Returns
|
22
15
|
# * response<~Excon::Response>:
|
23
16
|
# * body<~Hash>:
|
24
17
|
# varies based on ReturnValues param, see: http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/API_UpdateItem.html
|
18
|
+
#
|
19
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
|
20
|
+
#
|
25
21
|
def put_item(table_name, item, options = {})
|
26
22
|
body = {
|
27
23
|
'Item' => item,
|
@@ -6,15 +6,13 @@ module Fog
|
|
6
6
|
#
|
7
7
|
# ==== Parameters
|
8
8
|
# * 'table_name'<~String> - name of table to query
|
9
|
-
# * 'hash_key'<~Hash> - hash key to query
|
10
9
|
# * options<~Hash>:
|
11
10
|
# * 'AttributesToGet'<~Array> - Array of attributes to get for each item, defaults to all
|
12
11
|
# * 'ConsistentRead'<~Boolean> - Whether to wait for consistency, defaults to false
|
13
12
|
# * 'Count'<~Boolean> - If true, returns only a count of such items rather than items themselves, defaults to false
|
14
13
|
# * 'Limit'<~Integer> - limit of total items to return
|
15
|
-
# * '
|
16
|
-
#
|
17
|
-
# * 'ComparisonOperator'<~String>: comparison operator to use with attribute value list, in %w{BETWEEN BEGINS_WITH EQ LE LT GE GT}
|
14
|
+
# * 'KeyConditionExpression'<~String> - the condition elements need to match
|
15
|
+
# * 'ExpressionAttributeValues'<~Hash> - values to be used in the key condition expression
|
18
16
|
# * 'ScanIndexForward'<~Boolean>: Whether to scan from start or end of index, defaults to start
|
19
17
|
# * 'ExclusiveStartKey'<~Hash>: Key to start listing from, can be taken from LastEvaluatedKey in response
|
20
18
|
#
|
@@ -25,7 +23,17 @@ module Fog
|
|
25
23
|
# * 'Count'<~Integer> - number of items in response
|
26
24
|
# * 'Items'<~Array> - array of items returned
|
27
25
|
# * 'LastEvaluatedKey'<~Hash> - last key scanned, can be passed to ExclusiveStartKey for pagination
|
28
|
-
|
26
|
+
#
|
27
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html
|
28
|
+
#
|
29
|
+
def query(table_name, options = {}, hash_key_deprecated = nil)
|
30
|
+
if hash_key_deprecated || (options.keys.length == 1 && [:S, :N, :B].include?(options.keys.first.to_sym))
|
31
|
+
Fog::Logger.deprecation("The `20111205` API version is deprecated. You need to use `KeyConditionExpression` instead of `HashKey`.")
|
32
|
+
apiVersion = '20111205'
|
33
|
+
hash_key = options
|
34
|
+
options = hash_key_deprecated
|
35
|
+
end
|
36
|
+
|
29
37
|
body = {
|
30
38
|
'TableName' => table_name,
|
31
39
|
'HashKeyValue' => hash_key
|
@@ -33,7 +41,7 @@ module Fog
|
|
33
41
|
|
34
42
|
request(
|
35
43
|
:body => Fog::JSON.encode(body),
|
36
|
-
:headers => {'x-amz-target' => '
|
44
|
+
:headers => {'x-amz-target' => "DynamoDB_#{apiVersion || '20120810'}.Query"}
|
37
45
|
)
|
38
46
|
end
|
39
47
|
end
|
@@ -11,11 +11,8 @@ module Fog
|
|
11
11
|
# * 'ConsistentRead'<~Boolean> - Whether to wait for consistency, defaults to false
|
12
12
|
# * 'Count'<~Boolean> - If true, returns only a count of such items rather than items themselves, defaults to false
|
13
13
|
# * 'Limit'<~Integer> - limit of total items to return
|
14
|
-
# * '
|
15
|
-
#
|
16
|
-
# * 'AttributeValueList'<~Array>: one or more values to compare against
|
17
|
-
# * 'AttributeValue'<~Hash> - formated as {type => value}
|
18
|
-
# * 'ComparisonOperator'<~String>: comparison operator to use with attribute value list, in %w{BETWEEN BEGINS_WITH EQ LE LT GE GT}
|
14
|
+
# * 'KeyConditionExpression'<~String> - the condition elements need to match
|
15
|
+
# * 'ExpressionAttributeValues'<~Hash> - values to be used in the key condition expression
|
19
16
|
# * 'ScanIndexForward'<~Boolean>: Whether to scan from start or end of index, defaults to start
|
20
17
|
# * 'ExclusiveStartKey'<~Hash>: Key to start listing from, can be taken from LastEvaluatedKey in response
|
21
18
|
#
|
@@ -27,6 +24,9 @@ module Fog
|
|
27
24
|
# * 'Items'<~Array> - array of items returned
|
28
25
|
# * 'LastEvaluatedKey'<~Hash> - last key scanned, can be passed to ExclusiveStartKey for pagination
|
29
26
|
# * 'ScannedCount'<~Integer> - number of items scanned before applying filters
|
27
|
+
#
|
28
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html
|
29
|
+
#
|
30
30
|
def scan(table_name, options = {})
|
31
31
|
body = {
|
32
32
|
'TableName' => table_name
|
@@ -34,7 +34,7 @@ module Fog
|
|
34
34
|
|
35
35
|
request(
|
36
36
|
:body => Fog::JSON.encode(body),
|
37
|
-
:headers => {'x-amz-target' => '
|
37
|
+
:headers => {'x-amz-target' => 'DynamoDB_20120810.Scan'},
|
38
38
|
:idempotent => true
|
39
39
|
)
|
40
40
|
end
|
@@ -2,43 +2,45 @@ module Fog
|
|
2
2
|
module AWS
|
3
3
|
class DynamoDB
|
4
4
|
class Real
|
5
|
+
class DeprecatedAttributeUpdates < Exception; end
|
5
6
|
# Update DynamoDB item
|
6
7
|
#
|
7
8
|
# ==== Parameters
|
8
9
|
# * 'table_name'<~String> - name of table for item
|
9
|
-
# * 'key'<~Hash
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# * 'AttributeType'<~String> - type of attribute
|
16
|
-
# * 'attribute_updates'<~Hash>:
|
17
|
-
# * 'AttributeName'<~String> - Attribute to update
|
18
|
-
# * 'Value'<~Hash> - formated as {type => value}
|
19
|
-
# * 'Action'<~String> - action to take if expects matches, in %w{ADD DELETE PUT}, defaults to PUT
|
10
|
+
# * 'key'<~Hash> - list of elements to be updated and their value
|
11
|
+
# {
|
12
|
+
# "ForumName": {"S": "Amazon DynamoDB"},
|
13
|
+
# "Subject": {"S": "Maximum number of items?"}
|
14
|
+
# }
|
15
|
+
#
|
20
16
|
# * 'options'<~Hash>:
|
21
|
-
# * '
|
22
|
-
#
|
23
|
-
# * 'Value'<~Hash> - a value to check for the value of
|
24
|
-
# or
|
25
|
-
# * 'Exists'<~Boolean> - set as false to only allow update if attribute doesn't exist
|
17
|
+
# * 'KeyConditionExpression'<~String> - the condition elements need to match
|
18
|
+
# * 'ExpressionAttributeValues'<~Hash> - values to be used in the key condition expression
|
26
19
|
# * 'ReturnValues'<~String> - data to return in %w{ALL_NEW ALL_OLD NONE UPDATED_NEW UPDATED_OLD}, defaults to NONE
|
27
20
|
#
|
28
21
|
# ==== Returns
|
29
22
|
# * response<~Excon::Response>:
|
30
23
|
# * body<~Hash>:
|
31
24
|
# varies based on ReturnValues param, see: http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/API_UpdateItem.html
|
32
|
-
|
25
|
+
#
|
26
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html
|
27
|
+
#
|
28
|
+
def update_item(table_name, key, options = {}, deprecated_attribute_updates = nil)
|
29
|
+
if deprecated_attribute_updates
|
30
|
+
raise DeprecatedAttributeUpdates, "The `20111205` DynamoDB API is deprecated. You need to use `ExpressionAttributeValues` instead of `AttributeUpdates`."
|
31
|
+
attribute_updates = options
|
32
|
+
options = deprecated_attribute_updates
|
33
|
+
end
|
34
|
+
|
33
35
|
body = {
|
34
|
-
'AttributeUpdates' => attribute_updates,
|
35
36
|
'Key' => key,
|
36
|
-
'TableName' => table_name
|
37
|
+
'TableName' => table_name,
|
38
|
+
'AttributeUpdates' => attribute_updates,
|
37
39
|
}.merge(options)
|
38
40
|
|
39
41
|
request(
|
40
42
|
:body => Fog::JSON.encode(body),
|
41
|
-
:headers => {'x-amz-target' => '
|
43
|
+
:headers => {'x-amz-target' => 'DynamoDB_20120810.UpdateItem'}
|
42
44
|
)
|
43
45
|
end
|
44
46
|
end
|
@@ -14,18 +14,17 @@ module Fog
|
|
14
14
|
# * response<~Excon::Response>:
|
15
15
|
# * body<~Hash>:
|
16
16
|
# * 'Table'<~Hash>
|
17
|
-
# * 'KeySchema'<~
|
18
|
-
# * 'HashKeyElement'<~Hash>: info for primary key
|
17
|
+
# * 'KeySchema'<~Array> - schema for table
|
19
18
|
# * 'AttributeName'<~String> - name of attribute
|
20
|
-
# * '
|
21
|
-
# * 'RangeKeyElement'<~Hash>: optional, info for range key
|
22
|
-
# * 'AttributeName'<~String> - name of attribute
|
23
|
-
# * 'AttributeType'<~String> - type of attribute, in %w{N NS S SS} for number, number set, string, string set
|
19
|
+
# * 'KeyType'<~String> - type of attribute, in %w{N NS S SS} for number, number set, string, string set
|
24
20
|
# * 'ProvisionedThroughput'<~Hash>:
|
25
21
|
# * 'ReadCapacityUnits'<~Integer> - read capacity for table, in 5..10000
|
26
22
|
# * 'WriteCapacityUnits'<~Integer> - write capacity for table, in 5..10000
|
27
23
|
# * 'TableName'<~String> - name of table
|
28
24
|
# * 'TableStatus'<~String> - status of table
|
25
|
+
#
|
26
|
+
# See DynamoDB Documentation: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTable.html
|
27
|
+
#
|
29
28
|
def update_table(table_name, provisioned_throughput)
|
30
29
|
body = {
|
31
30
|
'ProvisionedThroughput' => provisioned_throughput,
|
@@ -34,7 +33,7 @@ module Fog
|
|
34
33
|
|
35
34
|
request(
|
36
35
|
:body => Fog::JSON.encode(body),
|
37
|
-
:headers => {'x-amz-target' => '
|
36
|
+
:headers => {'x-amz-target' => 'DynamoDB_20120810.UpdateTable'},
|
38
37
|
:idempotent => true
|
39
38
|
)
|
40
39
|
end
|
@@ -72,6 +72,7 @@ module Fog
|
|
72
72
|
'CacheClusterStatus' => 'available',
|
73
73
|
'CacheNodes' => create_cache_nodes(id.strip, options[:num_nodes]),
|
74
74
|
'CacheSecurityGroups' => [],
|
75
|
+
'SecurityGroups' => [],
|
75
76
|
'CacheParameterGroup' => { 'CacheParameterGroupName' =>
|
76
77
|
options[:parameter_group_name] || 'default.memcached1.4' },
|
77
78
|
'CacheSubnetGroupName' => options[:cache_subnet_group_name],
|
@@ -63,7 +63,7 @@ module Fog
|
|
63
63
|
'Arn' => data[:roles][role_name][:arn].strip,
|
64
64
|
'AssumeRolePolicyDocument' => Fog::JSON.encode(data[:roles][role_name][:assume_role_policy_document]),
|
65
65
|
'CreateDate' => data[:roles][role_name][:create_date],
|
66
|
-
'Path' => path,
|
66
|
+
'Path' => path || "/",
|
67
67
|
'RoleId' => data[:roles][role_name][:role_id].strip,
|
68
68
|
'RoleName' => role_name,
|
69
69
|
},
|
@@ -34,9 +34,12 @@ module Fog
|
|
34
34
|
|
35
35
|
class Mock
|
36
36
|
def get_role(role_name)
|
37
|
-
role = self.data[:roles][role_name]
|
38
37
|
|
39
|
-
|
38
|
+
unless self.data[:roles].key?(role_name)
|
39
|
+
raise Fog::AWS::IAM::NotFound.new("The role with name #{role_name} cannot be found")
|
40
|
+
end
|
41
|
+
|
42
|
+
role = self.data[:roles][role_name]
|
40
43
|
|
41
44
|
Excon::Response.new.tap do |response|
|
42
45
|
response.body = {
|
@@ -39,23 +39,57 @@ module Fog
|
|
39
39
|
|
40
40
|
class Mock
|
41
41
|
def list_roles(options={})
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
'IsTruncated' => false,
|
56
|
-
}
|
57
|
-
response.status = 200
|
42
|
+
limit = options['MaxItems']
|
43
|
+
marker = options['Marker']
|
44
|
+
|
45
|
+
if limit
|
46
|
+
if limit > 1_000
|
47
|
+
raise Fog::AWS::IAM::Error.new(
|
48
|
+
"ValidationError => 1 validation error detected: Value '#{limit}' at 'limit' failed to satisfy constraint: Member must have value less than or equal to 1000"
|
49
|
+
)
|
50
|
+
elsif limit < 1
|
51
|
+
raise Fog::AWS::IAM::Error.new(
|
52
|
+
"ValidationError => 1 validation error detected: Value '#{limit}' at 'limit' failed to satisfy constraint: Member must have value greater than or equal to 1"
|
53
|
+
)
|
54
|
+
end
|
58
55
|
end
|
56
|
+
|
57
|
+
data_set = if marker
|
58
|
+
self.data[:markers][marker] || []
|
59
|
+
else
|
60
|
+
data[:roles].map { |role, data|
|
61
|
+
{
|
62
|
+
'Arn' => data[:arn].strip,
|
63
|
+
'AssumeRolePolicyDocument' => Fog::JSON.encode(data[:assume_role_policy_document]),
|
64
|
+
'RoleId' => data[:role_id],
|
65
|
+
'Path' => data[:path],
|
66
|
+
'RoleName' => role,
|
67
|
+
'CreateDate' => data[:create_date],
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
data = data_set.slice!(0, limit || 100)
|
73
|
+
truncated = data_set.size > 0
|
74
|
+
marker = truncated && Base64.encode64("metadata/l/#{account_id}/#{UUID.uuid}")
|
75
|
+
|
76
|
+
response = Excon::Response.new
|
77
|
+
|
78
|
+
body = {
|
79
|
+
'Roles' => data,
|
80
|
+
'IsTruncated' => truncated,
|
81
|
+
'RequestId' => Fog::AWS::Mock.request_id
|
82
|
+
}
|
83
|
+
|
84
|
+
if marker
|
85
|
+
self.data[:markers][marker] = data_set
|
86
|
+
body.merge!('Marker' => marker)
|
87
|
+
end
|
88
|
+
|
89
|
+
response.body = body
|
90
|
+
response.status = 200
|
91
|
+
|
92
|
+
response
|
59
93
|
end
|
60
94
|
end
|
61
95
|
end
|
@@ -37,71 +37,70 @@ module Fog
|
|
37
37
|
end
|
38
38
|
|
39
39
|
request({
|
40
|
-
'Action'
|
40
|
+
'Action' => 'ModifyDBInstance',
|
41
41
|
'DBInstanceIdentifier' => db_name,
|
42
|
-
'ApplyImmediately'
|
43
|
-
:parser
|
42
|
+
'ApplyImmediately' => apply_immediately,
|
43
|
+
:parser => Fog::Parsers::AWS::RDS::ModifyDBInstance.new
|
44
44
|
}.merge(options))
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
class Mock
|
49
49
|
def modify_db_instance(db_name, apply_immediately, _options={})
|
50
|
-
options = _options
|
50
|
+
options = _options.dup
|
51
51
|
response = Excon::Response.new
|
52
|
-
if server = self.data[:servers][db_name]
|
53
|
-
if server["DBInstanceStatus"] != "available"
|
54
|
-
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for modification")
|
55
|
-
else
|
56
|
-
self.data[:modify_time] = Time.now
|
57
|
-
# TODO verify the params options
|
58
|
-
# if apply_immediately is false, all the options go to pending_modified_values and then apply and clear after either
|
59
|
-
# a reboot or the maintainance window
|
60
|
-
#if apply_immediately
|
61
|
-
# modified_server = server.merge(options)
|
62
|
-
#else
|
63
|
-
# modified_server = server["PendingModifiedValues"].merge!(options) # it appends
|
64
|
-
#end
|
65
|
-
|
66
|
-
db_security_group_names = Array(options.delete("DBSecurityGroups"))
|
67
|
-
|
68
|
-
rds_security_groups = self.data[:security_groups].values
|
69
|
-
|
70
|
-
db_security_groups = db_security_group_names.map do |r, group_name|
|
71
|
-
unless rds_security_groups.find { |sg| sg["DBSecurityGroupName"] == group_name }
|
72
|
-
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId= , groupName=#{group_name}")
|
73
|
-
end
|
74
|
-
r << {"Status" => "active", "DBSecurityGroupName" => group_name }
|
75
|
-
end
|
76
|
-
|
77
|
-
ec2_security_groups = Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:security_groups].values
|
78
|
-
|
79
|
-
vpc_security_groups = Array(options.delete("VpcSecurityGroups")).map do |group_id|
|
80
|
-
unless ec2_security_groups.find { |sg| sg["groupId"] == group_id }
|
81
|
-
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId=#{group_id} , groupName=")
|
82
|
-
end
|
83
|
-
|
84
|
-
{"Status" => "active", "VpcSecurityGroupId" => group_id }
|
85
|
-
end
|
86
|
-
|
87
|
-
options.merge!(
|
88
|
-
"DBSecurityGroups" => db_security_groups,
|
89
|
-
"VpcSecurityGroups" => vpc_security_groups
|
90
|
-
)
|
91
|
-
|
92
|
-
self.data[:servers][db_name]["PendingModifiedValues"].merge!(options) # it appends
|
93
|
-
self.data[:servers][db_name]["DBInstanceStatus"] = "modifying"
|
94
|
-
response.status = 200
|
95
|
-
response.body = {
|
96
|
-
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
|
97
|
-
"ModifyDBInstanceResult" => { "DBInstance" => self.data[:servers][db_name] }
|
98
|
-
}
|
99
|
-
response
|
100
52
|
|
101
|
-
|
102
|
-
|
53
|
+
server = self.data[:servers][db_name]
|
54
|
+
|
55
|
+
if server.nil?
|
103
56
|
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not found")
|
104
57
|
end
|
58
|
+
|
59
|
+
if server["DBInstanceStatus"] != "available"
|
60
|
+
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for modification")
|
61
|
+
end
|
62
|
+
|
63
|
+
db_security_group_names = Array(options.delete("DBSecurityGroups"))
|
64
|
+
|
65
|
+
rds_security_groups = self.data[:security_groups].values
|
66
|
+
|
67
|
+
db_security_groups = db_security_group_names.map do |r, group_name|
|
68
|
+
unless rds_security_groups.find { |sg| sg["DBSecurityGroupName"] == group_name }
|
69
|
+
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId= , groupName=#{group_name}")
|
70
|
+
end
|
71
|
+
r << {"Status" => "active", "DBSecurityGroupName" => group_name }
|
72
|
+
end
|
73
|
+
|
74
|
+
ec2_security_groups = Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:security_groups].values
|
75
|
+
|
76
|
+
vpc_security_groups = Array(options.delete("VpcSecurityGroups")).map do |group_id|
|
77
|
+
unless ec2_security_groups.find { |sg| sg["groupId"] == group_id }
|
78
|
+
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId=#{group_id} , groupName=")
|
79
|
+
end
|
80
|
+
|
81
|
+
{"Status" => "active", "VpcSecurityGroupId" => group_id }
|
82
|
+
end
|
83
|
+
|
84
|
+
options.merge!(
|
85
|
+
"DBSecurityGroups" => db_security_groups,
|
86
|
+
"VpcSecurityGroups" => vpc_security_groups
|
87
|
+
)
|
88
|
+
|
89
|
+
if options["NewDBInstanceIdentifier"]
|
90
|
+
options["DBInstanceIdentifier"] = options.delete("NewDBInstanceIdentifier")
|
91
|
+
end
|
92
|
+
|
93
|
+
self.data[:modify_time] = Time.now
|
94
|
+
server["PendingModifiedValues"].merge!(options)
|
95
|
+
server["DBInstanceStatus"] = "modifying"
|
96
|
+
|
97
|
+
response.status = 200
|
98
|
+
response.body = {
|
99
|
+
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
|
100
|
+
"ModifyDBInstanceResult" => { "DBInstance" => server }
|
101
|
+
}
|
102
|
+
|
103
|
+
response
|
105
104
|
end
|
106
105
|
end
|
107
106
|
end
|