aws_ro 1.1.4 → 1.2.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68c2dde788db572723bc6847d444d1e8d979dc97
4
- data.tar.gz: 469637de553ceefd61115661070f9086eb68cf86
3
+ metadata.gz: aa3b1ec18bd57ce846212b61409453b3292c06ff
4
+ data.tar.gz: fae83af841cc8f4412a52e021cf7d2500cc29b63
5
5
  SHA512:
6
- metadata.gz: 4bbda904addebf1ea8e70ba0f58a02aa1acf195ecbbd16a16ca9e0da3440de68872283185f3e55d99f480b76c0de603d8ad1b8aadb7fdf885db21066af3e5b4c
7
- data.tar.gz: 8a32263755f874faa3d6f09d6a9daeac8839f418ea8823a329da99be3285c58699869e2c76544c84ac007eb5ecdff2285a247aa2c75998f621b6e05719baae48
6
+ metadata.gz: 3b18dbbd3015e468ecc9776dd3ccfeadeff90ce8f95ebc67fe89b654ab3aefa5553c269ddb95ab5121446971cbb889c538a4a5cd46373460f389f848e10c7fc1
7
+ data.tar.gz: 81a35b657138cb0b77cc2aeef36fa809e42d93f420f781532bf2c6cf77c2a7e86dc986068127a1d509c4a63d660c31036ab81f5c9a8d4fdaf16e6f9496009757
data/aws_ro.gemspec CHANGED
@@ -31,7 +31,7 @@ Wrpper library of AWS SDK objects to enable to access properties
31
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ["lib"]
33
33
 
34
- spec.add_dependency "aws-sdk", "~> 2.0"
34
+ spec.add_dependency "aws-sdk", "~> 2.5.3"
35
35
  spec.add_development_dependency "bundler", "~> 1.9"
36
36
  spec.add_development_dependency "rake", "~> 10.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -0,0 +1,99 @@
