Sha256: 719c78ca9ac6ebfdb07566583e12dd017327522b02344f2fdf5e0ac792563410

Contents?: true

Size: 1.54 KB

Versions: 30

Compression:

Stored size: 1.54 KB

Contents

module Fog
  module AWS
    class ELBV2
      class Real
        require 'fog/aws/parsers/elbv2/empty'

        # adds tags to a load balancer instance
        # http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/API_AddTags.html
        # ==== Parameters
        # * resource_arn <~String> - The Amazon Resource Name (ARN) of the resource
        # * tags <~Hash> A Hash of (String) key-value pairs
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        def add_tags(resource_arn, tags)
          keys    = tags.keys.sort
          values  = keys.map {|key| tags[key]}
          request({
              'Action'                     => 'AddTags',
              'ResourceArns.member.1'      => resource_arn,
              :parser                      => Fog::Parsers::AWS::ELBV2::Empty.new,
            }.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys))
             .merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values)))
        end

      end

      class Mock
        def add_tags(resource_arn, tags)
          response = Excon::Response.new
          if self.data[:load_balancers_v2][resource_arn]
            self.data[:tags][resource_arn].merge! tags
            response.status = 200
            response.body = {
              "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id }
            }
            response
          else
            raise Fog::AWS::ELBV2::NotFound.new("Elastic load balancer #{resource_arn} not found")
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
fog-aws-3.29.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.28.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.27.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.26.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.25.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.24.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.23.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.22.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.21.1 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.21.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.20.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.19.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.18.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.17.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.16.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.15.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.14.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.13.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.12.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.11.0 lib/fog/aws/requests/elbv2/add_tags.rb