Class: OvirtSDK4::EventSubscriptionsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary collapse
-
#add(event_subscription, opts = {}) ⇒ EventSubscription
Add a new event-subscription to the system.
-
#event_subscription_service(id) ⇒ EventSubscriptionService
Reference to the service that manages a specific event-subscription.
-
#list(opts = {}) ⇒ Array<EventSubscription>
List the event-subscriptions for the provided user.
-
#service(path) ⇒ Service
Locates the service corresponding to the given path.
Methods inherited from Service
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 HTTP/1.1
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.
8743 8744 8745 |
# File 'lib/ovirtsdk4/services.rb', line 8743 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.
8810 8811 8812 |
# File 'lib/ovirtsdk4/services.rb', line 8810 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 HTTP/1.1
<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>
8799 8800 8801 |
# File 'lib/ovirtsdk4/services.rb', line 8799 def list(opts = {}) internal_get(LIST, opts) end |
#service(path) ⇒ Service
Locates the service corresponding to the given path.
8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 |
# File 'lib/ovirtsdk4/services.rb', line 8821 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 |