/*
 * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
 *
 * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin;


import io.swagger.annotations.*;
import io.entgra.device.mgt.core.apimgt.annotations.Scope;
import io.entgra.device.mgt.core.apimgt.annotations.Scopes;
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse;
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

@SwaggerDefinition(
        info = @Info(
                version = "1.0.0",
                title = "",
                extensions = {
                        @Extension(properties = {
                                @ExtensionProperty(name = "name", value = "DeviceAnalyticsArtifactUploaderAdminService"),
                                @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/publish-artifact"),
                        })
                }
        ),
        tags = {
                @Tag(name = "device_management", description = "")
        }
)
@Path("/admin/publish-artifact")
@Api(value = "Devicetype deployment Administrative Service", description = "This an  API intended to be used to " +
        "deploy device type components" +
        "Further, this is strictly restricted to admin users only ")
@Scopes(
        scopes = {
                @Scope(
                        name = "Devicetype deployment",
                        description = "Deploy devicetype",
                        key = "dm:device-type:deploy",
                        roles = {"Internal/devicemgt-admin"},
                        permissions = {"/device-mgt/devicetype/deploy"}
                )
        }
)

public interface DeviceAnalyticsArtifactUploaderAdminService {

    @POST
    @Path("/deploy/{type}")
    @ApiOperation(
            httpMethod = "POST",
            value = "Deploy device type\n",
            notes = "This is an API that can be used to deploy existing device type artifact for tenant",
            response = Response.class,
            tags = "Devicetype Deployment Service",
            extensions = {
                    @Extension(properties = {
                            @ExtensionProperty(name = Constants.SCOPE, value = "dm:device-type:deploy")
                    })
            })

    @ApiResponses(value = {
            @ApiResponse(
                    code = 201,
                    message = "OK. \n  Successfully deployed the artifacts.",
                    response = Response.class),
            @ApiResponse(
                    code = 400,
                    message = "Bad Request. \n Invalid request or validation error.",
                    response = ErrorResponse.class),
            @ApiResponse(
                    code = 404,
                    message = "Not Found. \n The specified resource does not exist."),
            @ApiResponse(
                    code = 415,
                    message = "Unsupported media type. \n The entity of the request was in a not supported format."),
            @ApiResponse(
                    code = 500,
                    message = "Internal Server Error. \n Server error occurred while checking the authorization" +
                            " for a specified set of devices.",
                    response = ErrorResponse.class)
    })

    Response doPublish(
            @ApiParam(name = "type",
                value = "The type of deployment." +
                    "INFO: Deploy artifact with given type.",
                required = true)
           @PathParam("type") String type);

}
