yao 0.13.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +19 -0
  3. data/.github/workflows/ubuntu-rvm.yml +1 -1
  4. data/.github/workflows/ubuntu.yml +1 -1
  5. data/.rubocop.yml +3 -6
  6. data/README.md +2 -1
  7. data/lib/yao/auth.rb +19 -1
  8. data/lib/yao/client.rb +12 -8
  9. data/lib/yao/config.rb +19 -0
  10. data/lib/yao/faraday_middlewares.rb +37 -3
  11. data/lib/yao/mode.rb +4 -0
  12. data/lib/yao/plugins/default_client_generator.rb +0 -1
  13. data/lib/yao/plugins/registry.rb +2 -1
  14. data/lib/yao/resources/action.rb +7 -0
  15. data/lib/yao/resources/aggregates.rb +1 -0
  16. data/lib/yao/resources/base.rb +22 -1
  17. data/lib/yao/resources/compute_services.rb +8 -1
  18. data/lib/yao/resources/flavor.rb +2 -0
  19. data/lib/yao/resources/floating_ip.rb +2 -0
  20. data/lib/yao/resources/hypervisor.rb +1 -1
  21. data/lib/yao/resources/image.rb +2 -0
  22. data/lib/yao/resources/loadbalancer.rb +4 -0
  23. data/lib/yao/resources/loadbalancer_healthmonitor.rb +3 -0
  24. data/lib/yao/resources/loadbalancer_listener.rb +2 -0
  25. data/lib/yao/resources/loadbalancer_pool.rb +6 -0
  26. data/lib/yao/resources/loadbalancer_pool_member.rb +21 -0
  27. data/lib/yao/resources/metadata_available.rb +21 -0
  28. data/lib/yao/resources/meter.rb +8 -1
  29. data/lib/yao/resources/network.rb +1 -0
  30. data/lib/yao/resources/network_associationable.rb +1 -0
  31. data/lib/yao/resources/old_sample.rb +4 -0
  32. data/lib/yao/resources/port.rb +2 -0
  33. data/lib/yao/resources/port_associationable.rb +1 -0
  34. data/lib/yao/resources/project.rb +11 -0
  35. data/lib/yao/resources/resource.rb +8 -2
  36. data/lib/yao/resources/restfully_accessible.rb +15 -0
  37. data/lib/yao/resources/role.rb +6 -4
  38. data/lib/yao/resources/role_assignment.rb +36 -3
  39. data/lib/yao/resources/router.rb +9 -0
  40. data/lib/yao/resources/sample.rb +4 -0
  41. data/lib/yao/resources/security_group.rb +1 -0
  42. data/lib/yao/resources/security_group_rule.rb +10 -0
  43. data/lib/yao/resources/server.rb +20 -0
  44. data/lib/yao/resources/server_group.rb +1 -1
  45. data/lib/yao/resources/server_usage_associationable.rb +12 -0
  46. data/lib/yao/resources/subnet.rb +1 -0
  47. data/lib/yao/resources/tenant.rb +11 -0
  48. data/lib/yao/resources/tenant_associationable.rb +1 -0
  49. data/lib/yao/resources/user.rb +8 -1
  50. data/lib/yao/resources/volume.rb +12 -1
  51. data/lib/yao/resources/volume_action.rb +13 -0
  52. data/lib/yao/resources.rb +3 -0
  53. data/lib/yao/token.rb +1 -0
  54. data/lib/yao/version.rb +1 -1
  55. data/test/yao/resources/test_base.rb +11 -0
  56. data/test/yao/resources/test_image.rb +5 -0
  57. data/test/yao/resources/test_project.rb +45 -6
  58. data/test/yao/resources/test_role_assignment.rb +98 -1
  59. data/test/yao/resources/test_server_group.rb +1 -1
  60. data/test/yao/resources/test_user.rb +28 -1
  61. data/test/yao/resources/test_volume.rb +60 -1
  62. data/test/yao/test_client.rb +2 -1
  63. data/yao.gemspec +1 -1
  64. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 051a375b0fda12cf9a9a3553d13905638adb2af8e661606d2407c0a1b832c032
