Sha256: 2eaa4195f8cb9253998594416983ac7e26d028d0adc2e2499635d6fd00eb628f

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'rackspace-fog/core/model'
module Fog
  module AWS
    class ELB

      class Policy < Fog::Model
        identity :id, :aliases => 'PolicyName'

        attribute :cookie,     :aliases => 'CookieName'
        attribute :expiration, :aliases => 'CookieExpirationPeriod'

        attr_accessor :cookie_stickiness # Either :app or :lb

        def save
          requires :id, :load_balancer, :cookie_stickiness
          connection_method = nil
          args = [load_balancer.id, id]
          case cookie_stickiness
          when :app
            requires :cookie
            method = :create_app_cookie_stickiness_policy
            args << cookie
          when :lb
            method = :create_lb_cookie_stickiness_policy
            args << expiration if expiration
          else
            raise ArgumentError.new('cookie_stickiness must be :app or :lb')
          end

          connection.send(method, *args)
          reload
        end

        def destroy
          requires :id, :load_balancer
          connection.delete_load_balancer_policy(load_balancer.id, id)
          reload
        end

        def reload
          load_balancer.reload
        end

        def load_balancer
          collection.load_balancer
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rackspace-fog-1.4.2 lib/rackspace-fog/aws/models/elb/policy.rb