class OvirtSDK4::EventService

Public Class Methods

new(connection, path) click to toggle source

Creates a new implementation of the service.

@param connection [Connection] The connection to be used by this service.

@param path [String] The relative path of this service, for example `vms/123/disks`.

@api private

# File lib/ovirtsdk4/services.rb, line 7597
def initialize(connection, path)
  @connection = connection
  @path = path
end

Public Instance Methods

get(opts = {}) click to toggle source

Get an event.

An example of getting an event:

source

GET /ovirt-engine/api/events/123


source,xml

<event href=“/ovirt-engine/api/events/123” id=“123”>

<description>Host example.com was added by admin@internal-authz.</description>
<code>42</code>
<correlation_id>135</correlation_id>
<custom_id>-1</custom_id>
<flood_rate>30</flood_rate>
<origin>oVirt</origin>
<severity>normal</severity>
<time>2016-12-11T11:13:44.654+02:00</time>
<cluster href="/ovirt-engine/api/clusters/456" id="456"/>
<host href="/ovirt-engine/api/hosts/789" id="789"/>
<user href="/ovirt-engine/api/users/987" id="987"/>

</event>


Note that the number of fields changes according to the information that resides on the event. For example, for storage domain related events you will get the storage domain reference, as well as the reference for the data center this storage domain resides in.

@param opts [Hash] Additional options.

@return [Event]

# File lib/ovirtsdk4/services.rb, line 7637
def get(opts = {})
  query = {}
  request = HttpRequest.new(method: :GET, url: @path, query: query)
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return EventReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end
remove(opts = {}) click to toggle source

Removes an event from internal audit log.

An event can be removed by sending following request

source

DELETE /ovirt-engine/api/events/123


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the remove should be performed asynchronously.

# File lib/ovirtsdk4/services.rb, line 7667
def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = HttpRequest.new(method: :DELETE, url: @path, query: query)
  response = @connection.send(request)
  unless response.code == 200
    check_fault(response)
  end
end
service(path) click to toggle source

Locates the service corresponding to the given path.

@param path [String] The path of the service.

@return [Service] A reference to the service.

# File lib/ovirtsdk4/services.rb, line 7688
def service(path)
  if path.nil? || path == ''
    return self
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

# File lib/ovirtsdk4/services.rb, line 7700
def to_s
  "#<#{EventService}:#{@path}>"
end