Class: Yao::Client::ClientSet
- Inherits:
-
Object
- Object
- Yao::Client::ClientSet
- Defined in:
- lib/yao/client.rb
Instance Attribute Summary collapse
-
#admin_pool ⇒ Object
readonly
Returns the value of attribute admin_pool.
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
Instance Method Summary collapse
-
#initialize ⇒ ClientSet
constructor
A new instance of ClientSet.
- #register_endpoints(endpoints, token: nil) ⇒ Object
Constructor Details
#initialize ⇒ ClientSet
Returns a new instance of ClientSet.
8 9 10 11 |
# File 'lib/yao/client.rb', line 8 def initialize @pool = {} @admin_pool = {} end |
Instance Attribute Details
#admin_pool ⇒ Object (readonly)
Returns the value of attribute admin_pool.
12 13 14 |
# File 'lib/yao/client.rb', line 12 def admin_pool @admin_pool end |
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
12 13 14 |
# File 'lib/yao/client.rb', line 12 def pool @pool end |
Instance Method Details
#register_endpoints(endpoints, token: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/yao/client.rb', line 24 def register_endpoints(endpoints, token: nil) endpoints.each_pair do |type, urls| # XXX: neutron just have v2.0 API and endpoint may not have version prefix if type == "network" urls = urls.map {|public_or_admin, url| path = URI.parse(url).path url = (path == '' || path == '/') ? File.join(url, "v2.0") : url [public_or_admin, url] }.to_h end self.pool[type] = Yao::Client.gen_client(urls[:public_url], token: token) if urls[:public_url] self.admin_pool[type] = Yao::Client.gen_client(urls[:admin_url], token: token) if urls[:admin_url] end end |