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
-
#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 Optional headers :headers => {} 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
Optional headers
:headers => {}
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"
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/misty/http/client.rb', line 53 def initialize(auth, config, ) @auth = auth @config = config @options = setup() @uri = URI.parse(@auth.get_url(@options.service_names, @options.region_id, @options.interface)) @base_path = @options.base_path ? @options.base_path : @uri.path @base_path = @base_path.chomp('/') @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.
23 24 25 |
# File 'lib/misty/http/client.rb', line 23 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’
71 72 73 |
# File 'lib/misty/http/client.rb', line 71 def self.prefix_path_to_ignore '' end |
Instance Method Details
#headers ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/misty/http/client.rb', line 75 def headers header = {} header.merge!({'Content-Type' => 'application/json', 'Accept' => 'application/json'}) header.merge!('X-Auth-Token' => @auth.get_token.to_s) header.merge!(@config.headers) if @config.headers header.merge!(@options.headers) if @options.headers header.merge!(microversion_header) if microversion header end |
#requests ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/misty/http/client.rb', line 25 def requests list = [] self.class.api.each do |_path, verbs| verbs.each do |_verb, requests| list << requests end end list.flatten.sort end |