All Downloads are FREE. Search and download functionalities are using the official Maven repository.

services.EventsService Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
/*
Copyright (c) 2015 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package services;

import annotations.Area;
import mixins.Follow;
import org.ovirt.api.metamodel.annotations.In;
import org.ovirt.api.metamodel.annotations.InputDetail;
import org.ovirt.api.metamodel.annotations.Out;
import org.ovirt.api.metamodel.annotations.Service;
import types.Event;

import static org.ovirt.api.metamodel.language.ApiLanguage.mandatory;
import static org.ovirt.api.metamodel.language.ApiLanguage.optional;

/**
 * A service to manage events in the system.
 *
 * @author Oved Ourfali 
 * @date 12 Dec 2016
 * @status added
 */
@Service
@Area("Infrastructure")
public interface EventsService {
    /**
     * Adds an external event to the internal audit log.
     *
     * This is intended for integration with external systems that detect or produce events relevant for the
     * administrator of the system. For example, an external monitoring tool may be able to detect that a file system
     * is full inside the guest operating system of a virtual machine. This event can be added to the internal audit
     * log sending a request like this:
     *
     * [source]
     * ----
     * POST /ovirt-engine/api/events
     * 
     *   File system /home is full
     *   alert
     *   mymonitor
     *   1467879754
     * 
     * ----
     *
     * Events can also be linked to specific objects. For example, the above event could be linked to the specific
     * virtual machine where it happened, using the `vm` link:
     *
     * [source]
     * ----
     * POST /ovirt-engine/api/events
     * 
     *   File system /home is full
     *   alert
     *   mymonitor
     *   1467879754
     *   
     * 
     * ----
     *
     * NOTE: When using links, like the `vm` in the previous example, only the `id` attribute is accepted. The `name`
     * attribute, if provided, is simply ignored.
     *
     * @author Juan Hernandez 
     * @author Eitan Raviv 
     * @date 19 Aug 2019
     * @status updated
     */
    interface Add {
        @InputDetail
        default void inputDetail() {
            mandatory(event().customId());
            mandatory(event().description());
            mandatory(event().origin());
            mandatory(event().severity());
            optional(event().cluster().id());
            optional(event().dataCenter().id());
            optional(event().floodRate());
            optional(event().host().externalStatus());
            optional(event().host().id());
            optional(event().storageDomain().externalStatus());
            optional(event().storageDomain().id());
            optional(event().template().id());
            optional(event().user().id());
            optional(event().vm().id());
            optional(event().logOnHost());
        }
        @In @Out Event event();
    }

    /**
     * Get list of events.
     *
     * [source]
     * ----
     * GET /ovirt-engine/api/events
     * ----
     *
     * To the above request we get following response:
     *
     * [source,xml]
     * ----
     * 
     *   
     *     User admin@internal-authz logged out.
     *     31
     *     1e892ea9
     *     -1
     *     30
     *     oVirt
     *     normal
     *     
     *     
     *   
     *   
     *     User admin logged in.
     *     30
     *     1fbd81f4
     *     -1
     *     30
     *     oVirt
     *     normal
     *     
     *     
     *   
     * 
     * ----
     *
     * The following events occur:
     *
     * * id="1" - The API logs in the admin user account.
     * * id="2" - The API logs out of the admin user account.
     *
     * The order of the returned list of events is always garanteed. If the `sortby` clause is included in the
     * `search` parameter, then the events will be ordered according to that clause. If the `sortby` clause isn't
     * included, then the events will be sorted by the numeric value of the `id` attribute, starting with the
     * highest value. This, combined with the `max` parameter, simplifies obtaining the most recent event:
     *
     * ....
     * GET /ovirt-engine/api/events?max=1
     * ....
     *
     * @author Piotr Kliczewski 
     * @date 14 Sep 2016
     * @status added
     */
    interface List extends Follow {
        @Out Event[] events();

        /**
         * Indicates the event index after which events should be returned. The indexes of events are
         * strictly increasing, so when this parameter is used only the events with greater indexes
         * will be returned. For example, the following request will return only the events
         * with indexes greater than `123`:
         *
         * [source]
         * ----
         * GET /ovirt-engine/api/events?from=123
         * ----
         *
         * This parameter is optional, and if not specified then the first event returned will be most recently
         * generated.
         *
         * @author Juan Hernandez 
         * @date 6 Jul 2016
         * @status added
         */
        @In Integer from();

        /**
         * Sets the maximum number of events to return. If not specified all the events are returned.
         */
        @In Integer max();

        /**
         * The events service provides search queries similar to other resource services.
         *
         * We can search by providing specific severity.
         *
         * [source]
         * ----
         * GET /ovirt-engine/api/events?search=severity%3Dnormal
         * ----
         *
         * To the above request we get a list of events which severity is equal to `normal`:
         *
         * [source,xml]
         * ----
         * 
         *   
         *     User admin@internal-authz logged out.
         *     31
         *     1fbd81f4
         *     -1
         *     30
         *     oVirt
         *     normal
         *     
         *     
         *   
         *   
         *     Affinity Rules Enforcement Manager started.
         *     10780
         *     -1
         *     30
         *     oVirt
         *     normal
         *     
         *   
         * 
         * ----
         *
         * A virtualization environment generates a large amount of events after
         * a period of time. However, the API only displays a default number of
         * events for one search query. To display more than the default, the API
         * separates results into pages with the page command in a search query.
         * The following search query tells the API to paginate results using a
         * page value in combination with the sortby clause:
         *
         * [source]
         * ----
         * sortby time asc page 1
         * ----
         *
         * Below example paginates event resources. The URL-encoded request is:
         *
         * [source]
         * ----
         * GET /ovirt-engine/api/events?search=sortby%20time%20asc%20page%201
         * ----
         *
         * Increase the page value to view the next page of results.
         *
         * [source]
         * ----
         * GET /ovirt-engine/api/events?search=sortby%20time%20asc%20page%202
         * ----
         *
         * @author Piotr Kliczewski 
         * @date 14 Sep 2016
         * @status added
         */
        @In String search();

        /**
         * Indicates if the search performed using the `search` parameter should be performed taking case into
         * account. The default value is `true`, which means that case is taken into account. If you want to search
         * ignoring case set it to `false`.
         */
        @In Boolean caseSensitive();
    }

    interface Undelete {
        /**
         * Indicates if the un-delete should be performed asynchronously.
         */
        @In Boolean async();
    }

    /**
     * Reference to the service that manages a specific event.
     *
     * @author Oved Ourfali 
     * @date 12 Dec 2016
     * @status added
     */
    @Service EventService event(String id);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy