diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java index 348a9008d..e09fd22ff 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java @@ -16,9 +16,14 @@ * under the License. */ + package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; -import org.wso2.carbon.apimgt.annotations.api.API; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; @@ -27,7 +32,21 @@ import javax.ws.rs.*; import javax.ws.rs.core.Response; @DeviceType(value = "android_sense") -@API(name = "android_sense", version = "1.0.0", context = "/android_sense", tags = {"android_sense"}) +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "android_sense"), + @ExtensionProperty(name = "context", value = "/android_sense"), + }) + } + ), + tags = { + @Tag(name = "android_sense", description = "") + } +) public interface AndroidSenseService { /** diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java index 9e0c97ec3..97cf4ad1f 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java @@ -18,7 +18,12 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl; -import org.wso2.carbon.apimgt.annotations.api.API; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; + import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; @@ -26,7 +31,21 @@ import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; import javax.ws.rs.*; import javax.ws.rs.core.Response; -@API(name = "arduino", version = "1.0.0", context = "/arduino", tags = {"arduino"}) +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "arduino"), + @ExtensionProperty(name = "context", value = "/arduino"), + }) + } + ), + tags = { + @Tag(name = "arduino", description = "") + } +) @DeviceType(value = "arduino") public interface ArduinoService { diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java index 00236ddbe..757e6ff56 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java @@ -18,7 +18,11 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl; -import org.wso2.carbon.apimgt.annotations.api.API; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; @@ -27,7 +31,21 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@API(name = "raspberrypi", version = "1.0.0", context = "/raspberrypi", tags = {"raspberrypi"}) +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "raspberrypi"), + @ExtensionProperty(name = "context", value = "/raspberrypi"), + }) + } + ), + tags = { + @Tag(name = "raspberrypi", description = "") + } +) @DeviceType(value = "raspberrypi") public interface RaspberryPiService { diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java index 9d89050fb..faf40c962 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java @@ -18,7 +18,11 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl; -import org.wso2.carbon.apimgt.annotations.api.API; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; @@ -33,7 +37,21 @@ import javax.ws.rs.core.Response; * the transport 'Connectors' [XMPP & MQTT] specific to the VirtualFirealarm device-type in order to communicate with * such devices and to receive messages form it. */ -@API(name = "virtual_firealarm", version = "1.0.0", context = "/virtual_firealarm", tags = {"virtual_firealarm"}) +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "virtual_firealarm"), + @ExtensionProperty(name = "context", value = "/virtual_firealarm"), + }) + } + ), + tags = { + @Tag(name = "virtual_firealarm", description = "") + } +) @DeviceType(value = "virtual_firealarm") public interface VirtualFireAlarmService { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java index 773d5645f..e24f6fbfa 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java @@ -18,10 +18,19 @@ */ package org.wso2.carbon.mdm.services.android.services; -import io.swagger.annotations.*; -import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; -import org.wso2.carbon.apimgt.annotations.api.Scope; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; +import io.swagger.annotations.Api; +import io.swagger.annotations.AuthorizationScope; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ResponseHeader; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.mdm.services.android.bean.wrapper.*; @@ -34,10 +43,23 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; -@API(name = "Android Device Management Administrative Service", version = "1.0.0", - context = "/api/device-mgt/android/v1.0/admin/devices", - tags = {"devicemgt_android"}) - +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", + value = "Android Device Management Administrative Service"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/android/v1.0/admin/devices"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_android", description = "") + } +) @Path("/admin/devices") @Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.") @Produces(MediaType.APPLICATION_JSON) @@ -53,7 +75,15 @@ public interface DeviceManagementAdminService { notes = "Using this API you have the option of hard locking an Android device, where the Administrator " + "permanently locks the device or screen locking an Android device.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/lock", + description = "Lock Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -93,7 +123,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while locking the device.") }) - @Permission(name = "Lock Device", permission = "/device-mgt/devices/owning-device/operations/android/lock") Response configureDeviceLock( @ApiParam( name = "deviceLock", @@ -112,7 +141,16 @@ public interface DeviceManagementAdminService { responseContainer = "List", notes = "Unlock devices that were locked permanently using the hard lock operation. Devices that are hard locked can only be unlocked by the EMM administrator.", response = Activity.class, - tags = "Android Device Management Administrative Service") + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/unlock", + description = "Unlock Device") } + ) + } + ) @ApiResponses(value = { @ApiResponse( code = 201, @@ -151,7 +189,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while unlocking the device.") }) - @Permission(name = "Unlock Device", permission = "/device-mgt/devices/owning-device/operations/android/unlock") Response configureDeviceUnlock( @ApiParam( name = "deviceIDs", @@ -170,7 +207,16 @@ public interface DeviceManagementAdminService { notes = "Request location coordinates of Android devices. \n" + "Example: In situations where you have lost your device and need to find out where it is, you can use this REST API to get the location of the device.", response = Activity.class, - tags = "Android Device Management Administrative Service") + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/location", + description = "Get Device Location") } + ) + } + ) @ApiResponses(value = { @ApiResponse( code = 201, @@ -208,7 +254,6 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a new get-location operation.")}) - @Permission(name = "Get Device Location", permission = "/device-mgt/devices/owning-device/operations/android/location") Response getDeviceLocation( @ApiParam( name = "deviceIDs", @@ -224,7 +269,15 @@ public interface DeviceManagementAdminService { value = "Clearing the Password on Android Devices", notes = "Clear the password on Android devices", response = Activity.class, - tags = "Android Device Management Administrative Service." + tags = "Android Device Management Administrative Service.", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/clear-password", + description = "Clear Password of Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -264,7 +317,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new clear password operation.") }) - @Permission(name = "Clear Password of Device", permission = "/device-mgt/devices/owning-device/operations/android/clear-password") Response removePassword( @ApiParam(name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", @@ -278,7 +330,13 @@ public interface DeviceManagementAdminService { value = "Enabling or Disabling the Camera on Android Devices", notes = "Enable or disable the camera on Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/operations/android/camera", description = "Manage Camera") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -318,7 +376,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding the new camera control operation.") }) - @Permission(name = "Manage Camera", permission = "/device-mgt/devices/owning-device/operations/android/camera") Response configureCamera( @ApiParam( name = "cameraControl", @@ -340,7 +397,15 @@ public interface DeviceManagementAdminService { " executed it will be in the Android operation queue until the device calls the server to retrieve " + "the list of operations that needs to be executed on the device", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/info", + description = "Get Device Information") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -380,7 +445,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device info operation.") }) - @Permission(name = "Get Device Information", permission = "/device-mgt/devices/owning-device/operations/android/info") Response getDeviceInformation( @ApiParam( name = "deviceIds", @@ -399,7 +463,15 @@ public interface DeviceManagementAdminService { " executed it will be in the Android operation queue until the device calls the server to retrieve " + "the list of operations that needs to be executed on the device.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/logcat", + description = "Get Logs") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -439,7 +511,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device logcat operation.") }) - @Permission(name = "Get Logs", permission = "/device-mgt/devices/owning-device/operations/android/logcat") Response getDeviceLogcat( @ApiParam( name = "deviceIds", @@ -457,7 +528,15 @@ public interface DeviceManagementAdminService { notes = "Enterprise wipe is the process of deleting enterprise related data on a device while keeping the " + "personal data intact. You are able to enterprise wipe Android devices using this REST API.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/enterprise-wipe", + description = "Enterprise Wipe") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -496,7 +575,6 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding the enterprise wipe operation.")}) - @Permission(name = "Enterprise Wipe", permission = "/device-mgt/devices/owning-device/operations/android/enterprise-wipe") Response wipeDevice( @ApiParam( name = "deviceIDs", @@ -513,7 +591,15 @@ public interface DeviceManagementAdminService { notes = "Factory rest or erase all the data stored on the Android devices " + "to restore them back to the original system.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/wipe", + description = "Factory Reset") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -552,7 +638,6 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding the device wipe operation.")}) - @Permission(name = "Factory Reset", permission = "/device-mgt/devices/owning-device/operations/android/wipe") Response wipeData( @ApiParam( name = "wipeData", @@ -573,7 +658,15 @@ public interface DeviceManagementAdminService { "until the device calls the server to retrieve the list of operations that needs to be executed " + "on the device.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/applications", + description = "Get Installed Application") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -613,7 +706,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding the new get-applications operation.") }) - @Permission(name = "Get Installed Application", permission = "/device-mgt/devices/owning-device/operations/android/applications") Response getApplications( @ApiParam( name = "deviceIDs", @@ -629,7 +721,15 @@ public interface DeviceManagementAdminService { value = "Ringing Android Devices", notes = "Ring Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/ring", + description = "Ring Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -669,7 +769,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device ring operation.") }) - @Permission(name = "Ring Device", permission = "/device-mgt/devices/owning-device/operations/android/ring") Response ringDevice( @ApiParam( name = "deviceIDs", @@ -685,7 +784,15 @@ public interface DeviceManagementAdminService { value = "Rebooting Android Devices", notes = "Reboot or restart your Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/reboot", + description = "Reboot Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -725,7 +832,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding the new device reboot operation.") }) - @Permission(name = "Reboot Device", permission = "/device-mgt/devices/owning-device/operations/android/reboot") Response rebootDevice( @ApiParam( name = "deviceIDs", @@ -740,7 +846,15 @@ public interface DeviceManagementAdminService { value = "Muting Android Devices", notes = "Mute or enable a silent profile for Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/mute", + description = "Mute Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -781,7 +895,6 @@ public interface DeviceManagementAdminService { "Server error occurred while adding a new device mute operation.") }) @Path("/mute") - @Permission(name = "Mute Device", permission = "/device-mgt/devices/owning-device/operations/android/mute") Response muteDevice( @ApiParam( name = "deviceIDs", @@ -799,7 +912,15 @@ public interface DeviceManagementAdminService { notes = "Install an application on an Android device. If the device you are installing the application has the WSO2 system service application installed," + " the application installation will happen in silent mode, else the device user's consent will be required.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/install-app", + description = "Install Applications") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -839,7 +960,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new install-application operation.") }) - @Permission(name = "Install Applications", permission = "/device-mgt/devices/owning-device/operations/android/install-app") Response installApplication( @ApiParam( name = "applicationInstallation", @@ -860,7 +980,15 @@ public interface DeviceManagementAdminService { " has the WSO2 system service application installed, the application update will happen in silent " + "mode, else the device user's consent is required.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/update-app", + description = "Update installed applications") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -900,7 +1028,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding the new update-application operation.") }) - @Permission(name = "Update installed applications", permission = "/device-mgt/devices/owning-device/operations/android/update-app") Response updateApplication( @ApiParam( name = "applicationUpdate", @@ -918,7 +1045,15 @@ public interface DeviceManagementAdminService { value = "Uninstalling an Application from Android Devices", notes = "Uninstall an application from Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/uninstall-app", + description = "Uninstall Applications") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -958,7 +1093,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new uninstall-application operation.") }) - @Permission(name = "Uninstall Applications", permission = "/device-mgt/devices/owning-device/operations/android/uninstall-app") Response uninstallApplication( @ApiParam( name = "applicationUninstallation", @@ -980,7 +1114,15 @@ public interface DeviceManagementAdminService { " Android operating systems and after, the blacklisted apps will be hidden. Blacklisting can be used on both BYOD and " + "COPE devices. Applications can be blacklisted via the application restriction policy too.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/blacklist-app", + description = "Blacklist Applications") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1020,7 +1162,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding the new blacklist-applications operation.") }) - @Permission(name = "Blacklist Applications", permission = "/device-mgt/devices/owning-device/operations/android/blacklist-app") Response blacklistApplications( @ApiParam( name = "blacklistApplications", @@ -1038,7 +1179,15 @@ public interface DeviceManagementAdminService { value = "UUpgrading Firmware of Android Devices", notes = "Upgrade the firmware of Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/upgrade", + description = "Upgrade Firmware") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1078,7 +1227,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new upgrade firmware operation.") }) - @Permission(name = "Upgrade Firmware", permission = "/device-mgt/devices/owning-device/operations/android/upgrade") Response upgradeFirmware( @ApiParam( name = "upgradeFirmware", @@ -1098,7 +1246,15 @@ public interface DeviceManagementAdminService { value = "Configuring VPN on Android devices", notes = "Configure VPN on Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/vpn", + description = "Add VPN") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1138,7 +1294,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while configuring the VPN.") }) - @Permission(name = "Add VPN", permission = "/device-mgt/devices/owning-device/operations/android/vpn") Response configureVPN( @ApiParam( name = "vpnBean", @@ -1154,7 +1309,15 @@ public interface DeviceManagementAdminService { value = "Sending a Notification to Android Devices", notes = "Send a notification or message to Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/send-notification", + description = "Send Notifications") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1194,7 +1357,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new send notification operation.") }) - @Permission(name = "Send Notifications", permission = "/device-mgt/devices/owning-device/operations/android/send-notification") Response sendNotification( @ApiParam( name = "notification", @@ -1211,7 +1373,15 @@ public interface DeviceManagementAdminService { value = "Configuring Wi-Fi on Android Devices", notes = "Configure Wi-Fi on Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/wifi", + description = "Add Wifi Configuration") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1251,7 +1421,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while configuring Wi-Fi.") }) - @Permission(name = "Add Wifi Configuration", permission = "/device-mgt/devices/owning-device/operations/android/wifi") Response configureWifi( @ApiParam( name = "wifi", @@ -1269,7 +1438,15 @@ public interface DeviceManagementAdminService { value = "Encrypting Storage on Android Devices", notes = "Encrypt the data stored on Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/encrypt", + description = "Encrypt Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1309,7 +1486,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new encrypt storage operation.") }) - @Permission(name = "Encrypt Device", permission = "/device-mgt/devices/owning-device/operations/android/encrypt") Response encryptStorage( @ApiParam( name = "encryption", @@ -1327,7 +1503,15 @@ public interface DeviceManagementAdminService { value = "Changing the Lock Code on Android Devices", notes = "Change the lock code on Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/change-lock-code", + description = "Change Password of Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1367,7 +1551,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new change lock code operation.") }) - @Permission(name = "Change Password of Device", permission = "/device-mgt/devices/owning-device/operations/android/change-lock-code") Response changeLockCode( @ApiParam( name = "lockCode", @@ -1385,7 +1568,15 @@ public interface DeviceManagementAdminService { value = "Setting a Password Policy on Android Devices", notes = "Set a password policy on Android devices.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/password-policy", + description = "Set Password Policy") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1425,7 +1616,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new set password policy operation.") }) - @Permission(name = "Set Password Policy", permission = "/device-mgt/devices/owning-device/operations/android/password-policy") Response setPasswordPolicy( @ApiParam( name = "passwordPolicy", @@ -1441,7 +1631,15 @@ public interface DeviceManagementAdminService { value = "Setting a Web Clip on Android Devices", notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application.", response = Activity.class, - tags = "Android Device Management Administrative Service" + tags = "Android Device Management Administrative Service", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/android/webclip", + description = "Add Webclips") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -1481,7 +1679,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding adding a the set web clip operation.") }) - @Permission(name = "Add Webclips", permission = "/device-mgt/devices/owning-device/operations/android/webclip") Response setWebClip( @ApiParam( name = "webClip", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index 04d4098b5..5bf5fef24 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -18,9 +18,20 @@ */ package org.wso2.carbon.mdm.services.android.services; -import io.swagger.annotations.*; -import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; +import io.swagger.annotations.Api; +import io.swagger.annotations.AuthorizationScope; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ResponseHeader; + import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; @@ -34,10 +45,21 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; -@API(name = "Android Device Management", version = "1.0.0", - context = "/api/device-mgt/android/v1.0/devices", - tags = {"devicemgt_android"}) - +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Android Device Management"), + @ExtensionProperty(name = "context", value = "/api/device-mgt/android/v1.0/devices"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_android", description = "") + } +) @Api(value = "Android Device Management", description = "This carries all the resources related to the Android device management functionalities.") @Path("/devices") @@ -53,7 +75,14 @@ public interface DeviceManagementService { httpMethod = "PUT", value = "Updating the Application Details on Android Devices", notes = "Update the details of the applications that are installed on Android devices.", - tags = "Android Device Management" + tags = "Android Device Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Enroll Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -88,7 +117,6 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the application list.") }) - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android") Response updateApplicationList( @ApiParam( name = "id", @@ -114,7 +142,15 @@ public interface DeviceManagementService { " While getting the pending operations the details of the operations executed at the device end is shared with the server. " + "The server then updates the status of the operations that were carried out on the device.", response = Operation.class, - tags = "Android Device Management") + tags = "Android Device Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Enroll Device") } + ) + } + ) @ApiResponses(value = { @ApiResponse( code = 200, @@ -144,7 +180,6 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the list of pending operations.") }) - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android") Response getPendingOperations( @ApiParam( name = "id", @@ -173,7 +208,14 @@ public interface DeviceManagementService { " the Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," + " you can use this REST API to register an Android device with WSO2 EMM, without having to install" + " an Android Agent. This API can be mainly used to test the device enrollment process.", - tags = "Android Device Management" + tags = "Android Device Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Enroll Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -212,7 +254,6 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device.") }) - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android") Response enrollDevice(@ApiParam( name = "device", value = "The properties required to enroll a device.") @@ -224,7 +265,14 @@ public interface DeviceManagementService { httpMethod = "GET", value = "Getting the Registration Status of an Android Device", notes = "Use this REST API to retrieve the registration status of an Android device.", - tags = "Android Device Management" + tags = "Android Device Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Enroll Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -253,7 +301,6 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the enrollment status of the Android device.") }) - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android") Response isEnrolled( @ApiParam( name = "id", @@ -273,7 +320,14 @@ public interface DeviceManagementService { httpMethod = "PUT", value = "Updating the Registration Details of an Android Device", notes = "Use this REST API to update the registration details of an Android device.", - tags = "Android Device Management" + tags = "Android Device Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Enroll Device") } + ) + } ) @ApiResponses( value = { @@ -309,7 +363,6 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the device enrollment.") }) - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android") Response modifyEnrollment( @ApiParam( name = "id", @@ -325,7 +378,13 @@ public interface DeviceManagementService { httpMethod = "DELETE", value = "Unregistering an Android Device", notes = "Use this REST API to unregister an Android device.", - tags = "Android Device Management" + tags = "Android Device Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/disenroll/android", description = "Disenroll Device") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -339,7 +398,6 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while dis-enrolling the device.") }) - @Permission(name = "Disenroll Device", permission = "/device-mgt/devices/disenroll/android") Response disEnrollDevice( @ApiParam( name = "id", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java index 051146d03..3eab30e35 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java @@ -18,9 +18,19 @@ */ package org.wso2.carbon.mdm.services.android.services; -import io.swagger.annotations.*; -import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; +import io.swagger.annotations.Api; +import io.swagger.annotations.AuthorizationScope; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ResponseHeader; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; @@ -30,10 +40,23 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@API(name = "Android Configuration Management", version = "1.0.0", - context = "/api/device-mgt/android/v1.0/configuration", - tags = {"devicemgt_android"}) - +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", + value = "Android Configuration Management"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/android/v1.0/configuration"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_android", description = "") + } +) @Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.") @Path("/configuration") @Produces(MediaType.APPLICATION_JSON) @@ -47,7 +70,14 @@ public interface DeviceTypeConfigurationService { value = "Getting Android Platform Configurations", notes = "Get the Android platform configuration details using this REST API.", response = PlatformConfiguration.class, - tags = "Android Configuration Management" + tags = "Android Configuration Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/view", + description = "View Configurations") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -80,7 +110,6 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the Android platform configuration.") }) - @Permission(name = "View Configurations", permission = "/device-mgt/platform-configurations/view") Response getConfiguration( @ApiParam( name = "If-Modified-Since", @@ -97,7 +126,14 @@ public interface DeviceTypeConfigurationService { httpMethod = "PUT", value = "Updating Android Platform Configurations", notes = "Update the Android platform configurations using this REST API.", - tags = "Android Configuration Management" + tags = "Android Configuration Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/manage", + description = "Manage Configurations") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -132,7 +168,6 @@ public interface DeviceTypeConfigurationService { message = "Internal Server Error. \n " + "Server error occurred while modifying the Android platform configuration.") }) - @Permission(name = "Manage Configurations", permission = "/device-mgt/platform-configurations/manage") Response updateConfiguration( @ApiParam(name = "configuration", value = "The properties to update the Android platform configurations.") @@ -148,7 +183,15 @@ public interface DeviceTypeConfigurationService { notes = "Use this REST API to retrieve the license agreement that is used for the Android device " + "registration process.", response = String.class, - tags = "Android Configuration Management") + tags = "Android Configuration Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Enroll Device") } + ) + } + ) @ApiResponses(value = { @ApiResponse( code = 200, @@ -180,7 +223,6 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the Android license configuration.") }) - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/android") Response getLicense( @ApiParam( name = "If-Modified-Since", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java index c37cc5191..744655768 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java @@ -18,10 +18,19 @@ */ package org.wso2.carbon.mdm.services.android.services; -import io.swagger.annotations.*; -import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; -import org.wso2.carbon.apimgt.annotations.api.Scope; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; +import io.swagger.annotations.Api; +import io.swagger.annotations.AuthorizationScope; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ResponseHeader; import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; @@ -31,10 +40,21 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@API(name = "Android Event Receiver", version = "1.0.0", - context = "/api/device-mgt/android/v1.0/events", - tags = {"devicemgt_android"}) - +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Android Event Receiver"), + @ExtensionProperty(name = "context", value = "/api/device-mgt/android/v1.0/events"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_android", description = "") + } +) @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" + " configure WSO2 EMM as explained in https://docs.wso2.com/display/EMM220/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " + "https://docs.wso2.com/display/EMM220/Creating+a+New+Event+Stream+and+Receiver") @@ -51,7 +71,14 @@ public interface EventReceiverService { httpMethod = "POST", value = "Publishing Events", notes = "Publish events received by the WSO2 EMM Android client to the WSO2 Data Analytics Server (DAS) using this API.", - tags = "Event Receiver" + tags = "Event Receiver", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Publish Events to DAS") } + ) + } ) @ApiResponses( value = { @@ -91,7 +118,6 @@ public interface EventReceiverService { message = "Internal Server Error. \n " + "Server error occurred while publishing events.") }) - @Permission(name = "Publish Events to DAS", permission = "/device-mgt/devices/enroll/android") Response publishEvents( @ApiParam( name = "eventBeanWrapper", @@ -110,7 +136,14 @@ public interface EventReceiverService { "(This cannot be combined with the to and from parameters).", response = DeviceState.class, responseContainer = "List", - tags = "Event Receiver" + tags = "Event Receiver", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", + description = "Publish Events to DAS") } + ) + } ) @ApiResponses( value = { @@ -140,7 +173,6 @@ public interface EventReceiverService { code = 500, message = "Error occurred while getting the published events for the specified device.") }) - @Permission(name = "Publish Events to DAS", permission = "/device-mgt/devices/enroll/android") Response retrieveAlerts( @ApiParam( name = "id", diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java index 076c56bc4..ab4c2574b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java @@ -18,9 +18,20 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; -import io.swagger.annotations.*; -import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; +import io.swagger.annotations.Api; +import io.swagger.annotations.AuthorizationScope; +import io.swagger.annotations.Authorization; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.ResponseHeader; + import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message; @@ -34,9 +45,23 @@ import javax.ws.rs.core.Response; * Windows Platform Configuration REST-API implementation. * All end points supports JSON, XMl with content negotiation. */ -@API(name = "Windows Configuration Management", version = "1.0.0", - context = "/api/device-mgt/windows/v1.0/services/configuration", - tags = {"windows"}) + +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows Configuration Management"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/services/configuration"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) @Api(value = "Windows Configuration Management", description = "This carries all the resources related to Windows configurations management functionalities") @WebService @@ -52,7 +77,14 @@ public interface ConfigurationMgtService { value = "Getting Windows Platform Configurations", notes = "Get the Windows platform configuration details using this REST API.", response = PlatformConfiguration.class, - tags = "Windows Configuration Management" + tags = "Windows Configuration Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/view", + description = "View Configurations") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -85,7 +117,6 @@ public interface ConfigurationMgtService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the Windows platform configuration.") }) - @Permission(name = "View Configurations", permission = "/device-mgt/platform-configurations/view") PlatformConfiguration getConfiguration() throws WindowsConfigurationException; /** @@ -102,7 +133,14 @@ public interface ConfigurationMgtService { httpMethod = "PUT", value = "Updating Windows Platform Configurations", notes = "Update the Windows platform configurations using this REST API.", - tags = "Windows Configuration Management" + tags = "Windows Configuration Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/configurations/manage", + description = "Manage Configurations") } + ) + } ) @ApiResponses(value = { @ApiResponse( @@ -137,7 +175,6 @@ public interface ConfigurationMgtService { message = "Internal Server Error. \n " + "Server error occurred while modifying the Windows platform configurations.") }) - @Permission(name = "Manage Configurations", permission = "/device-mgt/configurations/manage") Message updateConfiguration ( @ApiParam( name = "configuration", @@ -154,7 +191,15 @@ public interface ConfigurationMgtService { notes = "Use this REST API to retrieve the license agreement that is used for the Windows device " + "registration process.", response = String.class, - tags = "Windows Configuration Management") + tags = "Windows Configuration Management", + authorizations = { + @Authorization( + value="permission", + scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", + description = "Enroll Device") } + ) + } + ) @ApiResponses(value = { @ApiResponse( code = 200, @@ -186,7 +231,6 @@ public interface ConfigurationMgtService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the Windows license configuration.") }) - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/windows") Response getLicense( @ApiParam( name = "If-Modified-Since", diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index 5cfa31fd4..5e325938c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -18,8 +18,12 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; import io.swagger.annotations.Api; -import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; @@ -38,9 +42,24 @@ import java.util.List; */ @Api(value = "Windows Device Management Administrative Service", description = "Device management related admin APIs.") -@API(name = "Windows Device Management Administrative Service", version = "1.0.0", - context = "/api/device-mgt/windows/v1.0/admin/devices", - tags = {"devicemgt_windows"}) + +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", + value = "Windows Device Management Administrative Service"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/admin/devices"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) @WebService @Path("/admin/devices") @Consumes(MediaType.APPLICATION_JSON) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index 8734124df..63d046860 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -18,8 +18,12 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Info; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Extension; +import io.swagger.annotations.Tag; import io.swagger.annotations.Api; -import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; @@ -40,9 +44,22 @@ import java.util.List; */ @Api(value = "Windows Device Management", description = "This carries all the resources related to Windows device management functionalities") -@API(name = "Windows Device Management", version = "1.0.0", - context = "/api/device-mgt/windows/v1.0/devices", - tags = {"devicemgt_windows"}) + +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows Device Management"), + @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/devices"), + }) + } + ), + tags = { + @Tag(name = "devicemgt_windows", description = "") + } +) @WebService @Path("/devices") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})