/* SPDX-License-Identifier: BSD-3-Clause */
/*
 * Copyright 2018 Raritan Inc. All rights reserved.
 */

#ifndef __PDUMODEL_OUTLETGROUPMANAGER_IDL__
#define __PDUMODEL_OUTLETGROUPMANAGER_IDL__

#include <Outlet.idl>
#include <OutletGroup.idl>

module pdumodel {

    /** Outlet group manager interface */
    interface OutletGroupManager_1_1_10 {
        constant int ERR_INVALID_ARGUMENT = 1;
        constant int ERR_NO_SUCH_ID = 2;
        constant int ERR_MAX_GROUP_COUNT_REACHED = 3;

        /** Event: A new outlet group has been created */
        valueobject GroupCreatedEvent extends event.UserEvent {
            int id;                                 ///< The ID under which the outlet group manager
                                                    ///< references this group; may be reused after
                                                    ///< a group is deleted.
            int uniqueId;                           ///< Random ID uniquely identifying the new group
            OutletGroup_1_1_10 group;                ///< The new group
            OutletGroup_1_1_10.Settings settings;    ///< The new group's settings
        };

        /** Event: An outlet group has been deleted */
        valueobject GroupDeletedEvent extends event.UserEvent {
            int id;                                 ///< The ID under which the outlet group manager
                                                    ///< referenced the group
            int uniqueId;                           ///< Random unique ID of the deleted group
            OutletGroup_1_1_10.Settings settings;    ///< Last group settings before deletion
        };

        /**
         * Create a new outlet group.
         *
         * @param name     New group name
         * @param members  List of member outlets
         * @param group    Result: Reference to newly created group; null in case of error
         *
         * @return 0 if OK
         * @return 1 if any parameters are invalid
         * @return 3 if the maximum number of groups has been reached
         */
        int createGroup(in string name, in vector<Outlet_3_0_3> members, out OutletGroup_1_1_10 group);

        /**
         * Retrieve the list of outlet groups.
         *
         * @return Map of outlet groups, indexed by group ID
         */
        map<int, OutletGroup_1_1_10> getAllGroups();

        /**
         * Retrieve a specific outlet group.
         *
         * @param id     The ID of the requested group
         * @param group  Result: requested outlet group; null if not found
         *
         * @return 0 if OK
         * @return 2 if no group with the given ID exists
         */
        int getGroup(in int id, out OutletGroup_1_1_10 group);

        /**
         * Delete an outlet group.
         *
         * @param id  The ID of the group to delete
         *
         * @return 0 if OK
         * @return 2 if no group with the given ID exists
         */
        int deleteGroup(in int id);
    };
}

#endif
