Class: Ubicloud::Adapter
- Inherits:
-
Object
- Object
- Ubicloud::Adapter
- Defined in:
- lib/ubicloud/adapter.rb
Overview
Ubicloud::Adapter is the base class for adapters used in Ubicloud's Ruby SDK. Ubicloud's Ruby SDK uses adapters to allow for separate ways to access Ubicloud's API. Currently, the :net_http adapter is the recommended adapter.
Ubicloud::Adapter subclasses must implement call to handle sending the
request. They should call handle_response to handle responses to the
request.
Defined Under Namespace
Class Method Summary collapse
-
.adapter_class(adapter_type) ⇒ Object
Require the related adapter file, and return the related adapter.
Instance Method Summary collapse
-
#delete(path) ⇒ Object
Issue a DELETE request to the API for the given path.
-
#get(path, missing: :raise) ⇒ Object
Issue a GET request to the API for the given path.
-
#patch(path, params = nil) ⇒ Object
Issue a PATCH request to the API for the given path and parameters.
-
#post(path, params = nil) ⇒ Object
Issue a GET request to the API for the given path and parameters.
Class Method Details
.adapter_class(adapter_type) ⇒ Object
Require the related adapter file, and return the related adapter.
21 22 23 24 |
# File 'lib/ubicloud/adapter.rb', line 21 def self.adapter_class(adapter_type) require_relative "adapter/#{adapter_type}" const_get(ADAPTERS.fetch(adapter_type)) end |
Instance Method Details
#delete(path) ⇒ Object
Issue a DELETE request to the API for the given path.
37 38 39 |
# File 'lib/ubicloud/adapter.rb', line 37 def delete(path) call("DELETE", path) end |
#get(path, missing: :raise) ⇒ Object
Issue a GET request to the API for the given path.
27 28 29 |
# File 'lib/ubicloud/adapter.rb', line 27 def get(path, missing: :raise) call("GET", path, missing:) end |
#patch(path, params = nil) ⇒ Object
Issue a PATCH request to the API for the given path and parameters.
42 43 44 |
# File 'lib/ubicloud/adapter.rb', line 42 def patch(path, params = nil) call("PATCH", path, params:) end |
#post(path, params = nil) ⇒ Object
Issue a GET request to the API for the given path and parameters.
32 33 34 |
# File 'lib/ubicloud/adapter.rb', line 32 def post(path, params = nil) call("POST", path, params:) end |