4
- data.tar.gz: a0592f5d24e3d258b2b2bba0c6b7d16dc48a26a365a27c4b98354a349da04144
3
+ metadata.gz: b2448b0a2070a9d61401c29e6f53445a4cb0c9bbd8f1bc98aac172661d6d9bc0
4
+ data.tar.gz: 0f50c66bd6fd508c0b47132c672395da04037cb4dd59842d48006c386d19f9fb
5
5
  SHA512:
6
- metadata.gz: 9c3859bf07d45e3f257ab3b7c8e45da5304cb0046b823916617fcd896d3ea2e7811dd4b3fce463a9fb1916dba336df00c6f817a246feeea6227036b7206a49b0
7
- data.tar.gz: 5fc9b2a499232273a76bde3134102d1913baa41c233cd42a5aa4d84704a19817a39285fcba8ab05bfbe0dc2d060705d7e0d580a30b4b53e49f2928b518ff7a44
6
+ metadata.gz: 4e6553ffc603ead2c2ec1d4a4fcc133381b3b4065f7cdce8df9705a8776ab7cf916d1d49d7cc59f5b5453c55b8d8bb1890cec7c35ace2d67f698a43e72f11450
7
+ data.tar.gz: 0b79462e8a112e7b12f490f8d24e3839b80792d2f4247fee849963c07b4b3b732d3d773a9b4806f27427812e80823e27b7f69a2e0ea198f5286bb7c18439b85c
@@ -0,0 +1,19 @@
1
+ name: rubocop
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@master
10
+ - name: Set up Ruby
11
+ uses: actions/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0
14
+ - name: Install dependencies
15
+ run: |
16
+ gem install bundler --no-document
17
+ bundle install
18
+ - name: Run rubocop
19
+ run: bundle exec rubocop
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ 'ruby-2.7.0' ]
10
+ ruby: [ 'ruby-3.0.3' ]
11
11
  steps:
12
12
  - uses: actions/checkout@master
13
13
  - name: Set up RVM
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ '2.6.x', '2.5.x', '2.4.x' ]
10
+ ruby: [3.0, 2.7, 2.6]
11
11
  steps:
12
12
  - uses: actions/checkout@master
13
13
  - name: Set up Ruby
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ SuggestExtensions: false
3
+ TargetRubyVersion: 3.0
3
4
  DisplayCopNames: true
4
5
  DisabledByDefault: true
5
6
  Exclude:
@@ -11,7 +12,7 @@ Style/HashSyntax:
11
12
  Layout/EmptyLines:
12
13
  Enabled: true
13
14
 
14
- Layout/TrailingBlankLines:
15
+ Layout/TrailingEmptyLines:
15
16
  Enabled: true
16
17
 
17
18
  Layout/TrailingWhitespace:
@@ -52,7 +53,3 @@ Style/NumericLiteralPrefix:
52
53
  Style/StabbyLambdaParentheses:
53
54
  EnforcedStyle: require_parentheses
54
55
  Enabled: true
55
-
56
- Rails/ActionFilter:
57
- EnforcedStyle: action
58
- Enabled: true
data/README.md CHANGED
@@ -34,7 +34,8 @@ Yao.configure do
34
34
  # timeout is optional
35
35
  timeout 300
36
36
 
37
- # If your endpoint requires cert & key
37
+ # If your endpoint requires cacert,cert and key
38
+ ca_cert "/path/to/my.ca"
38
39
  client_cert "/path/to/my.pem"
39
40
  client_key "/path/to/my.key"
40
41
 
data/lib/yao/auth.rb CHANGED
@@ -5,19 +5,29 @@ require 'yao/token'
5
5
  require 'yao/tokenv3'
6
6
 
7
7
  module Yao
