Class: OvirtSDK4::DiskSnapshotsService

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

Instance Method Summary (collapse)

Instance Method Details

- (Array<DiskSnapshot>) 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 snapshots to return. If not specified all the snapshots are returned.

Returns:



5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
# File 'lib/ovirtsdk4/services.rb', line 5840

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 DiskSnapshotReader.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.



5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
# File 'lib/ovirtsdk4/services.rb', line 5880

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

- (DiskSnapshotService) snapshot_service(id)

Locates the snapshot service.

Parameters:

  • id (String)

    The identifier of the snapshot.

Returns:



5869
5870
5871
# File 'lib/ovirtsdk4/services.rb', line 5869

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


5896
5897
5898
# File 'lib/ovirtsdk4/services.rb', line 5896

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