Class: OvirtSDK4::StorageServerConnectionService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::StorageServerConnectionService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (StorageConnection) get(opts = {})
Returns the representation of the object managed by this service.
-
- (Object) remove(opts = {})
Deletes the object managed by this service.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
-
- (Object) update(connection)
Updates the object managed by this service.
Instance Method Details
- (StorageConnection) get(opts = {})
Returns the representation of the object managed by this service.
20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 |
# File 'lib/ovirtsdk4/services.rb', line 20064 def get(opts = {}) query = {} request = Request.new(:method => :GET, :path => @path, :query => query) response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return StorageConnectionReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Object) remove(opts = {})
Deletes the object managed by this service.
20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 |
# File 'lib/ovirtsdk4/services.rb', line 20088 def remove(opts = {}) query = {} value = opts[:async] unless value.nil? value = Writer.render_boolean(value) query['async'] = value end request = Request.new(:method => :DELETE, :path => @path, :query => query) response = @connection.send(request) unless response.code == 200 check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
20139 20140 20141 20142 20143 20144 |
# File 'lib/ovirtsdk4/services.rb', line 20139 def service(path) if path.nil? || path == '' return self end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end |
- (String) to_s
Returns an string representation of this service.
20151 20152 20153 |
# File 'lib/ovirtsdk4/services.rb', line 20151 def to_s return "#<#{StorageServerConnectionService}:#{@path}>" end |
- (Object) update(connection)
Updates the object managed by this service.
20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 |
# File 'lib/ovirtsdk4/services.rb', line 20105 def update(connection) if connection.is_a?(Hash) connection = OvirtSDK4::StorageConnection.new(connection) end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) StorageConnectionWriter.write_one(connection, writer, 'connection') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return StorageConnectionReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end |