/*
 * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. licenses this file to you 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 org.wso2.carbon.device.mgt.ios.services;

import org.bouncycastle.cms.CMSException;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.ios.api.utils.beans.LoginBean;
import org.wso2.carbon.device.mgt.ios.util.ContentType;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.InputStream;

/**
 * iOS device enrollment REST-API implementation.
 */
public interface EnrollmentService {

    @GET
    @Produces({MediaType.WILDCARD})
    @Path("/ca")
    void getCA(@Context HttpServletResponse response) throws Exception;

    @POST
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces({MediaType.APPLICATION_JSON})
    @Path("/authenticate")
    Response authenticate(LoginBean loginBean);

    @POST
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces({ContentType.APPLE_ASPEN_CONFIG})
    @Path("/enroll")
    Response getMobileConfigurations(LoginBean loginBean);

    @GET
    @Path("/enrolled")
    Response isEnrolled(@QueryParam("deviceid") String deviceId);

    @POST
    @Produces({ContentType.APPLE_ASPEN_CONFIG, MediaType.APPLICATION_JSON})
    @Consumes({MediaType.WILDCARD})
    @Path("/profile")
    Response getProfileRequest(InputStream inputStream);

    @GET
    @Path("/scep")
    Response scepRequest(@QueryParam("operation") String operation, @QueryParam("message") String message);

    @POST
    @Consumes({ContentType.X_PKI_MESSAGE})
    @Path("/scep")
    Response scepRequestPost(@QueryParam("operation") String operation, InputStream inputStream);

    @PUT
    @Produces({MediaType.WILDCARD})
    @Consumes({MediaType.WILDCARD})
    @Path("/checkin")
    Response checkInRequest(InputStream inputStream);

    @PUT
    @Produces({MediaType.WILDCARD})
    @Consumes({MediaType.WILDCARD})
    @Path("/server")
    Response serverRequest(@Context HttpServletRequest request, InputStream inputStream) throws CMSException;

    @GET
    @Path("/license")
    @Produces({MediaType.APPLICATION_JSON})
    @Consumes({MediaType.WILDCARD})
    License getLicense();
}
