Class: OvirtSDK4::QuotaStorageLimitsService

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

Instance Method Summary (collapse)

Instance Method Details

- (QuotaStorageLimit) add(limit, opts = {})

Adds a new limit.

Parameters:

Returns:



16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
# File 'lib/ovirtsdk4/services.rb', line 16265

def add(limit, opts = {})
  if limit.is_a?(Hash)
    limit = OvirtSDK4::QuotaStorageLimit.new(limit)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    QuotaStorageLimitWriter.write_one(limit, writer, 'limit')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 201, 202
    begin
      reader = XmlReader.new(response.body)
      return QuotaStorageLimitReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (QuotaStorageLimitService) limit_service(id)

Locates the limit service.

Parameters:

  • id (String)

    The identifier of the limit.

Returns:



16329
16330
16331
# File 'lib/ovirtsdk4/services.rb', line 16329

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

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

Returns:



16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
# File 'lib/ovirtsdk4/services.rb', line 16300

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



16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
# File 'lib/ovirtsdk4/services.rb', line 16340

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


16356
16357
16358
# File 'lib/ovirtsdk4/services.rb', line 16356

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