Module: Misty::Openstack::Service
- Included in:
- ServicePack
- Defined in:
- lib/misty/openstack/service.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#microversion ⇒ Object
readonly
Returns the value of attribute microversion.
Instance Method Summary collapse
- #initialize(arg) ⇒ Object
-
#prefix_path_to_ignore ⇒ Object
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.
-
#request_config(arg = {}) ⇒ Object
Each option is recreated for a request brief life duration to account for a new value if provided or use value propagated from defaults, globals or service levels.
-
#requests ⇒ Object
Generate available requests available for current service.
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
4 5 6 |
# File 'lib/misty/openstack/service.rb', line 4 def headers @headers end |
#microversion ⇒ Object (readonly)
Returns the value of attribute microversion.
4 5 6 |
# File 'lib/misty/openstack/service.rb', line 4 def microversion @microversion end |
Instance Method Details
#initialize(arg) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/misty/openstack/service.rb', line 6 def initialize(arg) @token = arg[:token] @log = arg[:log] @config = arg[:config] @content_type = @config[:content_type] @headers = Misty::HTTP::Header.new(@config[:headers].get.clone) @ssl_verify_mode = @config[:ssl_verify_mode] @endpoint = if @config[:endpoint] URI.parse(@config[:endpoint]) else names = service_types names << @config[:service_name] if @config[:service_name] URI.parse(@token.catalog.get_endpoint_url(names, @config[:region], @config[:interface])) end @base_path = @config[:base_path] ? @config[:base_path] : @endpoint.path.chomp('/') if microversion asked_version = @config[:version] ? @config[:version] : '' @version = set_version(asked_version) end end |
#prefix_path_to_ignore ⇒ Object
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.
To use Mixing classes must override
For exampe, if a Catalog is defined with ‘192.0.2.21:8004/v1/48985e6b8da145699d411f12a3459fc’ and Service API resource has ‘/v1/tenant_id/stacks’ then the path prefix is ignored and path is only /stacks
40 41 42 |
# File 'lib/misty/openstack/service.rb', line 40 def prefix_path_to_ignore '' end |
#request_config(arg = {}) ⇒ Object
Each option is recreated for a request brief life duration to account for a new value if provided or use value propagated from defaults, globals or service levels
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/misty/openstack/service.rb', line 51 def request_config(arg = {}) @request_content_type = arg[:content_type] ? arg[:content_type] : @content_type @request_headers = Misty::HTTP::Header.new(@headers.get.clone) @request_headers.add(arg[:headers]) if arg[:headers] if microversion request_version = if arg[:version] set_version(arg[:version]) else @version end @request_headers.add(microversion_header(request_version)) if request_version end end |
#requests ⇒ Object
Generate available requests available for current service
45 46 47 |
# File 'lib/misty/openstack/service.rb', line 45 def requests requests_api + requests_custom end |