Class: OvirtSDK4::StatisticsService

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

Instance Method Summary (collapse)

Instance Method Details

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

Returns:



18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
# File 'lib/ovirtsdk4/services.rb', line 18270

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



18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
# File 'lib/ovirtsdk4/services.rb', line 18310

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

- (StatisticService) statistic_service(id)

Locates the statistic service.

Parameters:

  • id (String)

    The identifier of the statistic.

Returns:



18299
18300
18301
# File 'lib/ovirtsdk4/services.rb', line 18299

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


18326
18327
18328
# File 'lib/ovirtsdk4/services.rb', line 18326

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