Class: Misty::HTTP::Client
- Inherits:
-
Object
- Object
- Misty::HTTP::Client
- Includes:
- Direct, MethodBuilder, NetHTTP, Request
- Defined in:
- lib/misty/http/client.rb
Direct Known Subclasses
Openstack::Aodh::V2, Openstack::Ceilometer::V2, Openstack::Cinder::V1, Openstack::Cinder::V2, Openstack::Cinder::V3, Openstack::Designate::V2, Openstack::Freezer::V1, Openstack::Glance::V1, Openstack::Glance::V2, Openstack::Heat::V1, Openstack::Ironic::V1, Openstack::Karbor::V1, Openstack::Keystone::V2_0, Openstack::Keystone::V3, Openstack::Magnum::V1, Openstack::Manila::V2, Openstack::Murano::V1, Openstack::Neutron::V2_0, Openstack::Nova::V2_1, Openstack::Octavia::V2_0, Openstack::Sahara::V1_1, Openstack::Searchlight::V1, Openstack::Senlin::V1, Openstack::Swift::V1, Openstack::Tacker::V1_0, Openstack::Trove::V1_0, Openstack::Zaqar::V2
Defined Under Namespace
Classes: InvalidDataError, Options
Constant Summary collapse
- INTERFACES =
%w{admin public internal}
Instance Attribute Summary collapse
-
#microversion ⇒ Object
readonly
Returns the value of attribute microversion.
Class Method Summary collapse
-
.prefix_path_to_ignore ⇒ Object
Sub classes to override When a catalog provides a base path and the Service API definition containts the generic equivalent as prefix then the preifx is redundant and must be removed from the path.
Instance Method Summary collapse
- #headers ⇒ Object
- #headers_default ⇒ Object
-
#initialize(auth, config, options) ⇒ Client
constructor
Options - Values shown are the default Base path can be forced (Not recommended, mainly used for test purposes) :base_path => nil URL can be forced (Helps when setup is broken) :base_url => nil Endpoint type (admin, public or internal) :interface => “public” Region ID :region_id => “regionOne” Service name The Service names are pre defined but more can be added using this option.
- #requests ⇒ Object
Methods included from Direct
#base_set, #delete, #get, #post, #put
Methods included from Request
#decode?, #http, #http_copy, #http_delete, #http_get, #http_head, #http_options, #http_patch, #http_post, #http_put, #http_to_s
Methods included from MethodBuilder
Methods included from NetHTTP
Constructor Details
#initialize(auth, config, options) ⇒ Client
Options - Values shown are the default
Base path can be forced (Not recommended, mainly used for test purposes)
:base_path => nil
URL can be forced (Helps when setup is broken)
:base_url => nil
Endpoint type (admin, public or internal)
:interface => "public"
Region ID
:region_id => "regionOne"
Service name
The Service names are pre defined but more can be added using this option.
:service_name
SSL Verify Mode
:ssl_verify_mode => true
(micro)version: Can be numbered (3.1) or by state (CURRENT, LATEST or SUPPORTED)
:version => "CURRENT"
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/misty/http/client.rb', line 50 def initialize(auth, config, ) @auth = auth @config = config @options = setup() @uri = URI.parse(@auth.get_endpoint(@options.service_names, @options.region_id, @options.interface)) @base_path = @options.base_path ? @options.base_path : @uri.path @base_path = @base_path.chomp("/") @http = Misty::HTTP::NetHTTP.net_http(@uri, @options.ssl_verify_mode, @config.log) @version = nil @microversion = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Misty::HTTP::MethodBuilder
Instance Attribute Details
#microversion ⇒ Object (readonly)
Returns the value of attribute microversion.
22 23 24 |
# File 'lib/misty/http/client.rb', line 22 def microversion @microversion end |
Class Method Details
.prefix_path_to_ignore ⇒ Object
Sub classes to override When a catalog provides a base path and the Service API definition containts the generic equivalent as prefix then the preifx is redundant and must be removed from the path. For example: Catalog provides “192.0.2.21:8004/v1/48985e6b8da145699d411f12a3459fca” and Service API has “/v1/tenant_id/stacks” then the path prefix is ignored and path is only “/stacks”
69 70 71 |
# File 'lib/misty/http/client.rb', line 69 def self.prefix_path_to_ignore "" end |
Instance Method Details
#headers ⇒ Object
77 78 79 80 81 |
# File 'lib/misty/http/client.rb', line 77 def headers h = headers_default.merge("X-Auth-Token" => "#{@auth.get_token}") h.merge!(microversion_header) if microversion h end |
#headers_default ⇒ Object
73 74 75 |
# File 'lib/misty/http/client.rb', line 73 def headers_default Misty::HEADER_JSON end |
#requests ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/misty/http/client.rb', line 24 def requests list = [] self.class.api.each do |_path, verbs| verbs.each do |_verb, requests| list << requests end end list.flatten.sort end |