package org.wso2.carbon.device.mgt.mobile.impl.ios.profile;

import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.ios.payload.beans.DeviceProfile;
import org.wso2.carbon.device.mgt.ios.payload.exception.PListException;
import org.wso2.carbon.device.mgt.ios.payload.exception.ProfileConfigurationException;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dto.DEPDevice;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dto.DEPProfile;

import java.util.List;

public interface IOSProfileService {

    void saveProfile(DeviceProfile deviceProfile) throws PListException;
    DeviceProfile getProfile(String deviceId, String url) throws PListException;

    /**
     * Adding a new DEP profile to the database.
     * @param depProfile DEP profile to be added.
     * @return The auto generated ID added to the database.
     * @throws ProfileConfigurationException
     */
    int addDEPProfile(DEPProfile depProfile) throws ProfileConfigurationException;

    /**
     * Updating the DEP profile
     *
     * @param depProfile DEP profile to be updated.
     * @return return if the request is successful
     * @throws ProfileConfigurationException
     */
    boolean updateDEPProfile(DEPProfile depProfile) throws ProfileConfigurationException;

    /**
     * Adding a new DEP device to the database.
     * @param depDevice device to be added to the database.
     * @return added status.
     * @throws ProfileConfigurationException
     */
    boolean addDEPDevice(DEPDevice depDevice) throws ProfileConfigurationException;

    /**
     * Update a DEP device in the database.
     * @param depDevice Device to be updated.
     * @return Update success status.
     * @throws ProfileConfigurationException
     */
    boolean updateDEPDevice(DEPDevice depDevice) throws ProfileConfigurationException;

    /**
     * Get a DEP profile based on the UUID provided.
     * @param uuid UUID of the profile.
     * @return DEP profile content.
     * @throws ProfileConfigurationException
     */
    DEPProfile getDEPProfile(String uuid) throws ProfileConfigurationException;

    /**
     * Get all DEP profile in a paginated manner.
     *
     * @param request Pagination request
     * @return Details of the DEP profiles.
     * @throws ProfileConfigurationException
     */
    PaginationResult getDEPProfiles(PaginationRequest request) throws ProfileConfigurationException;

    /**
     * Delete a DEP device from the database.
     * @param depDevices Device to be deleted.
     * @throws ProfileConfigurationException
     */
    void removeDEPDevices(List<String> depDevices) throws ProfileConfigurationException;

    /**
     * Get DEP device from the database.
     * @param serial Serial number of the device to be fetched.
     * @return Device details.
     * @throws ProfileConfigurationException
     */
    DEPDevice getDEPDevice(String serial) throws ProfileConfigurationException;

    /**
     * Get all DEP devices in a paginated manner.
     *
     * @param request Pagination request.
     * @return Details of the DEP devices.
     * @throws ProfileConfigurationException
     */
    PaginationResult getDEPDevices(PaginationRequest request) throws ProfileConfigurationException;

    /**
     * Get DEP device from the database by device identifier.
     * @param id Device identifier of the device to be fetched.
     * @return Device details.
     * @throws ProfileConfigurationException
     */
    DEPDevice getDEPDeviceByDeviceId(String id) throws ProfileConfigurationException;

    /**
     * Update the user of the device list and if basic auth is needed to be checked.
     * @param username username of the owner of the serial numbers provided.
     * @param serials serial numbers of the devices to be updated.
     * @param requireBasicAuth if the basic authentication is required at the device startup.
     * @param requireAgentInstall
     * @throws ProfileConfigurationException
     */
    void updateDeviceUser(String username, String[] serials, boolean requireBasicAuth, boolean requireAgentInstall)throws
            ProfileConfigurationException;

    /**
     * Map a DEP profile to a DEP device.
     * @param uuid UUID of the DEP profile.
     * @param serialNumbers serial numbers of the devices.
     * @throws ProfileConfigurationException
     */
    void assignProfileToDevice(String uuid, String [] serialNumbers) throws
            ProfileConfigurationException;

    /**
     * Remove DEP profile to DEP device mapping.
     * @param serialNumbers serial numbers of the devices.
     * @throws ProfileConfigurationException
     */
    void removeProfileToDeviceAssignment(String [] serialNumbers) throws ProfileConfigurationException;
}