1
+ module AwsRo
2
+ module ElasticLoadBalancingV2
3
+ class LoadBalancer
4
+ extend Forwardable
5
+ def_delegators :@load_balancer, :load_balancer_name, :load_balancer_arn, :vpc_id
6
+ attr_reader :client, :load_balancer
7
+ alias alb load_balancer
8
+ alias name load_balancer_name
9
+ alias arn load_balancer_arn
10
+
11
+ def initialize(load_balancer, client)
12
+ @load_balancer = load_balancer
13
+ @client = client
14
+ end
15
+
16
+ def listeners
17
+ @listeners ||= client.describe_listeners(load_balancer_arn: arn).listeners.map do |listener|
18
+ Listener.new(listener, client)
19
+ end
20
+ end
21
+ end
22
+
23
+ class Listener
24
+ extend Forwardable
25
+ def_delegators :@listener, :listener_arn, :port, :protocol
26
+ attr_reader :client, :listener
27
+ alias arn listener_arn
28
+
29
+ def initialize(listener, client)
30
+ @listener = listener
31
+ @client = client
32
+ end
33
+
34
+ def rules
35
+ @rules ||= client.describe_rules(listener_arn: arn).rules.map do |rule|
36
+ Rule.new(rule, client)
37
+ end
38
+ end
39
+ end
40
+
41
+ class Rule
42
+ extend Forwardable
43
+ def_delegators :@rule, :rule_arn, :priority, :is_default
44
+ attr_reader :client, :rule
45
+ alias arn rule_arn
46
+ alias default? is_default
47
+
48
+ def initialize(rule, client)
49
+ @rule = rule
50
+ @client = client
51
+ end
52
+
53
+ def forward_target_group
54
+ action = rule.actions.find { |act| act.type == 'forward' }
55
+ TargetGroup.new(action.target_group_arn, client) if action
56
+ end
57
+
58
+ def path_pattern
59
+ condition = rule.conditions.find { |cond| cond.field == 'path-pattern' }
60
+ condition.values.first if condition
61
+ end
62
+ end
63
+
64
+ class TargetGroup
65
+ attr_reader :client, :target_group_arn
66
+ alias arn target_group_arn
67
+
68
+ def initialize(arn, client)
69
+ @target_group_arn = arn
70
+ @client = client
71
+ end
72
+
73
+ def health(instance_id = nil)
74
+ return health_descriptions[instance_id] if instance_id
75
+ health_descriptions.values
76
+ end
77
+
78
+ def target_group
79
+ @target_group ||= client.describe_target_groups(target_group_arns: [arn]).target_groups.first
80
+ end
81
+
82
+ def instances(ec2_repository = nil)
83
+ ec2_repository ||= AwsRo::EC2::Repository.new(
84
+ region: client.config.region,
85
+ credentials: client.config.credentials
86
+ )
87
+ ec2_repository.instance_ids(health_descriptions.keys)
88
+ end
89
+
90
+ private
91
+
92
+ def health_descriptions
93
+ @health_descriptions ||= client.describe_target_health(target_group_arn: arn).target_health_descriptions.each_with_object({}) do |desc, h|
94
+ h[desc.target.id] = desc
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,39 @@
1
+ require 'aws-sdk'
2
+ require 'aws_ro/elastic_load_balancing_v2/load_balancer'
3
+ require 'aws_ro/ec2/repository'
4
+ require 'pry'
5
+ module AwsRo
6
+ module ElasticLoadBalancingV2
7
+ class Repository
8
+ attr_reader :client
9
+
10
+ def initialize(client_or_options)
11
+ @client = if client_or_options.is_a? Aws::ElasticLoadBalancingV2::Client
12
+ client_or_options
13
+ else
14
+ Aws::ElasticLoadBalancingV2::Client.new(client_or_options)
15
+ end
16
+ end
17
+
18
+ def ec2_repository
19
+ @ec2_repository ||= AwsRo::EC2::Repository.new(
20
+ region: client.config.region,
21
+ credentials: client.config.credentials
22
+ )
23
+ end
24
+
25
+ def all
26
+ client.describe_load_balancers.each_with_object([]) do |page, arr|
27
+ page.load_balancers.each do |alb|
28
+ arr << LoadBalancer.new(alb, client)
29
+ end
30
+ end
31
+ end
32
+
33
+ def find_by_name(name)
34
+ alb = client.describe_load_balancers(names: [name]).load_balancers.first
35
+ LoadBalancer.new(alb, client) if alb
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ require 'aws_ro/elastic_load_balancing_v2/load_balancer'
2
+ require 'aws_ro/elastic_load_balancing_v2/repository'
3
+
4
+ module AwsRo
5
+ module ElasticLoadBalancingV2
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module AwsRo
2
- VERSION = "1.1.4"
2
+ VERSION = "1.2.0.beta"
3
3
  end
data/lib/aws_ro.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'aws_ro/ec2'
2
2
  require 'aws_ro/elastic_load_balancing'
3
+ require 'aws_ro/elastic_load_balancing_v2'
3
4
 
4
5
  module AwsRo
5
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_ro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - takuto.komazaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-02 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: 2.5.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: 2.5.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +136,9 @@ files:
136
136
  - lib/aws_ro/elastic_load_balancing.rb
137
137
  - lib/aws_ro/elastic_load_balancing/load_balancer.rb
138
138
  - lib/aws_ro/elastic_load_balancing/repository.rb
139
+ - lib/aws_ro/elastic_load_balancing_v2.rb
140
+ - lib/aws_ro/elastic_load_balancing_v2/load_balancer.rb
141
+ - lib/aws_ro/elastic_load_balancing_v2/repository.rb
139
142
  - lib/aws_ro/version.rb
140
143
  homepage: https://github.com/gree/aws_ro
141
144
  licenses: []
@@ -151,9 +154,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
154
  version: 1.9.3
152
155
  required_rubygems_version: !ruby/object:Gem::Requirement
153
156
  requirements:
154
- - - ">="
157
+ - - ">"
155
158
  - !ruby/object:Gem::Version
156
- version: '0'
159
+ version: 1.3.1
157
160
  requirements: []
158
161
  rubyforge_project:
159
162
  rubygems_version: 2.5.1