Class: OvirtSDK4::AssignedPermissionsService

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

Direct Known Subclasses

SystemPermissionsService

Instance Method Summary (collapse)

Instance Method Details

- (Permission) add(permission, opts = {})

Adds a new permission.

Parameters:

Returns:



2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
# File 'lib/ovirtsdk4/services.rb', line 2673

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

- (Array<Permission>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Returns:



2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
# File 'lib/ovirtsdk4/services.rb', line 2706

def list(opts = {})
  query = {}
  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 PermissionReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (PermissionService) permission_service(id)

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

Parameters:

  • id (String)

    The identifier of the permission.

Returns:



2731
2732
2733
# File 'lib/ovirtsdk4/services.rb', line 2731

def permission_service(id)
  return PermissionService.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.



2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
# File 'lib/ovirtsdk4/services.rb', line 2742

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


2758
2759
2760
# File 'lib/ovirtsdk4/services.rb', line 2758

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