Sha256: a269f179e268527556fd8de3ce7253b7a714bbb8b87033d23cde8cd0c0e0e71a

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Aws
  module EC2

    # 5 of EC2's old APIs DescribeInstances, DescribeImages, DescribeSnapshots, DescribeVolumes and DescribeTag
    # support paginated calls and will not paginate server side unless max_results is set to a non-nil value.
    # This module customizes the resource association methods by adding a default value of 1000 to max_results
    # to ensure results are paginated.
    module ResourcePaginationFix
      def images(options = {})
        options[:max_results] ||= 1000
        super(options)
      end

      def instances(options = {})
        options[:max_results] ||= 1000
        super(options)
      end

      def snapshots(options = {})
        options[:max_results] ||= 1000
        super(options)
      end

      def volumes(options = {})
        options[:max_results] ||= 1000
        super(options)
      end
    end

    class Resource
      prepend ResourcePaginationFix
      def create_tags(options)
        resp = Aws::Plugins::UserAgent.feature('resource') do
          @client.create_tags(options)
        end
        tags = []
        options[:resources].each do |resource_id|
          options[:tags].each do |tag|
            tags << Tag.new(resource_id, tag[:key], tag[:value], client: @client)
          end
        end
        Tag::Collection.new([tags], size: tags.size)
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
aws-sdk-ec2-1.455.0 lib/aws-sdk-ec2/customizations/resource.rb
aws-sdk-ec2-1.454.0 lib/aws-sdk-ec2/customizations/resource.rb
aws-sdk-ec2-1.453.0 lib/aws-sdk-ec2/customizations/resource.rb
aws-sdk-ec2-1.452.0 lib/aws-sdk-ec2/customizations/resource.rb
aws-sdk-ec2-1.451.0 lib/aws-sdk-ec2/customizations/resource.rb
aws-sdk-ec2-1.450.0 lib/aws-sdk-ec2/customizations/resource.rb
aws-sdk-ec2-1.449.0 lib/aws-sdk-ec2/customizations/resource.rb
aws-sdk-ec2-1.448.1 lib/aws-sdk-ec2/customizations/resource.rb