Class: OvirtSDK4::QuotasService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::QuotasService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Quota) add(quota, opts = {})
Adds a new
quota
. -
- (Array<Quota>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (QuotaService) quota_service(id)
Locates the
quota
service. -
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (Quota) add(quota, opts = {})
Adds a new quota
.
16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 |
# File 'lib/ovirtsdk4/services.rb', line 16385 def add(quota, opts = {}) if quota.is_a?(Hash) quota = OvirtSDK4::Quota.new(quota) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) QuotaWriter.write_one(quota, writer, 'quota') 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 QuotaReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<Quota>) list(opts = {})
Returns the representation of the object managed by this service.
16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 |
# File 'lib/ovirtsdk4/services.rb', line 16420 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 QuotaReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (QuotaService) quota_service(id)
Locates the quota
service.
16449 16450 16451 |
# File 'lib/ovirtsdk4/services.rb', line 16449 def quota_service(id) return QuotaService.new(@connection, "#{@path}/#{id}") end |
- (Service) service(path)
Locates the service corresponding to the given path.
16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 |
# File 'lib/ovirtsdk4/services.rb', line 16460 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return quota_service(path) end return quota_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
16476 16477 16478 |
# File 'lib/ovirtsdk4/services.rb', line 16476 def to_s return "#<#{QuotasService}:#{@path}>" end |