Sha256: fa3105daeae0191665b88fdc7ee25b6fa9a6280abc51f416bbcad46de99ea317

Contents?: true

Size: 1.53 KB

Versions: 44

Compression:

Stored size: 1.53 KB

Contents

require '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'
        attribute :type_name
        attribute :policy_attributes

        attr_accessor :cookie_stickiness # Either :app or :lb

        def save
          requires :id, :load_balancer
          service_method = nil
          args = [load_balancer.id, id]

          if cookie_stickiness
            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
          else
            requires :type_name, :policy_attributes
            method = :create_load_balancer_policy
            args << type_name
            args << policy_attributes
          end

          service.send(method, *args)
          reload
        end

        def destroy
          requires :id, :load_balancer
          service.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

44 entries across 44 versions & 3 rubygems

Version Path
fog-maestrodev-1.18.0.20131209090811 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131126122111 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131125111730 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/aws/models/elb/policy.rb
fog-1.18.0 lib/fog/aws/models/elb/policy.rb
fog-1.17.0 lib/fog/aws/models/elb/policy.rb
fog-1.16.0 lib/fog/aws/models/elb/policy.rb
fog-maestrodev-1.15.0.20130927082724 lib/fog/aws/models/elb/policy.rb