Sha256: 3391d439cc894420bdccf5b5822681621e8b7f753ea14680ca7cd1ceaf562ef1

Contents?: true

Size: 1.54 KB

Versions: 39

Compression:

Stored size: 1.54 KB

Contents

# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.

module AWS
  class EC2

    # @api private
    class ConfigTransform

      class << self

        def transform(api_config)
          ["RunInstances",
           "DetachVolume",
           "AttachVolume",
           "CreateSnapshot",
           "CreateVolume",
           "DescribeImageAttribute",
           "DescribeInstanceAttribute"].each do |(op, wrapper)|
            if op_config = api_config[:operations][op]
              op_config[:output] = op_config[:output].first.values.first
            end
          end

          api_config[:operations].each do |op, op_config|
            op_config[:input] =
              capitalize_input_structure(op_config[:input])
          end

          api_config
        end

        private
        def capitalize_input_structure(struct)
          struct.inject({}) do |m, (name, desc)|

            name = name[0,1].upcase + name[1..-1]
            m[name] = capitalize_input_descriptors(desc)
            m
          end
        end

        private
        def capitalize_input_descriptors(desc)
          desc.map do |d|
            case
            when d.kind_of?(Hash) && d.key?(:structure)
              d.merge(:structure =>
                      capitalize_input_structure(d[:structure]))
            when d.kind_of?(Hash) && d.key?(:list)
              d.merge(:list =>
                      capitalize_input_descriptors(d[:list]))
            else
              d
            end
          end
        end

      end

    end

  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
aws-sdk-1.31.3 lib/aws/ec2/config_transform.rb
aws-sdk-1.31.2 lib/aws/ec2/config_transform.rb
aws-sdk-1.31.1 lib/aws/ec2/config_transform.rb
aws-sdk-1.31.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.30.1 lib/aws/ec2/config_transform.rb
aws-sdk-1.30.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.29.1 lib/aws/ec2/config_transform.rb
aws-sdk-1.29.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.28.1 lib/aws/ec2/config_transform.rb
aws-sdk-1.28.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.27.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.26.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.25.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.24.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.23.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.22.1 lib/aws/ec2/config_transform.rb
aws-sdk-1.22.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.21.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.20.0 lib/aws/ec2/config_transform.rb
aws-sdk-1.19.0 lib/aws/ec2/config_transform.rb