yao 0.13.4 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) 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/lib/yao/auth.rb +18 -0
  7. data/lib/yao/client.rb +1 -1
  8. data/lib/yao/config.rb +19 -0
  9. data/lib/yao/faraday_middlewares.rb +37 -3
  10. data/lib/yao/mode.rb +4 -0
  11. data/lib/yao/plugins/default_client_generator.rb +0 -1
  12. data/lib/yao/plugins/registry.rb +2 -1
  13. data/lib/yao/resources/action.rb +7 -0
  14. data/lib/yao/resources/aggregates.rb +1 -0
  15. data/lib/yao/resources/base.rb +22 -1
  16. data/lib/yao/resources/compute_services.rb +8 -1
  17. data/lib/yao/resources/flavor.rb +2 -0
  18. data/lib/yao/resources/floating_ip.rb +2 -0
  19. data/lib/yao/resources/hypervisor.rb +1 -1
  20. data/lib/yao/resources/image.rb +2 -0
  21. data/lib/yao/resources/loadbalancer.rb +4 -0
  22. data/lib/yao/resources/loadbalancer_healthmonitor.rb +3 -0
  23. data/lib/yao/resources/loadbalancer_listener.rb +2 -0
  24. data/lib/yao/resources/loadbalancer_pool.rb +6 -0
  25. data/lib/yao/resources/loadbalancer_pool_member.rb +21 -0
  26. data/lib/yao/resources/metadata_available.rb +21 -0
  27. data/lib/yao/resources/meter.rb +8 -1
  28. data/lib/yao/resources/network.rb +1 -0
  29. data/lib/yao/resources/network_associationable.rb +1 -0
  30. data/lib/yao/resources/old_sample.rb +4 -0
  31. data/lib/yao/resources/port.rb +2 -0
  32. data/lib/yao/resources/port_associationable.rb +1 -0
  33. data/lib/yao/resources/project.rb +6 -0
  34. data/lib/yao/resources/resource.rb +8 -2
  35. data/lib/yao/resources/restfully_accessible.rb +15 -0
  36. data/lib/yao/resources/role.rb +6 -4
  37. data/lib/yao/resources/role_assignment.rb +1 -0
  38. data/lib/yao/resources/router.rb +9 -0
  39. data/lib/yao/resources/sample.rb +4 -0
  40. data/lib/yao/resources/security_group.rb +1 -0
  41. data/lib/yao/resources/security_group_rule.rb +10 -0
  42. data/lib/yao/resources/server.rb +20 -0
  43. data/lib/yao/resources/server_group.rb +1 -1
  44. data/lib/yao/resources/server_usage_associationable.rb +12 -0
  45. data/lib/yao/resources/subnet.rb +1 -0
  46. data/lib/yao/resources/tenant.rb +6 -0
  47. data/lib/yao/resources/tenant_associationable.rb +1 -0
  48. data/lib/yao/resources/user.rb +2 -0
  49. data/lib/yao/resources.rb +3 -0
  50. data/lib/yao/token.rb +1 -0
  51. data/lib/yao/version.rb +1 -1
  52. data/test/yao/resources/test_base.rb +11 -0
  53. data/test/yao/resources/test_image.rb +5 -0
  54. data/test/yao/resources/test_project.rb +20 -1
  55. data/test/yao/resources/test_server_group.rb +1 -1
  56. data/test/yao/test_client.rb +0 -1
  57. data/yao.gemspec +1 -1
  58. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ee889ea30a4ed867e8f34bcb5fd185f194b317320fd8f5797f1a7b24b232e66
4
- data.tar.gz: 745bb13217eb75907e47732b457ac41cd90330f23becb0936e4c13beabdeb6e3
3
+ metadata.gz: 55df2a0420c42a9448a180f6b0378d82bd8c6fb2d9efac004c152675d357ee3a
4
+ data.tar.gz: ff5477041bca286e2283ef8130c3659cd4762a8b415dbc374df73ff077dae51a
5
5
  SHA512:
