1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Add MaxResults filter to describe security groups

This commit is contained in:
KevinLoiseau 2019-01-29 15:30:21 +01:00
parent d3c6cec347
commit 0d73e2c603
No known key found for this signature in database
GPG key ID: 1980A300C3CF754A
2 changed files with 13 additions and 2 deletions

View file

@ -97,7 +97,7 @@ module Fog
@response['securityGroupInfo'] << @security_group
@security_group = { 'ipPermissions' => [], 'ipPermissionsEgress' => [], 'tagSet' => {} }
end
when 'requestId'
when 'requestId', 'nextToken'
@response[name] = value
when 'userId'
@group[name] = value

View file

@ -8,6 +8,8 @@ module Fog
#
# ==== Parameters
# * filters<~Hash> - List of filters to limit results with
# * 'MaxResults'<~Integer> - The maximum number of results to return for the request in a single page
# * 'NextToken'<~String> - The token to retrieve the next page of results
#
# === Returns
# * response<~Excon::Response>:
@ -27,6 +29,7 @@ module Fog
# * 'cidrIp'<~String> - CIDR range
# * 'toPort'<~Integer> - End of port range (or -1 for ICMP wildcard)
# * 'ownerId'<~String> - AWS Access Key Id of the owner of the security group
# * 'NextToken'<~String> - The token to retrieve the next page of results
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSecurityGroups.html]
def describe_security_groups(filters = {})
@ -34,7 +37,15 @@ module Fog
Fog::Logger.deprecation("describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead [light_black](#{caller.first})[/]")
filters = {'group-name' => [*filters]}
end
params = Fog::AWS.indexed_filters(filters)
options = {}
for key in %w[MaxResults NextToken]
if filters.is_a?(Hash) && filters.key?(key)
options[key] = filters.delete(key)
end
end
params = Fog::AWS.indexed_filters(filters).merge!(options)
request({
'Action' => 'DescribeSecurityGroups',
:idempotent => true,