8
- %i(tenant_name username password timeout client_cert client_key region_name
8
+ %i(tenant_name username password timeout ca_cert client_cert client_key region_name
9
9
  identity_api_version user_domain_id user_domain_name project_domain_id project_domain_name).each do |name|
10
10
  Yao.config.param name, nil
11
11
  end
12
12
 
13
13
  module Auth
14
14
  class << self
15
+ # @return [Yao::Auth]
15
16
  def try_new
16
17
  if Yao.config.tenant_name && Yao.config.username && Yao.config.password && Yao.default_client
17
18
  Yao::Auth.new
18
19
  end
19
20
  end
20
21
 
22
+ # @param tenant_name [String]
23
+ # @param username [String]
24
+ # @param password [String]
25
+ # @param default_domain [String]
26
+ # @param user_domain_id [String]
27
+ # @param user_domain_name [String]
28
+ # @param project_domain_id [String]
29
+ # @param project_domain_name [String]
30
+ # @return [Hash]
21
31
  def build_authv3_info(tenant_name, username, password,
22
32
  default_domain,
23
33
  user_domain_id, user_domain_name,
@@ -55,6 +65,10 @@ module Yao
55
65
  }
56
66
  end
57
67
 
68
+ # @param tenant_name [String]
69
+ # @param username [String]
70
+ # @param password [String]
71
+ # @return [Hash]
58
72
  def build_auth_info(tenant_name, username, password)
59
73
  auth_info = {
60
74
  auth: {
@@ -68,6 +82,10 @@ module Yao
68
82
  auth_info
69
83
  end
70
84
 
85
+ # if identity_api_version == "3"
86
+ # @return [TokenV3]
87
+ # else
88
+ # @return [Token]
71
89
  def new(
72
90
  tenant_name: Yao.config.tenant_name,
73
91
  username: Yao.config.username,
data/lib/yao/client.rb CHANGED
@@ -104,7 +104,7 @@ module Yao
104
104
  end
105
105
  end
106
106
 
107
- # @param [String]
107
+ # @param new_endpoint [String]
108
108
  def reset_client(new_endpoint=nil)
109
109
  set = ClientSet.new
110
110
  endpoint = {
@@ -124,13 +124,17 @@ module Yao
124
124
  end
125
125
 
126
126
  # Client Certificate Authentication
127
- if Yao.config.client_cert && Yao.config.client_key
128
- cert = OpenSSL::X509::Certificate.new(File.read(Yao.config.client_cert))
129
- key = OpenSSL::PKey.read(File.read(Yao.config.client_key))
130
- opt.merge!(ssl: {
131
- client_cert: cert,
132
- client_key: key,
133
- })
127
+ if (Yao.config.client_cert && Yao.config.client_key) || Yao.config.ca_cert
128
+ h = {}
129
+ if Yao.config.client_cert && Yao.config.client_key
130
+ cert = OpenSSL::X509::Certificate.new(File.read(Yao.config.client_cert))
131
+ key = OpenSSL::PKey.read(File.read(Yao.config.client_key))
132
+ h[:client_cert] = cert
133
+ h[:client_key] = key
134
+ end
135
+
136
+ h[:ca_file] = Yao.config.ca_cert if Yao.config.ca_cert
137
+ opt.merge!(ssl: h)
134
138
  end
135
139
  opt
136
140
  end
data/lib/yao/config.rb CHANGED
@@ -1,22 +1,30 @@
1
1
  module Yao
2
2
  class Config
3
+
4
+ # @return [Hash]
3
5
  def _configuration_defaults
4
6
  @_configuration_defaults ||= {}
5
7
  end
6
8
 
9
+ # @return [Hash]
7
10
  def _configuration_hooks
8
11
  @_configuration_hooks ||= {}
9
12
  end
10
13
 
14
+ # @return [Array]
11
15
  def _configuration_hooks_queue
12
16
  @_configuration_hooks_queue ||= []
13
17
  end
14
18
 
19
+ # @return [Hash]
15
20
  def configuration
16
21
  @configuration ||= {}
17
22
  end
18
23
 
19
24
  HOOK_RENEW_CLIENT_KEYS = %i(tenant_name username password auth_url debug debug_record_response)
25
+
26
+ # @param v [Boolean]
27
+ # @return [Array]
20
28
  def delay_hook=(v)
21
29
  @delay_hook = v
22
30
  if !v and !_configuration_hooks_queue.empty?
@@ -33,10 +41,14 @@ module Yao
33
41
  end
34
42
  end
35
43
 
44
+ # @return [Boolean]
36
45
  def delay_hook?
37
46
  @delay_hook
38
47
  end
39
48
 
49
+ # @param name [String]
50
+ # @param default [String]
51
+ # @param hook [Proc]
40
52
  def param(name, default, &hook)
41
53
  raise("Duplicate definition of #{name}") if self.respond_to?(name)
42
54
 
@@ -55,6 +67,9 @@ module Yao
55
67
  end
56
68
  end
57
69
 
70
+ # @param name [String]
71
+ # @param value [String]
72
+ # @return [String]
58
73
  def set(name, value)
59
74
  raise("Undefined config key #{name}") unless self.respond_to?(name)
60
75
  configuration[name.to_sym] = value
@@ -67,6 +82,8 @@ module Yao
67
82
  end
68
83
  end
69
84
 
85
+ # @param blk [Proc]
86
+ # @return [Yao::Config]
70
87
  def self.config(&blk)
71
88
  @__config ||= Config.new
72
89
  if blk
@@ -77,6 +94,8 @@ module Yao
77
94
  @__config
78
95
  end
79
96
 
97
+ # @param blk [Proc]
98
+ # @return [Yao::Config]
80
99
  def self.configure(&blk)
81
100
  config(&blk)
82
101
  end
@@ -81,17 +81,21 @@ class Faraday::Response::OSDumper < Faraday::Response::Middleware
81
81
  def on_complete(env)
82
82
  require 'pp'
83
83
 
84
- body = if env.response_headers["content-type"] == "application/json"
84
+ body = if env.response_headers["content-type"].start_with?("application/json")
85
85
  JSON.parse(env.body)
86
86
  else
87
87
  env.body
88
88
  end
89
+ body = conseal_token_in_body(body)
90
+
91
+ request_headers = conseal_token_in_request_headers(env.request_headers.dup)
92
+ response_headers= conseal_token_in_response_headers(env.response_headers.dup)
89
93
 
90
94
  params = [
91
95
  env.url.to_s,
92
96
  body,
93
- env.request_headers,
94
- env.response_headers,
97
+ request_headers,
98
+ response_headers,
95
99
  env.method,
96
100
  env.status
97
101
  ].map(&:pretty_inspect)
@@ -114,6 +118,36 @@ Status Code: %s
114
118
 
115
119
  FMT
116
120
  end
121
+
122
+ private
123
+ def conseal_token_in_body(body)
124
+ # for keystone v2.0
125
+ if body.is_a?(Hash) && token = body.dig("access", "token", "id")
126
+ body["access"]["token"]["id"] = hashed_token(token)
127
+ end
128
+ body
129
+ end
130
+
131
+ def conseal_token_in_request_headers(headers)
132
+ if token = headers["X-Auth-Token"]
133
+ headers["X-Auth-Token"] = hashed_token(token)
134
+ end
135
+ headers
136
+ end
137
+
138
+ def conseal_token_in_response_headers(headers)
139
+ if token = headers["x-subject-token"]
140
+ headers["x-subject-token"] = hashed_token(token)
141
+ end
142
+ headers
143
+ end
144
+
145
+ def hashed_token(token)
146
+ require 'openssl'
147
+
148
+ # This format was based on openstack client.
149
+ "{SHA256}" + OpenSSL::Digest::SHA256.hexdigest(token)
150
+ end
117
151
  end
118
152
  Faraday::Response.register_middleware os_dumper: -> { Faraday::Response::OSDumper }
119
153
 
data/lib/yao/mode.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Yao
2
2
  module Mode
3
+ # @param blk [Proc]
4
+ # @return [String]
3
5
  def read_only!(&blk)
4
6
  raise unless block_given?
5
7
 
@@ -16,6 +18,8 @@ module Yao
16
18
  end
17
19
  end
18
20
 
21
+ # @param blk [Proc]
22
+ # @return [String]
19
23
  def read_only(&blk)
20
24
  raise unless block_given?
21
25
 
@@ -20,7 +20,6 @@ module Yao::Plugins
20
20
  f.response :json, content_type: /\bjson$/
21
21
 
22
22
  if Yao.config.debug
23
- f.response :logger
24
23
  f.response :os_dumper
25
24
  end
26
25
 
@@ -6,11 +6,12 @@ module Yao::Plugins
6
6
  class Registry
7
7
  include Singleton
8
8
 
9
+ # @return [Hash]
9
10
  def initialize
10
11
  @types = {}
11
12
  end
12
13
 
13
- # @type type [Symbol]
14
+ # @param type [Symbol]
14
15
  # @return [Object]
15
16
  def [](type)
16
17
  @types[type]
@@ -1,5 +1,9 @@
1
1
  module Yao::Resources
2
2
  module Action
3
+
4
+ # @param id [String]
5
+ # @param query [Hash]
6
+ # @return [Hash]
3
7
  def action(id, query)
4
8
  res = POST(action_path(id)) do |req|
5
9
  req.body = query.to_json
@@ -9,6 +13,9 @@ module Yao::Resources
9
13
  end
10
14
 
11
15
  private
16
+
17
+ # @param id [String]
18
+ # @return [String]
12
19
  def action_path(id)
13
20
  [resources_name, id, "action"].join("/")
14
21
  end
@@ -4,6 +4,7 @@ module Yao::Resources
4
4
  class Aggregates < Base
5
5
  friendly_attributes :availability_zone, :deleted, :hosts, :metadata, :name
6
6
 
7
+ # @return [Date]
7
8
  def deleted_at
8
9
  Date.parse(self["deleted_at"]) if self["deleted_at"]
9
10
  end
@@ -3,6 +3,8 @@ require 'time'
3
3
 
4
4
  module Yao::Resources
5
5
  class Base
6
+
7
+ # @param name [Array]
6
8
  def self.friendly_attributes(*names)
7
9
  names.map(&:to_s).each do |name|
8
10
  define_method(name) do
@@ -14,6 +16,8 @@ module Yao::Resources
14
16
  end
15
17
  end
16
18
 
19
+ # @param k_and_v [Hash]
20
+ # @return [Symbol]
17
21
  def self.map_attribute_to_attribute(k_and_v)
18
22
  as_json, as_method = *k_and_v.to_a.first.map(&:to_s)
19
23
  define_method(as_method) do
@@ -21,14 +25,20 @@ module Yao::Resources
21
25
  end
22
26
  end
23
27
 
28
+ # @param k_and_v [Hash]
29
+ # @return [Symbol]
24
30
  def self.map_attribute_to_resource(k_and_v)
25
31
  _name, klass = *k_and_v.to_a.first
26
32
  name = _name.to_s
27
33
  define_method(name) do
28
- self[[name, klass].join("__")] ||= klass.new(self[name])
34
+ unless self[name].empty?
35
+ self[[name, klass].join("__")] ||= klass.new(self[name])
36
+ end
29
37
  end
30
38
  end
31
39
 
40
+ # @param k_and_v [Hash]
41
+ # @return [Symbol]
32
42
  def self.map_attribute_to_resources(k_and_v)
33
43
  _name, klass = *k_and_v.to_a.first
34
44
  name = _name.to_s
@@ -39,32 +49,43 @@ module Yao::Resources
39
49
  end
40
50
  end
41
51
 
52
+ # @param data_via_json [Hash]
53
+ # @return [Hash]
42
54
  def initialize(data_via_json)
43
55
  @data = data_via_json
44
56
  end
45
57
 
58
+ # @param name [String]
59
+ # @return [String]
46
60
  def [](name)
47
61
  @data[name]
48
62
  end
49
63
 
64
+ # @param name [String]
65
+ # @param value [String]
66
+ # @return [String]
50
67
  def []=(name, value)
51
68
  @data[name] = value
52
69
  end
53
70
 
71
+ # @return [Hash]
54
72
  def to_hash
55
73
  @data
56
74
  end
57
75
 
76
+ # @return [String]
58
77
  def id
59
78
  self["id"]
60
79
  end
61
80
 
81
+ # @return [Date]
62
82
  def created
63
83
  if date = self["created"] || self["created_at"]
64
84
  Time.parse(date)
65
85
  end
66
86
  end
67
87
 
88
+ # @return [Date]
68
89
  def updated
69
90
  if date = self["updated"] || self["updated_at"]
70
91
  Time.parse(date)
@@ -19,6 +19,9 @@ module Yao::Resources
19
19
  end
20
20
 
21
21
  class << self
22
+ # @param host [String]
23
+ # @param binary [String]
24
+ # @return [Yao::Resources::ComputeServices]
22
25
  def enable(host, binary)
23
26
  params = {
24
27
  "host" => host,
@@ -27,6 +30,10 @@ module Yao::Resources
27
30
  put("enable", params)
28
31
  end
29
32
 
33
+ # @param host [String]
34
+ # @param binary [String]
35
+ # @param resason [String]
36
+ # @return [Yao::Resources::ComputeServices]
30
37
  def disable(host, binary, reason = nil)
31
38
  params = {
32
39
  "host" => host,
@@ -55,4 +62,4 @@ module Yao::Resources
55
62
  end
56
63
 
57
64
  end
58
- end
65
+ end
@@ -4,6 +4,8 @@ module Yao::Resources
4
4
  map_attribute_to_attribute "os-flavor-access:is_public" => :public?
5
5
  map_attribute_to_attribute "OS-FLV-DISABLED:disabled" => :disabled?
6
6
 
7
+ # @param unit [String]
8
+ # @return [Integer]
7
9
  def ram(unit='M')
8
10
  case unit
9
11
  when 'M'
@@ -14,10 +14,12 @@ module Yao::Resources
14
14
  self.resource_name = "floatingip"
15
15
  self.resources_name = "floatingips"
16
16
 
17
+ # @return [Yao::Resources::Router]
17
18
  def router
18
19
  @router ||= Yao::Router.get(router_id)
19
20
  end
20
21
 
22
+ # @return [Yao::Resources::Tenant]
21
23
  def project
22
24
  @project ||= Yao::Tenant.get(project_id)
23
25
  end
@@ -22,7 +22,7 @@ module Yao::Resources
22
22
  self['status'] == 'disabled'
23
23
  end
24
24
 
25
- # @return [Yao::ComputeServices]
25
+ # @return [Yao::Resources::ComputeServices]
26
26
  def service
27
27
  Yao::ComputeServices.new(self['service'])
28
28
  end
@@ -5,6 +5,8 @@ module Yao::Resources
5
5
  map_attribute_to_attribute minDisk: :min_disk
6
6
  map_attribute_to_attribute minRam: :min_ram
7
7
 
8
+ # @param unit [String]
9
+ # @return [Integer]
8
10
  def size(unit=nil)
9
11
  size = self["OS-EXT-IMG-SIZE:size"]
10
12
  case unit
@@ -6,6 +6,7 @@ module Yao::Resources
6
6
  map_attribute_to_resources listeners: LoadBalancerListener
7
7
  map_attribute_to_resources pools: LoadBalancerPool
8
8
 
9
+ # @return [Yao::Resources::Tenant]
9
10
  def project
10
11
  if project_id = self["project_id"]
11
12
  Yao::Tenant.find project_id
@@ -13,18 +14,21 @@ module Yao::Resources
13
14
  end
14
15
  alias :tenant :project
15
16
 
17
+ # @return [Yao::Resources::Network]
16
18
  def vip_network
17
19
  if vip_network_id = self["vip_network_id"]
18
20
  Yao::Network.find vip_network_id
19
21
  end
20
22
  end
21
23
 
24
+ # @return [Yao::Resources::Port]
22
25
  def vip_port
23
26
  if vip_port_id = self["vip_port_id"]
24
27
  Yao::Port.find vip_port_id
25
28
  end
26
29
  end
27
30
 
31
+ # @return [Yao::Resources::Subnet]
28
32
  def vip_subnet
29
33
  if vip_subnet_id = self["vip_subnet_id"]
30
34
  Yao::Subnet.find vip_subnet_id
@@ -7,14 +7,17 @@ module Yao::Resources
7
7
 
8
8
  map_attribute_to_resources pools: LoadBalancerListener
9
9
 
10
+ # @return [Date]
10
11
  def created_at
11
12
  Date.parse(self["created_at"])
12
13
  end
13
14
 
15
+ # @return [Date]
14
16
  def updated_at
15
17
  Date.parse(self["updated_at"])
16
18
  end
17
19
 
20
+ # @return [Date]
18
21
  def project
19
22
  if project_id = self["project_id"]
20
23
  Yao::Tenant.find project_id
@@ -8,6 +8,7 @@ module Yao::Resources
8
8
 
9
9
  map_attribute_to_resources loadbalancers: LoadBalancer
10
10
 
11
+ # @return [Yao::Resources::Tenant]
11
12
  def project
12
13
  if project_id = self["project_id"]
13
14
  Yao::Tenant.find project_id
@@ -15,6 +16,7 @@ module Yao::Resources
15
16
  end
16
17
  alias :tenant :project
17
18
 
19
+ # @return [Yao::Resources::LoadBalancerPool]
18
20
  def default_pool
19
21
  if default_pool_id = self["default_pool_id"]
20
22
  Yao::LoadBalancerPool.find default_pool_id
@@ -7,20 +7,24 @@ module Yao::Resources
7
7
  map_attribute_to_resources loadbalancers: LoadBalancer
8
8
  map_attribute_to_resources listeners: LoadBalancerListener
9
9
 
10
+ # @return [Date]
10
11
  def created_at
11
12
  Date.parse(self["created_at"])
12
13
  end
13
14
 
15
+ # @return [Date]
14
16
  def updated_at
15
17
  Date.parse(self["updated_at"])
16
18
  end
17
19
 
20
+ # @return [Yao::Resources::LoadBalancerListener]
18
21
  def listeners
19
22
  self["listeners"].map do |listener|
20
23
  Yao::LoadBalancerListener.find listener["id"]
21
24
  end
22
25
  end
23
26
 
27
+ # @return [Yao::Resources::Tenant]
24
28
  def project
25
29
  if project_id = self["project_id"]
26
30
  Yao::Tenant.find project_id
@@ -28,12 +32,14 @@ module Yao::Resources
28
32
  end
29
33
  alias :tenant :project
30
34
 
35
+ # @return [Yao::Resources::LoadBalancerListener]
31
36
  def members
32
37
  self["members"].map do |member|
33
38
  Yao::LoadBalancerPoolMember.find(self,member["id"])
34
39
  end
35
40
  end
36
41
 
42
+ # @return [Yao::Resources::LoadBalancerHealthMonitor]
37
43
  def healthmonitor
38
44
  if healthmonitor_id = self["healthmonitor_id"]
39
45
  Yao::LoadBalancerHealthMonitor.find healthmonitor_id