6
- metadata.gz: bddf10dfefb8277e6ad2dda817ab08b54ede238586c1f4fd913b8648a257d4c8e79cb7301976cbf02f5991b4ffd8a0199d7a06db604d21a9f63438dea263801f
7
- data.tar.gz: 2e572a0ca854f98b118cb081daf3a862b3ad60ffcb7e8e0ba58d35d64cdaf40578a507cdd2b578c05b576be5d61c7d92161e251c03e0d6396fa73384599a2520
6
+ metadata.gz: 75274af855b318f6be285de56b21260f350e5dd892a291b4ef128db9683b9559e06a6284024f555e4123c879530a2b903b3abea29cc08be0c76fe54417638d38
7
+ data.tar.gz: 66ee630a29f13cd94eb4639fcabc711da46d71f1ff8ff779777b7833a052cf6899b5076f9bac7c25669449fb28a87d4c1d6a63857e5bbeae22bd27280834d84f
@@ -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/lib/yao/auth.rb CHANGED
@@ -12,12 +12,22 @@ module Yao
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 = {
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
@@ -5,6 +5,7 @@ module Yao::Resources
5
5
  :monitor_address, :address,
6
6
  :protocol_port, :operating_status
7
7
 
8
+ # @return [Yao::Resources::Tenant]
8
9
  def project
9
10
  if project_id = self["project_id"]
10
11
  Yao::Tenant.find project_id
@@ -12,6 +13,7 @@ module Yao::Resources
12
13
  end
13
14
  alias :tenant :project
14
15
 
16
+ # @return [Yao::Resources::Subnet]
15
17
  def subnet
16
18
  if subnet_id = self["subnet_id"]
17
19
  Yao::Subnet.find subnet_id
@@ -25,33 +27,52 @@ module Yao::Resources
25
27
 
26
28
  class << self
27
29
 
30
+ # @param pool [Yao::Resources::LoadBalancerPool]
31
+ # @param query [Hash]
32
+ # @return [Array<Yao::Resources::LoadBalancerPoolMember>]
28
33
  def list(pool, query={})
29
34
  self.resources_path = member_resources_path(pool)
30
35
  super(query)
31
36
  end
32
37
 
38
+ # @param pool [Yao::Resources::LoadBalancerPool]
39
+ # @param id_or_permalink [String]
40
+ # @param query [Hash]
41
+ # @return [Yao::Resources::LoadBalancerPoolMember]
33
42
  def get(pool, id_or_permalink, query={})
34
43
  self.resources_path = member_resources_path(pool)
35
44
  super(id_or_permalink, query)
36
45
  end
37
46
  alias find get
38
47
 
48
+ # @param pool [Yao::Resources::LoadBalancerPool]
49
+ # @param resource_params [Hash]
50
+ # @return [Yao::Resources::LoadBalancerPoolMember]
39
51
  def create(pool, resource_params)
40
52
  self.resources_path = member_resources_path(pool)
41
53
  super(resource_params)
42
54
  end
43
55
 
56
+ # @param pool [Yao::Resources::LoadBalancerPool]
57
+ # @param id [String]
58
+ # @param resource_params [Hash]
59
+ # @return [Yao::Resources::LoadBalancerPoolMember]
44
60
  def update(pool, id, resource_params)
45
61
  self.resources_path = member_resources_path(pool)
46
62
  super(id, resource_params)
47
63
  end
48
64
 
65
+ # @param pool [Yao::Resources::LoadBalancerPool]
66
+ # @param id [String]
67
+ # @return [String]
49
68
  def destroy(pool, id)
50
69
  self.resources_path = member_resources_path(pool)
51
70
  super(id)
52
71
  end
53
72
 
54
73
  private
74
+ # @param pool [Yao::Resources::LoadBalancerPool]
75
+ # @return [String]
55
76
  def member_resources_path(pool)
56
77
  "lbaas/pools/#{pool.id}/#{self.resources_name}"
57
78
  end