Class: InvisibleCollector::Resources::VmsResource
- Inherits:
-
Object
- Object
- InvisibleCollector::Resources::VmsResource
- Includes:
- DefaultHandlers
- Defined in:
- lib/invisible_collector/resources/vms_resource.rb
Instance Method Summary collapse
- #get(id, attrs = {}) ⇒ Object
-
#initialize(options = {}) ⇒ VmsResource
constructor
A new instance of VmsResource.
- #save(message) ⇒ Object
Methods included from DefaultHandlers
#execute, #execute_get, #execute_post, #handle, #handles
Constructor Details
#initialize(options = {}) ⇒ VmsResource
Returns a new instance of VmsResource.
8 9 10 11 12 13 14 15 |
# File 'lib/invisible_collector/resources/vms_resource.rb', line 8 def initialize( = {}) super() handle(400) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) } handle(403) { |response| raise InvisibleCollector::Forbidden.from_json(response.body) } handle(404) { |response| raise InvisibleCollector::NotFound.from_json(response.body) } handle(409) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) } handle(422) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) } end |
Instance Method Details
#get(id, attrs = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/invisible_collector/resources/vms_resource.rb', line 17 def get(id, attrs = {}) response = @connection.get("vms/#{id}", attrs) if response.status == 404 nil else build_response(response) end end |
#save(message) ⇒ Object
26 27 28 29 |
# File 'lib/invisible_collector/resources/vms_resource.rb', line 26 def save() response = execute_post('vms', ) build_list_response(response) end |