Class: OvirtSDK4::SnapshotDisksService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (SnapshotDiskService) disk_service(id)

Locates the disk service.

Parameters:

  • id (String)

    The identifier of the disk.

Returns:



17633
17634
17635
# File 'lib/ovirtsdk4/services.rb', line 17633

def disk_service(id)
  return SnapshotDiskService.new(@connection, "#{@path}/#{id}")
end

- (Array<Disk>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :max (Integer)

    Sets the maximum number of disks to return. If not specified all the disks are returned.

Returns:



17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
# File 'lib/ovirtsdk4/services.rb', line 17604

def list(opts = {})
  query = {}
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  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 DiskReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
# File 'lib/ovirtsdk4/services.rb', line 17644

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return disk_service(path)
  end
  return disk_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


17660
17661
17662
# File 'lib/ovirtsdk4/services.rb', line 17660

def to_s
  return "#<#{SnapshotDisksService}:#{@path}>"
end