File: listener_collection.rb

package info (click to toggle)
ruby-aws-sdk 1.67.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,840 kB
  • sloc: ruby: 28,436; makefile: 7
file content (113 lines) | stat: -rw-r--r-- 3,778 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

module AWS
  class ELB

    class ListenerCollection

      include ListenerOpts
      include Core::Collection::Simple

      def initialize load_balancer, options = {}
        @load_balancer = load_balancer
        super
      end

      # @return [LoadBalancer]
      attr_reader :load_balancer

      # @param [Hash] options
      #
      # @option options [Integer] :port Specifies the external
      #   load balancer port number. This property cannot be modified for
      #   the life of the LoadBalancer.
      #
      # @option options [String,Symbol] :protocol Specifies the load balancer
      #   transport protocol to use for routing.  Valid values include:
      #
      # @option options [Integer] :instance_port Specifies the TCP port on
      #   which the instance server is listening. This property cannot be
      #   modified for the life of the load balancer.
      #
      # @option options [String,Symbol] :instance_protocol Specifies the
      #   protocol to use for routing traffic to back-end instances.  Valid
      #   values include:
      #
      #   * :http, 'HTTP'
      #   * :https, 'HTTPS'
      #   * :tcp, 'TCP'
      #   * :ssl, 'SSL'
      #
      #   This property cannot be modified for the life of the load balacner.
      #
      #   NOTE: If the front-end protocol is HTTP or HTTPS, `:instance_protocol`
      #   has to be at the same protocol layer, i.e., HTTP or HTTPS. Likewise,
      #   if the front-end protocol is TCP or SSL, `:instance_protocol` has
      #   to be TCP or SSL.
      #
      #   NOTE: If there is another listener with the same `:instance_port`
      #   whose `:instance_protocol` is secure, i.e., HTTPS or SSL, the
      #   listener's `:instance_protocol` has to be secure, i.e., HTTPS
      #   or SSL. If there is another listener with the same `:instance_port`
      #   whose `:instance_protocol` is HTTP or TCP, the listener's
      #   `:instance_protocol` must be either HTTP or TCP.
      #
      #   * :tcp, 'TCP'
      #   * :http, 'HTTP'
      #
      #   This property cannot be modified for the life of the load balancer.
      #
      # @option options [String,IAM::ServerCertificate] :server_certificate The
      #   ARN string of an IAM::ServerCertifcate or an IAM::ServerCertificate
      #   object.  Reqruied for HTTPs listeners.
      #
      # @return [Listener]
      def create options = {}

        format_listener_opts(options)

        client.create_load_balancer_listeners(
          :load_balancer_name => load_balancer.name,
          :listeners => [options])

        Listener.new(load_balancer,
          options[:load_balancer_port],
          options.merge(:config => config))

      end

      # @return [Listener]
      def [] port
        Listener.new(load_balancer, port, :config => config)
      end

      protected
      def _each_item options = {}
        load_balancer.listener_descriptions.each do |description|

          port = description[:listener][:load_balancer_port]

          options = {}
          options[:config] = config
          options.merge!(description[:listener])

          yield(Listener.new(load_balancer, port, options))

        end
      end

    end

  end
end