| 1 | package VM::EC2::ELB::Listener; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::ELB:Listener - Elastic Load Balancer Listener | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use VM::EC2; | ||
| 10 | |||
| 11 | my $ec2 = VM::EC2->new(...); | ||
| 12 | my $lb = $ec2->describe_load_balancers('my-lb'); | ||
| 13 | my @http_listeners = map { grep { $_->LoadBalancerPort eq '80' } $_->Listener } $lb->ListenerDescriptions; | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | This object is used to describe a listener attached to an Elastic Load | ||
| 18 | Balancer. | ||
| 19 | |||
| 20 | =head1 METHODS | ||
| 21 | |||
| 22 | The following object methods are supported: | ||
| 23 | |||
| 24 | Protocol -- The protocol of the load balancer listener | ||
| 25 | LoadBalancerPort -- The port the listener is listening on | ||
| 26 | InstanceProtocol -- The protocol the load balancer uses to communicate | ||
| 27 | with the instance | ||
| 28 | InstancePort -- The port on the instance the load balancer connects to | ||
| 29 | SSLCertificateId -- The ARN string of the server certificate | ||
| 30 | |||
| 31 | =head1 STRING OVERLOADING | ||
| 32 | |||
| 33 | When used in a string context, this object will return a string containing | ||
| 34 | all the parameters of the listener in a pretty format. | ||
| 35 | |||
| 36 | |||
| 37 | =head1 SEE ALSO | ||
| 38 | |||
| 39 | L<VM::EC2> | ||
| 40 | L<VM::EC2::Generic> | ||
| 41 | L<VM::EC2::ELB> | ||
| 42 | L<VM::EC2::ELB::ListenerDescription> | ||
| 43 | |||
| 44 | =head1 AUTHOR | ||
| 45 | |||
| 46 | Lance Kinley E<lt>lkinley@loyaltymethods.comE<gt>. | ||
| 47 | |||
| 48 | Copyright (c) 2012 Loyalty Methods, Inc. | ||
| 49 | |||
| 50 | This package and its accompanying libraries is free software; you can | ||
| 51 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 52 | version 1, or at your option, any later version) or the Artistic | ||
| 53 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 54 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | use strict; | ||
| 59 | use base 'VM::EC2::Generic'; | ||
| 60 | |||
| 61 | sub valid_fields { | ||
| 62 | my $self = shift; | ||
| 63 | return qw(InstancePort InstanceProtocol LoadBalancerPort Protocol SSLCertificateId); | ||
| 64 | } | ||
| 65 | |||
| 66 | use overload | ||
| 67 | '""' => sub { | ||
| 68 | my $self = shift; | ||
| 69 | my $string = $self->Protocol . ':' . $self->LoadBalancerPort . ' --> ' . $self->InstanceProtocol . ':' . $self->InstancePort; | ||
| 70 | my $ssl_id = $self->SSLCertificateId; | ||
| 71 | $string .= ':' . $ssl_id if (defined $ssl_id); | ||
| 72 | return $string}, | ||
| 73 | fallback => 1; | ||
| 74 | |||
| 75 | sub InstanceProtocol { | ||
| 76 | my $self = shift; | ||
| 77 | my $instance_protocol = $self->SUPER::InstanceProtocol; | ||
| 78 | return defined $instance_protocol ? $instance_protocol : $self->Protocol; | ||
| 79 | } | ||
| 80 | |||
| 81 | 1; |