Class: OvirtSDK4::PermitsService

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

Instance Method Summary (collapse)

Instance Method Details

- (Permit) add(permit, opts = {})

Adds a permit to the set aggregated by parent role. The permit must be one retrieved from the capabilities resource.

Parameters:

Returns:



15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
# File 'lib/ovirtsdk4/services.rb', line 15459

def add(permit, opts = {})
  if permit.is_a?(Hash)
    permit = OvirtSDK4::Permit.new(permit)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    PermitWriter.write_one(permit, writer, 'permit')
    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 PermitReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

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

Returns:



15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
# File 'lib/ovirtsdk4/services.rb', line 15494

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 PermitReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (PermitService) permit_service(id)

Sub-resource locator method, returns individual permit resource on which the remainder of the URI is dispatched.

Parameters:

  • id (String)

    The identifier of the permit.

Returns:



15523
15524
15525
# File 'lib/ovirtsdk4/services.rb', line 15523

def permit_service(id)
  return PermitService.new(@connection, "#{@path}/#{id}")
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.



15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
# File 'lib/ovirtsdk4/services.rb', line 15534

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


15550
15551
15552
# File 'lib/ovirtsdk4/services.rb', line 15550

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