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.10.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.9.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.8.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.7.0 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.6.7 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.6.6 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.6.5 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.6.4 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.6.3 lib/fog/aws/requests/elbv2/add_tags.rb
fog-aws-3.6.2 lib/fog/aws/requests/elbv2/add_tags.rb