Class: OvirtSDK4::EventSubscriptionsService

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

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#add(event_subscription, opts = {}) ⇒ EventSubscription

Add a new event-subscription to the system.

An event-subscription is always added in the context of a user. For example, to add new event-subscription for host_high_cpu_use for user 123, and have the notification sent to the e-mail address: [email protected], send a request like this:

POST /ovirt-engine/api/users/123/eventsubscriptions

With a request body like this:

<event_subscription>
    <event>host_high_cpu_use</event>
    <address>[email protected]</address>
</event_subscription>

The event name will become the ID of the new event-subscription entity: GET …​/api/users/123/eventsubscriptions/host_high_cpu_use

Note that no user id is provided in the request body. This is because the user-id (in this case 123) is already known to the API from the context. Note also that event-subscription entity contains notification-method field, but it is not provided either in the request body. This is because currently it’s always set to SMTP as SNMP notifications are still unsupported by the API layer.

Parameters:

  • event_subscription (EventSubscription)

    The added event-subscription.

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

    Additional options.

Options Hash (opts):

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:


8721
8722
8723
# File 'lib/ovirtsdk4/services.rb', line 8721

def add(event_subscription, opts = {})
  internal_add(event_subscription, EventSubscription, ADD, opts)
end

#event_subscription_service(id) ⇒ EventSubscriptionService

Reference to the service that manages a specific event-subscription.

Parameters:

  • id (String)

    The identifier of the event_subscription.

Returns:


8789
8790
8791
# File 'lib/ovirtsdk4/services.rb', line 8789

def event_subscription_service(id)
  EventSubscriptionService.new(self, id)
end

#list(opts = {}) ⇒ Array<EventSubscription>

List the event-subscriptions for the provided user.

For example to list event-subscriptions for user 123:

GET /ovirt-engine/api/users/123/event-subscriptions
<event-subscriptions>
  <event-subscription href="/ovirt-engine/api/users/123/event-subscriptions/host_install_failed">
    <event>host_install_failed</event>
    <notification_method>smtp</notification_method>
    <user href="/ovirt-engine/api/users/123" id="123"/>
    <address>[email protected]</address>
  </event-subscription>
  <event-subscription href="/ovirt-engine/api/users/123/event-subscriptions/vm_paused">
    <event>vm_paused</event>
    <notification_method>smtp</notification_method>
    <user href="/ovirt-engine/api/users/123" id="123"/>
    <address>[email protected]</address>
  </event-subscription>
</event-subscriptions>

Parameters:

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

    Additional options.

Options Hash (opts):

  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :max (Integer)

    Sets the maximum number of event-subscriptions to return. If not specified all the event-subscriptions are returned.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:


8778
8779
8780
# File 'lib/ovirtsdk4/services.rb', line 8778

def list(opts = {})
  internal_get(LIST, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.


8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
# File 'lib/ovirtsdk4/services.rb', line 8800

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