Class: GlobiGuard::ResourceClient
- Inherits:
-
Object
- Object
- GlobiGuard::ResourceClient
- Defined in:
- lib/globiguard.rb
Instance Method Summary collapse
- #create(body) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(transport, base_path, read_only:) ⇒ ResourceClient
constructor
A new instance of ResourceClient.
- #list ⇒ Object
- #post(suffix, body) ⇒ Object
Constructor Details
#initialize(transport, base_path, read_only:) ⇒ ResourceClient
Returns a new instance of ResourceClient.
139 140 141 142 143 |
# File 'lib/globiguard.rb', line 139 def initialize(transport, base_path, read_only:) @transport = transport @base_path = base_path @read_only = read_only end |
Instance Method Details
#create(body) ⇒ Object
147 148 149 150 |
# File 'lib/globiguard.rb', line 147 def create(body) require_write!("Resource creation") @transport.request("post", @base_path, body: body) end |
#get(id) ⇒ Object
146 |
# File 'lib/globiguard.rb', line 146 def get(id) = @transport.request("get", "#{@base_path}/#{URI.encode_www_form_component(id)}") |
#list ⇒ Object
145 |
# File 'lib/globiguard.rb', line 145 def list = @transport.request("get", @base_path) |
#post(suffix, body) ⇒ Object
152 153 154 155 |
# File 'lib/globiguard.rb', line 152 def post(suffix, body) require_write!("Resource mutation") @transport.request("post", "#{@base_path}/#{URI.encode_www_form_component(suffix.sub(%r{\A/+}, ""))}", body: body) end |