Class: OvirtSDK4::AssignedRolesService

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

Instance Method Summary (collapse)

Instance Method Details

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

Returns:



2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
# File 'lib/ovirtsdk4/services.rb', line 2789

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

- (RoleService) role_service(id)

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

Parameters:

  • id (String)

    The identifier of the role.

Returns:



2818
2819
2820
# File 'lib/ovirtsdk4/services.rb', line 2818

def role_service(id)
  return RoleService.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.



2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
# File 'lib/ovirtsdk4/services.rb', line 2829

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


2845
2846
2847
# File 'lib/ovirtsdk4/services.rb', line 2845

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