Class: AwsRo::ElasticLoadBalancingV2::TargetGroup
- Inherits:
-
Object
- Object
- AwsRo::ElasticLoadBalancingV2::TargetGroup
- Extended by:
- Forwardable
- Defined in:
- lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#target_group_arn ⇒ Object
(also: #arn)
readonly
Returns the value of attribute target_group_arn.
Instance Method Summary collapse
- #ec2_instances(ec2_repository = nil) ⇒ Object
- #health(instance_id = nil) ⇒ Object
-
#initialize(arn, client) ⇒ TargetGroup
constructor
A new instance of TargetGroup.
- #instances(ec2_repository = nil) ⇒ Object
- #target_group ⇒ Object
- #target_type ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(arn, client) ⇒ TargetGroup
Returns a new instance of TargetGroup.
79 80 81 82 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 79 def initialize(arn, client) @target_group_arn = arn @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
74 75 76 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 74 def client @client end |
#target_group_arn ⇒ Object (readonly) Also known as: arn
Returns the value of attribute target_group_arn.
74 75 76 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 74 def target_group_arn @target_group_arn end |
Instance Method Details
#ec2_instances(ec2_repository = nil) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 110 def ec2_instances(ec2_repository = nil) ec2_repository ||= AwsRo::EC2::Repository.new( region: client.config.region, credentials: client.config.credentials ) case type when 'instance' then ec2_repository.instance_ids(health_descriptions.keys) when 'ip' then ec2_repository.filters([{ name: 'network-interface.addresses.private-ip-address', values: health_descriptions.keys }]) end end |
#health(instance_id = nil) ⇒ Object
84 85 86 87 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 84 def health(instance_id = nil) return health_descriptions[instance_id] if instance_id health_descriptions.values end |
#instances(ec2_repository = nil) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 97 def instances(ec2_repository = nil) return [] if health_descriptions.empty? case type when 'instance','ip' ec2_instances(ec2_repository) when 'lambda' health_descriptions.values.map(&:target) else raise "Unsupported target-type: #{type}" end end |
#target_group ⇒ Object
89 90 91 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 89 def target_group @target_group ||= client.describe_target_groups(target_group_arns: [arn]).target_groups.first end |
#target_type ⇒ Object
93 94 95 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 93 def target_type @target_type ||= target_group.target_type end |
#type ⇒ Object
77 |
# File 'lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb', line 77 alias type target_type |