mirror of
				https://github.com/fog/fog-aws.git
				synced 2022-11-09 13:50:52 -05:00 
			
		
		
		
	Implement ELBV2 add_tags endpoint
This commit is contained in:
		
							parent
							
								
									beb3199492
								
							
						
					
					
						commit
						e220c91298
					
				
					 3 changed files with 56 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,7 @@ module Fog
 | 
			
		|||
      recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :version, :instrumentor, :instrumentor_name
 | 
			
		||||
 | 
			
		||||
      request_path 'fog/aws/requests/elbv2'
 | 
			
		||||
      request :add_tags
 | 
			
		||||
      request :create_load_balancer
 | 
			
		||||
      request :describe_load_balancers
 | 
			
		||||
      request :describe_listeners
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								lib/fog/aws/parsers/elbv2/empty.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lib/fog/aws/parsers/elbv2/empty.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
module Fog
 | 
			
		||||
  module Parsers
 | 
			
		||||
    module AWS
 | 
			
		||||
      module ELBV2
 | 
			
		||||
        class Empty < ELB::Empty
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										45
									
								
								lib/fog/aws/requests/elbv2/add_tags.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								lib/fog/aws/requests/elbv2/add_tags.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
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
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue