Sha256: c9d0a0c07ae1c853aa381a74c89d03ec5937652cb2e3e063b956061a3f204d0e

Contents?: true

Size: 1.53 KB

Versions: 17

Compression:

Stored size: 1.53 KB

Contents

require 'fog/core/model'
module Fog
  module AWS
    class ELB
      class Listener < Fog::Model

        attribute :policy_names,  :aliases => 'PolicyNames'
        attribute :instance_port, :aliases => 'InstancePort'
        attribute :lb_port,       :aliases => 'LoadBalancerPort'
        attribute :protocol,      :aliases => 'Protocol'
        attribute :ssl_id,        :aliases => 'SSLCertificateId'

        def initialize(attributes={})
          # set defaults, which may be overridden in super
          merge_attributes(:policy_names => [], :instance_port => 80, :lb_port => 80, :protocol => 'HTTP')
          super
        end

        def save
          requires :load_balancer, :instance_port, :lb_port, :protocol
          connection.create_load_balancer_listeners(load_balancer.id, [to_params])
          reload
        end

        def destroy
          requires :load_balancer, :lb_port
          connection.delete_load_balancer_listeners(load_balancer.id, [lb_port])
          reload
        end

        # Return the policy associated with this load balancer
        def policy
          load_balancer.policies.get(policy_names.first)
        end

        def reload
          load_balancer.reload
        end

        def load_balancer
          collection.load_balancer
        end

        def to_params
          {
            'InstancePort'     => instance_port,
            'LoadBalancerPort' => lb_port,
            'Protocol'         => protocol,
            'SSLCertificateId' => ssl_id
          }
        end

      end

    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
fog-1.1.2 lib/fog/aws/models/elb/listener.rb
fog_tractical-1.1.4 lib/fog/aws/models/elb/listener.rb
fog_tractical-1.1.3 lib/fog/aws/models/elb/listener.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
fog-1.1.1 lib/fog/aws/models/elb/listener.rb
fog-1.1.0 lib/fog/aws/models/elb/listener.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
tag-fog-1.0.1 lib/fog/aws/models/elb/listener.rb
brightbox-cli-0.14.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
brightbox-cli-0.14.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
fog-1.0.0 lib/fog/aws/models/elb/listener.rb
brightbox-cli-0.13.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
brightbox-cli-0.13.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/elb/listener.rb
fog-0.11.0 lib/fog/aws/models/elb/listener.rb
fog-0.10.0 lib/fog/aws/models/elb/listener.rb