diff --git a/lib/fog/aws/elb.rb b/lib/fog/aws/elb.rb index 87e6d7e9e..98c3884c0 100644 --- a/lib/fog/aws/elb.rb +++ b/lib/fog/aws/elb.rb @@ -7,8 +7,8 @@ module Fog request_path 'fog/aws/requests/elb' request :configure_health_check - #request :create_app_cookie_stickiness_policy - #request :create_db_cookie_stickiness_policy + request :create_app_cookie_stickiness_policy + request :create_lb_cookie_stickiness_policy request :create_load_balancer request :create_load_balancer_listeners request :delete_load_balancer diff --git a/lib/fog/aws/requests/elb/create_app_cookie_stickiness_policy.rb b/lib/fog/aws/requests/elb/create_app_cookie_stickiness_policy.rb new file mode 100644 index 000000000..356680a35 --- /dev/null +++ b/lib/fog/aws/requests/elb/create_app_cookie_stickiness_policy.rb @@ -0,0 +1,33 @@ +module Fog + module AWS + class ELB + class Real + + require 'fog/aws/parsers/elb/empty' + + # Create an app cookie stickiness policy + # + # ==== Parameters + # * lb_name<~String> - Name of the ELB + # * policy_name<~String> - The name of the policy being created. + # The name must be unique within the set of policies for this Load Balancer. + # * cookie_name<~String> - Name of the application cookie used for stickiness. + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'ResponseMetadata'<~Hash>: + # * 'RequestId'<~String> - Id of request + def create_app_cookie_stickiness_policy(lb_name, policy_name, cookie_name) + params = {'CookieName' => cookie_name, 'PolicyName' => policy_name} + + request({ + 'Action' => 'CreateAppCookieStickinessPolicy', + 'LoadBalancerName' => lb_name, + :parser => Fog::Parsers::AWS::ELB::Empty.new + }.merge!(params)) + end + + end + end + end +end diff --git a/lib/fog/aws/requests/elb/create_lb_cookie_stickiness_policy.rb b/lib/fog/aws/requests/elb/create_lb_cookie_stickiness_policy.rb new file mode 100644 index 000000000..d373ffbef --- /dev/null +++ b/lib/fog/aws/requests/elb/create_lb_cookie_stickiness_policy.rb @@ -0,0 +1,35 @@ +module Fog + module AWS + class ELB + class Real + + require 'fog/aws/parsers/elb/empty' + + # Create a Load Balancer Cookie Stickiness Policy + # + # ==== Parameters + # * lb_name<~String> - Name of the ELB + # * policy_name<~String> - The name of the policy being created. The name + # must be unique within the set of policies for this Load Balancer. + # * cookie_expiration_period<~Integer> - The time period in seconds after + # which the cookie should be considered stale. Not specifying this + # parameter indicates that the sticky session will last for the duration of the browser session. + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'ResponseMetadata'<~Hash>: + # * 'RequestId'<~String> - Id of request + def create_lb_cookie_stickiness_policy(lb_name, policy_name, cookie_expiration_period=nil) + params = {'PolicyName' => policy_name, 'CookieExpirationPeriod' => cookie_expiration_period} + + request({ + 'Action' => 'CreateLBCookieStickinessPolicy', + 'LoadBalancerName' => lb_name, + :parser => Fog::Parsers::AWS::ELB::Empty.new + }.merge!(params)) + end + + end + end + end +end diff --git a/tests/aws/requests/elb/load_balancer_tests.rb b/tests/aws/requests/elb/load_balancer_tests.rb index 378af7c8f..bac853b2d 100644 --- a/tests/aws/requests/elb/load_balancer_tests.rb +++ b/tests/aws/requests/elb/load_balancer_tests.rb @@ -26,6 +26,22 @@ Shindo.tests('AWS::ELB | load_balancer_tests', ['aws', 'elb']) do AWS[:elb].configure_health_check(@load_balancer_id, health_check).body end + tests("#create_app_cookie_stickiness_policy").formats(AWS::ELB::Formats::BASIC) do + cookie, policy = 'fog-app-cookie', 'fog-app-policy' + AWS[:elb].create_app_cookie_stickiness_policy(@load_balancer_id, policy, cookie).body + end + + tests("#create_lb_cookie_stickiness_policy with expiry").formats(AWS::ELB::Formats::BASIC) do + policy = 'fog-lb-expiry' + expiry = 300 + AWS[:elb].create_lb_cookie_stickiness_policy(@load_balancer_id, policy, expiry).body + end + + tests("#create_lb_cookie_stickiness_policy without expiry").formats(AWS::ELB::Formats::BASIC) do + policy = 'fog-lb-no-expiry' + AWS[:elb].create_lb_cookie_stickiness_policy(@load_balancer_id, policy).body + end + tests("#create_load_balancer_listeners").formats(AWS::ELB::Formats::BASIC) do listeners = [ {'Protocol' => 'tcp', 'LoadBalancerPort' => 443, 'InstancePort' => 443}, @@ -39,7 +55,6 @@ Shindo.tests('AWS::ELB | load_balancer_tests', ['aws', 'elb']) do AWS[:elb].delete_load_balancer_listeners(@load_balancer_id, ports).body end - tests("#delete_load_balancer").formats(AWS::ELB::Formats::DELETE_LOAD_BALANCER) do AWS[:elb].delete_load_balancer(@load_balancer_id).body end