Class: OvirtSDK4::SystemPermissionsService

Inherits:
AssignedPermissionsService show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

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

Adds a new permission.

Parameters:

Returns:



21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
# File 'lib/ovirtsdk4/services.rb', line 21130

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:



21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
# File 'lib/ovirtsdk4/services.rb', line 21163

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:



21188
21189
21190
# File 'lib/ovirtsdk4/services.rb', line 21188

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.



21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
# File 'lib/ovirtsdk4/services.rb', line 21199

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)


21215
21216
21217
# File 'lib/ovirtsdk4/services.rb', line 21215

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