Class: Ubicloud::Adapter::NetHttp
- Inherits:
-
Ubicloud::Adapter
- Object
- Ubicloud::Adapter
- Ubicloud::Adapter::NetHttp
- Defined in:
- lib/ubicloud/adapter/net_http.rb
Overview
Ubicloud::Adapter::NetHttp is the recommended adapter for general use. It uses the net/http standard library to make requests to the Ubicloud API.
Instance Method Summary collapse
-
#initialize(token:, project_id:, base_uri: "https://api.ubicloud.com/") ⇒ NetHttp
constructor
Set the token and project_id to use for requests.
Methods inherited from Ubicloud::Adapter
adapter_class, #delete, #get, #patch, #post
Constructor Details
#initialize(token:, project_id:, base_uri: "https://api.ubicloud.com/") ⇒ NetHttp
Set the token and project_id to use for requests. The base_uri argument can be used to access a self-hosted Ubicloud instance (or other Ubicloud instance not hosted by Ubicloud).
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ubicloud/adapter/net_http.rb', line 13 def initialize(token:, project_id:, base_uri: "https://api.ubicloud.com/") @base_uri = URI.join(URI(base_uri), "project/#{project_id}/") @headers = { "authorization" => "Bearer: #{token}", "content-type" => "application/json", "accept" => "text/plain", "connection" => "close" }.freeze @get_headers = @headers.dup @get_headers.delete("content-type") @get_headers.freeze end |