From 74c4f1004af175297feddb149aad76d24fed0636 Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Tue, 16 Mar 2021 14:39:02 +0530 Subject: [PATCH 01/49] Device search in store uninstall modal --- .../common/services/SubscriptionManager.java | 6 ++-- .../core/impl/SubscriptionManagerImpl.java | 15 ++++---- .../services/SubscriptionManagementAPI.java | 23 ++++++++++++ .../impl/SubscriptionManagementAPIImpl.java | 17 +++++++-- .../carbon/device/mgt/core/dao/DeviceDAO.java | 13 ++++--- .../dao/impl/device/GenericDeviceDAOImpl.java | 36 ++++++++++++++++--- .../dao/impl/device/OracleDeviceDAOImpl.java | 34 ++++++++++++++++-- .../impl/device/PostgreSQLDeviceDAOImpl.java | 34 ++++++++++++++++-- .../impl/device/SQLServerDeviceDAOImpl.java | 32 +++++++++++++++-- .../DeviceManagementProviderService.java | 9 +++-- .../DeviceManagementProviderServiceImpl.java | 6 ++-- 11 files changed, 183 insertions(+), 42 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java index 9d9e94c183..c1c0155087 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java @@ -22,6 +22,7 @@ import org.wso2.carbon.device.application.mgt.common.dto.ScheduledSubscriptionDT import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.SubscriptionManagementException; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; import java.util.List; @@ -127,13 +128,12 @@ public interface SubscriptionManager { * This method used to get the app id ,device ids and pass them to DM service method. * * @param appUUID UUID of the application release. - * @param offsetValue offset value for get paginated request. - * @param limitValue limit value for get paginated request. + * @param request paginated request object. * @param status status of the devices. * @return deviceDetails - device details for given application release. * @throws {@link ApplicationManagementException} Exception of the application management */ - PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID, + PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID, List status) throws ApplicationManagementException; /*** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 19008cbb0d..c81b4aa125 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -65,10 +65,7 @@ import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.HelperUtil; import org.wso2.carbon.device.application.mgt.core.util.OAuthUtils; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.MDMAppConstants; +import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.app.mgt.App; import org.wso2.carbon.device.mgt.common.app.mgt.MobileAppTypes; import org.wso2.carbon.device.mgt.common.app.mgt.android.CustomApplication; @@ -88,7 +85,6 @@ import org.wso2.carbon.device.mgt.core.util.MDMIOSOperationUtil; import org.wso2.carbon.device.mgt.core.util.MDMWindowsOperationUtil; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.device.mgt.common.PaginationResult; import javax.ws.rs.core.MediaType; import java.io.BufferedReader; @@ -1223,7 +1219,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID, List status) + public PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID, List status) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); DeviceManagementProviderService deviceManagementProviderService = HelperUtil @@ -1262,8 +1258,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } //pass the device id list to device manager service method try { - PaginationResult deviceDetails = deviceManagementProviderService - .getAppSubscribedDevices(offsetValue, limitValue, deviceIdList, status); + PaginationResult deviceDetails = deviceManagementProviderService.getAppSubscribedDevices + (request, deviceIdList, status); if (deviceDetails == null) { String msg = "Couldn't found an subscribed devices details for device ids: " + deviceIdList; @@ -1344,6 +1340,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { @Override public PaginationResult getAppSubscriptionDetails(int offsetValue, int limitValue, String appUUID) throws ApplicationManagementException { + PaginationRequest request = new PaginationRequest(offsetValue, limitValue); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); DeviceManagementProviderService deviceManagementProviderService = HelperUtil .getDeviceManagementProviderService(); @@ -1378,7 +1375,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { try { //pass the device id list to device manager service method PaginationResult paginationResult = deviceManagementProviderService - .getAppSubscribedDevices(offsetValue, limitValue, deviceIdList, null); + .getAppSubscribedDevices(request, deviceIdList, null); List deviceSubscriptionDataList = new ArrayList<>(); if (!paginationResult.getData().isEmpty()) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java index 75a4522d68..871066e39b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java @@ -32,6 +32,7 @@ import org.wso2.carbon.device.application.mgt.common.ErrorResponse; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import javax.validation.Valid; +import javax.validation.constraints.Size; import javax.ws.rs.Path; import javax.ws.rs.Consumes; import javax.ws.rs.Produces; @@ -337,6 +338,28 @@ public interface SubscriptionManagementAPI { response = ErrorResponse.class) }) Response getAppInstalledDevices( + @ApiParam( + name = "name", + value = "The device name. For example, Nexus devices can have names, suhc as shamu, bullhead or angler.", + required = false) + @Size(max = 45) + String name, + @ApiParam( + name = "user", + value = "The username of the owner of the device.", + required = false) + @QueryParam("user") + String user, + @ApiParam( + name = "ownership", + allowableValues = "BYOD, COPE", + value = "Provide the ownership status of the device. The following values can be assigned:\n" + + "- BYOD: Bring Your Own Device\n" + + "- COPE: Corporate-Owned, Personally-Enabled", + required = false) + @QueryParam("ownership") + @Size(max = 45) + String ownership, @ApiParam( name="uuid", value="uuid of the application release.", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index 984f689d07..ab7905e1d0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -33,6 +33,7 @@ import org.wso2.carbon.device.application.mgt.common.BasicUserInfo; import org.wso2.carbon.device.application.mgt.common.BasicUserInfoList; import org.wso2.carbon.device.application.mgt.common.RoleList; import org.wso2.carbon.device.application.mgt.common.DeviceGroupList; +import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException; @@ -273,6 +274,9 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ @Produces("application/json") @Path("/{uuid}/devices") public Response getAppInstalledDevices( + @QueryParam("name") String name, + @QueryParam("user") String user, + @QueryParam("ownership") String ownership, @PathParam("uuid") String uuid, @DefaultValue("0") @QueryParam("offset") int offset, @@ -281,8 +285,17 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ @QueryParam("status") List status) { try { SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - PaginationResult subscribedDeviceDetails = subscriptionManager - .getAppInstalledDevices(offset, limit, uuid, status); + PaginationRequest request = new PaginationRequest(offset, limit); + if (name != null && !name.isEmpty()) { + request.setDeviceName(name); + } + if (user != null && !user.isEmpty()) { + request.setOwner(user); + } + if (ownership != null && !ownership.isEmpty()) { + request.setOwnership(ownership); + } + PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid, status); DeviceList devices = new DeviceList(); devices.setList((List) subscribedDeviceDetails.getData()); devices.setCount(subscribedDeviceDetails.getRecordsTotal()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 38ef50a923..620faf898f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -651,16 +651,15 @@ public interface DeviceDAO { /** * This method is used to get the details of subscribed devices. * - * @param deviceIds device ids of the subscribed devices. - * @param tenantId Id of the current tenant. - * @param offsetValue offset value for get paginated request. - * @param limitValue limit value for get paginated request. - * @param status status of the devices. + * @param deviceIds device ids of the subscribed devices. + * @param tenantId Id of the current tenant. + * @param request paginated request object. + * @param status status of the devices. * @return devices - subscribed device details list * @throws DeviceManagementDAOException if connections establishment fails. */ - List getSubscribedDevices(int offsetValue, int limitValue, List deviceIds, - int tenantId, List status) throws DeviceManagementDAOException; + List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, + List status) throws DeviceManagementDAOException; /** * @param deviceIds device ids of the subscribed devices. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 07a2882b3d..f7bbfac380 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -877,16 +877,24 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(int offsetValue, int limitValue, - List deviceIds, int tenantId, List status) + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, + List status) throws DeviceManagementDAOException { Connection conn; - + int limitValue = request.getRowCount(); + int offsetValue = request.getStartIndex(); + String name = request.getDeviceName(); + String user = request.getOwner(); + String ownership = request.getOwnership(); try { conn = this.getConnection(); int index = 1; boolean isStatusProvided = false; + boolean isDeviceNameProvided = false; + boolean isOwnerProvided = false; + boolean isOwnershipProvided = false; + StringJoiner joiner = new StringJoiner(",", "SELECT " + "DM_DEVICE.ID AS DEVICE_ID, " @@ -914,6 +922,18 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); + if (name != null && !name.isEmpty()) { + query += " AND DM_DEVICE.NAME LIKE ?"; + isDeviceNameProvided = true; + } + if (ownership != null && !ownership.isEmpty()) { + query += " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + if (user != null && !user.isEmpty()) { + query += " AND e.OWNER = ?"; + isOwnerProvided = true; + } if (status != null && !status.isEmpty()) { query += buildStatusQuery(status); isStatusProvided = true; @@ -926,8 +946,16 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { for (Integer deviceId : deviceIds) { ps.setObject(index++, deviceId); } - ps.setInt(index++, tenantId); + if (isDeviceNameProvided) { + ps.setString(index++, name + "%"); + } + if (isOwnershipProvided) { + ps.setString(index++, ownership); + } + if (isOwnerProvided) { + ps.setString(index++, user); + } if (isStatusProvided) { for (String deviceStatus : status) { ps.setString(index++, deviceStatus); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index b143136ef9..201a0ba169 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -847,16 +847,23 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(int offsetValue, int limitValue, - List deviceIds, int tenantId, List status) + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, + List status) throws DeviceManagementDAOException { Connection conn; - + int limitValue = request.getRowCount(); + int offsetValue = request.getStartIndex(); + String name = request.getDeviceName(); + String user = request.getOwner(); + String ownership = request.getOwnership(); try { conn = this.getConnection(); int index = 1; boolean isStatusProvided = false; + boolean isDeviceNameProvided = false; + boolean isOwnerProvided = false; + boolean isOwnershipProvided = false; StringJoiner joiner = new StringJoiner(",", "SELECT " + "DM_DEVICE.ID AS DEVICE_ID, " @@ -884,6 +891,18 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); + if (name != null && !name.isEmpty()) { + query += " AND DM_DEVICE.NAME LIKE ?"; + isDeviceNameProvided = true; + } + if (ownership != null && !ownership.isEmpty()) { + query += " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + if (user != null && !user.isEmpty()) { + query += " AND e.OWNER = ?"; + isOwnerProvided = true; + } if (status != null && !status.isEmpty()) { query += buildStatusQuery(status); isStatusProvided = true; @@ -898,6 +917,15 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { } ps.setInt(index++, tenantId); + if (isDeviceNameProvided) { + ps.setString(index++, name + "%"); + } + if (isOwnershipProvided) { + ps.setString(index++, ownership); + } + if (isOwnerProvided) { + ps.setString(index++, user); + } if (isStatusProvided) { for (String deviceStatus : status) { ps.setString(index++, deviceStatus); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 4a7560f9f3..9234ff6f43 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -827,16 +827,23 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(int offsetValue, int limitValue, - List deviceIds, int tenantId, List status) + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, + List status) throws DeviceManagementDAOException { Connection conn; - + int limitValue = request.getRowCount(); + int offsetValue = request.getStartIndex(); + String name = request.getDeviceName(); + String user = request.getOwner(); + String ownership = request.getOwnership(); try { conn = this.getConnection(); int index = 1; boolean isStatusProvided = false; + boolean isDeviceNameProvided = false; + boolean isOwnerProvided = false; + boolean isOwnershipProvided = false; StringJoiner joiner = new StringJoiner(",", "SELECT " + "DM_DEVICE.ID AS DEVICE_ID, " @@ -864,6 +871,18 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); + if (name != null && !name.isEmpty()) { + query += " AND DM_DEVICE.NAME LIKE ?"; + isDeviceNameProvided = true; + } + if (ownership != null && !ownership.isEmpty()) { + query += " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + if (user != null && !user.isEmpty()) { + query += " AND e.OWNER = ?"; + isOwnerProvided = true; + } if (status != null && !status.isEmpty()) { query += buildStatusQuery(status); isStatusProvided = true; @@ -878,6 +897,15 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { } ps.setInt(index++, tenantId); + if (isDeviceNameProvided) { + ps.setString(index++, name + "%"); + } + if (isOwnershipProvided) { + ps.setString(index++, ownership); + } + if (isOwnerProvided) { + ps.setString(index++, user); + } if (isStatusProvided) { for (String deviceStatus : status) { ps.setString(index++, deviceStatus); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 11112c4655..a27191fe32 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -693,16 +693,23 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(int offsetValue, int limitValue, + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, List status) throws DeviceManagementDAOException { Connection conn; - + int limitValue = request.getRowCount(); + int offsetValue = request.getStartIndex(); + String name = request.getDeviceName(); + String user = request.getOwner(); + String ownership = request.getOwnership(); try { conn = this.getConnection(); int index = 1; boolean isStatusProvided = false; + boolean isDeviceNameProvided = false; + boolean isOwnerProvided = false; + boolean isOwnershipProvided = false; StringJoiner joiner = new StringJoiner(",", "SELECT " + "DM_DEVICE.ID AS DEVICE_ID, " @@ -730,6 +737,18 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); + if (name != null && !name.isEmpty()) { + query += " AND DM_DEVICE.NAME LIKE ?"; + isDeviceNameProvided = true; + } + if (ownership != null && !ownership.isEmpty()) { + query += " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + if (user != null && !user.isEmpty()) { + query += " AND e.OWNER = ?"; + isOwnerProvided = true; + } if (status != null && !status.isEmpty()) { query += buildStatusQuery(status); isStatusProvided = true; @@ -744,6 +763,15 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { } ps.setInt(index++, tenantId); + if (isDeviceNameProvided) { + ps.setString(index++, name + "%"); + } + if (isOwnershipProvided) { + ps.setString(index++, ownership); + } + if (isOwnerProvided) { + ps.setString(index++, user); + } if (isStatusProvided) { for (String deviceStatus : status) { ps.setString(index++, deviceStatus); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index fb3dd19527..d5f31c1546 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -905,14 +905,13 @@ public interface DeviceManagementProviderService { * This method retrieves a list of subscribed devices. * * @param devicesIds devices ids of the subscribed devices. - * @param offsetValue offset value for get paginated request. - * @param limitValue limit value for get paginated request. - * @param status status of the devices. + * @param request paginated request object. + * @param status status of the devices. * @return {@link PaginationResult} * @throws DeviceManagementException if any service level or DAO level error occurs. */ - PaginationResult getAppSubscribedDevices(int offsetValue, int limitValue, - List devicesIds, List status) throws DeviceManagementException; + PaginationResult getAppSubscribedDevices(PaginationRequest request, List devicesIds, List status) + throws DeviceManagementException; /** * This method is used to get a list of applications installed in all enrolled devices diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 7456111973..343acf2602 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -4156,9 +4156,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public PaginationResult getAppSubscribedDevices(int offsetValue, int limitValue, List devicesIds, + public PaginationResult getAppSubscribedDevices(PaginationRequest request, List devicesIds, List status) throws DeviceManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); if (log.isDebugEnabled()) { log.debug("Getting all devices details for device ids: " + devicesIds); @@ -4167,8 +4166,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv List subscribedDeviceDetails; try { DeviceManagementDAOFactory.openConnection(); - subscribedDeviceDetails = deviceDAO - .getSubscribedDevices(offsetValue, limitValue, devicesIds, tenantId, status); + subscribedDeviceDetails = deviceDAO.getSubscribedDevices(request, devicesIds, tenantId, status); if (subscribedDeviceDetails.isEmpty()) { paginationResult.setData(new ArrayList<>()); paginationResult.setRecordsFiltered(0); From c2940a4568b55d0003f26b6d87447c92a9ee38a0 Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Wed, 17 Mar 2021 15:25:02 +0530 Subject: [PATCH 02/49] Device search in store subscription details page --- .../common/services/SubscriptionManager.java | 7 +-- .../mgt/core/dao/SubscriptionDAO.java | 2 +- .../GenericSubscriptionDAOImpl.java | 11 +++- .../mgt/core/impl/ApplicationManagerImpl.java | 4 +- .../core/impl/SubscriptionManagerImpl.java | 13 ++--- .../admin/SubscriptionManagementAdminAPI.java | 21 ++++++++ .../impl/SubscriptionManagementAPIImpl.java | 32 ++++++++++++ .../SubscriptionManagementAdminAPIImpl.java | 51 ++++++++++++++++++- 8 files changed, 127 insertions(+), 14 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java index c1c0155087..1073015a73 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java @@ -152,14 +152,15 @@ public interface SubscriptionManager { /** * This method is responsible to provide application subscription data for given application release UUID. * - * @param offsetValue offset - * @param limitValue limit + * @param request paginated request object. + * @param status status of the devices. + * @param actionStatus status of the operation. * @param appUUID application release UUID * @return {@link PaginationResult} * @throws ApplicationManagementException if offset or limit contains incorrect values, if it couldn't find an * application release for given UUID, if an error occurred while getting device details of subscribed device ids, * if an error occurred while getting subscription details of given application release UUID. */ - PaginationResult getAppSubscriptionDetails(int offsetValue, int limitValue, String appUUID) + PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, List status,String actionStatus) throws ApplicationManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java index 4b99420e50..0dbd746912 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java @@ -81,7 +81,7 @@ public interface SubscriptionDAO { void addGroupSubscriptions(int tenantId, String subscribedBy, List groups, int releaseId, String action) throws ApplicationManagementDAOException; - List getDeviceSubscriptions(int appReleaseId, int tenantId) throws + List getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus) throws ApplicationManagementDAOException; Map getDeviceSubscriptions(List deviceIds, int appReleaseId, int tenantId) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 576eec9a6c..96a2746022 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -332,12 +332,13 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public List getDeviceSubscriptions(int appReleaseId, int tenantId) throws + public List getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting device subscriptions for the application release id " + appReleaseId + " from the database"); } + boolean isActionStatusProvided = false; String sql = "SELECT " + "DS.ID AS ID, " + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " @@ -350,11 +351,19 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc + "DS.DM_DEVICE_ID AS DEVICE_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.TENANT_ID=?"; + + if (actionStatus != null && !actionStatus.isEmpty()) { + sql += " AND DS.STATUS= ?"; + isActionStatusProvided = true; + } try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(1, appReleaseId); stmt.setInt(2, tenantId); + if(isActionStatusProvided){ + stmt.setString(3, actionStatus); + } try (ResultSet rs = stmt.executeQuery()) { if (log.isDebugEnabled()) { log.debug("Successfully retrieved device subscriptions for application release id " diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 2cebd98c61..80706aef41 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1445,7 +1445,7 @@ ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ForbiddenException(msg); } - if (!subscriptionDAO.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId).isEmpty()) { + if (!subscriptionDAO.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null).isEmpty()) { String msg = "Application release which has UUID: " + applicationReleaseDTO.getUuid() + " either subscribed to device/s or it had subscribed to device/s. Therefore you are not " + "permitted to delete the application release."; @@ -1580,7 +1580,7 @@ ApplicationManagerImpl implements ApplicationManager { try { ConnectionManagerUtil.beginDBTransaction(); List deviceSubscriptionDTOS = subscriptionDAO - .getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId); + .getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null); if (!deviceSubscriptionDTOS.isEmpty()) { String msg = "Application release which has UUID: " + applicationReleaseDTO.getUuid() + " either subscribed to device/s or it had subscribed to device/s. Therefore you " diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index c81b4aa125..d11fb4090f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -377,7 +377,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (applicationDTO != null) { List deviceSubscriptionDTOS = this.subscriptionDAO .getDeviceSubscriptions(applicationDTO.getApplicationReleaseDTOs().get(0).getId(), - tenantId); + tenantId, null); AtomicBoolean isAppSubscribable = new AtomicBoolean(true); for (DeviceSubscriptionDTO deviceSubscriptionDTO : deviceSubscriptionDTOS) { @@ -1231,7 +1231,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { int applicationReleaseId = applicationDTO.getApplicationReleaseDTOs().get(0).getId(); List deviceSubscriptionDTOS = subscriptionDAO - .getDeviceSubscriptions(applicationReleaseId, tenantId); + .getDeviceSubscriptions(applicationReleaseId, tenantId, null); if (deviceSubscriptionDTOS.isEmpty()) { PaginationResult paginationResult = new PaginationResult(); paginationResult.setData(new ArrayList<>()); @@ -1338,9 +1338,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public PaginationResult getAppSubscriptionDetails(int offsetValue, int limitValue, String appUUID) + public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, List status,String actionStatus) throws ApplicationManagementException { - PaginationRequest request = new PaginationRequest(offsetValue, limitValue); + int limitValue = request.getRowCount(); + int offsetValue = request.getStartIndex(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); DeviceManagementProviderService deviceManagementProviderService = HelperUtil .getDeviceManagementProviderService(); @@ -1362,7 +1363,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { int applicationReleaseId = applicationDTO.getApplicationReleaseDTOs().get(0).getId(); List deviceSubscriptionDTOS = subscriptionDAO - .getDeviceSubscriptions(applicationReleaseId, tenantId); + .getDeviceSubscriptions(applicationReleaseId, tenantId, actionStatus); if (deviceSubscriptionDTOS.isEmpty()) { PaginationResult paginationResult = new PaginationResult(); paginationResult.setData(new ArrayList<>()); @@ -1375,7 +1376,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { try { //pass the device id list to device manager service method PaginationResult paginationResult = deviceManagementProviderService - .getAppSubscribedDevices(request, deviceIdList, null); + .getAppSubscribedDevices(request, deviceIdList, status); List deviceSubscriptionDataList = new ArrayList<>(); if (!paginationResult.getData().isEmpty()) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java index 7c47b1f7cf..2cb9d63b21 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java @@ -31,6 +31,7 @@ import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.application.mgt.common.ErrorResponse; +import javax.validation.constraints.Size; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -111,6 +112,26 @@ public interface SubscriptionManagementAdminAPI { response = ErrorResponse.class) }) Response getAppInstalledDevices( + @ApiParam( + name = "name", + value = "The device name. For example, Nexus devices can have names, suhc as shamu, bullhead or angler.", + required = false) + @Size(max = 45) + String name, + @ApiParam( + name = "user", + value = "The username of the owner of the device.", + required = false) + @QueryParam("user") + String user, + @ApiParam( + name = "actionStatus", + value = "Provide the action status details") + @QueryParam("actionStatus") String actionStatus, + @ApiParam( + name = "status", + value = "Provide the device status details, such as active or inactive.") + @QueryParam("status") List status, @ApiParam( name = "uuid", value = "uuid of the application release.", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index ab7905e1d0..6d13e94a6f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -295,6 +295,38 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ if (ownership != null && !ownership.isEmpty()) { request.setOwnership(ownership); } +// if (status != null && !status.isEmpty()) { +// boolean isStatusEmpty = true; +// for (String statusString : status){ +// if (StringUtils.isNotBlank(statusString)){ +// isStatusEmpty = false; +// break; +// } +// } +// if (!isStatusEmpty) { +// for (String status_ : status) { +// switch (status_) { +// case "ACTIVE": +// case "INACTIVE": +// case "UNCLAIMED": +// case "UNREACHABLE": +// case "SUSPENDED": +// case "DISENROLLMENT_REQUESTED": +// case "REMOVED": +// case "BLOCKED": +// case "CREATED": +// break; +// default: +// String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types are " + +// "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + +// "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; +// log.error(msg); +// return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); +// } +// } +// request.setStatusList(status); +// } +// } PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid, status); DeviceList devices = new DeviceList(); devices.setList((List) subscribedDeviceDetails.getData()); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java index 2462556570..56c7e94646 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java @@ -18,16 +18,21 @@ package org.wso2.carbon.device.application.mgt.store.api.services.impl.admin; +import io.swagger.annotations.ApiParam; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpStatus; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import org.wso2.carbon.device.application.mgt.core.util.APIUtil; import org.wso2.carbon.device.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI; +import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; +import javax.validation.constraints.Size; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -36,6 +41,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; +import java.util.List; /** * Implementation of Subscription Management related APIs. @@ -51,6 +57,10 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen @Produces("application/json") @Path("/{uuid}") public Response getAppInstalledDevices( + @QueryParam("name") String name, + @QueryParam("user") String user, + @QueryParam("actionStatus") String actionStatus, + @QueryParam("status") List status, @PathParam("uuid") String uuid, @DefaultValue("0") @QueryParam("offset") int offset, @@ -58,9 +68,48 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen @QueryParam("limit") int limit) { try { + PaginationRequest request = new PaginationRequest(offset, limit); + if (name != null && !name.isEmpty()) { + request.setDeviceName(name); + } + if (user != null && !user.isEmpty()) { + request.setOwner(user); + } +// if (status != null && !status.isEmpty()) { +// boolean isStatusEmpty = true; +// for (String statusString : status){ +// if (StringUtils.isNotBlank(statusString)){ +// isStatusEmpty = false; +// break; +// } +// } +// if (!isStatusEmpty) { +// for (String status_ : status) { +// switch (status_) { +// case "ACTIVE": +// case "INACTIVE": +// case "UNCLAIMED": +// case "UNREACHABLE": +// case "SUSPENDED": +// case "DISENROLLMENT_REQUESTED": +// case "REMOVED": +// case "BLOCKED": +// case "CREATED": +// break; +// default: +// String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types are " + +// "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + +// "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; +// log.error(msg); +// return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); +// } +// } +// request.setStatusList(status); +// } +// } SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); PaginationResult subscriptionData = subscriptionManager - .getAppSubscriptionDetails(offset, limit, uuid); + .getAppSubscriptionDetails(request, uuid, status, actionStatus); return Response.status(Response.Status.OK).entity(subscriptionData).build(); } catch (NotFoundException e) { String msg = "Application with application release UUID: " + uuid + " is not found"; From 605168e770488c7b7890d63e3fbe772f2f382a48 Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Wed, 17 Mar 2021 18:37:14 +0530 Subject: [PATCH 03/49] Code modified --- .../common/services/SubscriptionManager.java | 6 +- .../core/impl/SubscriptionManagerImpl.java | 10 +-- .../impl/SubscriptionManagementAPIImpl.java | 66 +++++++------- .../SubscriptionManagementAdminAPIImpl.java | 89 ++++++++++++------- .../carbon/device/mgt/core/dao/DeviceDAO.java | 5 +- .../dao/impl/device/GenericDeviceDAOImpl.java | 4 +- .../dao/impl/device/OracleDeviceDAOImpl.java | 4 +- .../impl/device/PostgreSQLDeviceDAOImpl.java | 4 +- .../impl/device/SQLServerDeviceDAOImpl.java | 4 +- .../DeviceManagementProviderService.java | 2 +- .../DeviceManagementProviderServiceImpl.java | 7 +- 11 files changed, 109 insertions(+), 92 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java index 1073015a73..5951433c14 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java @@ -133,8 +133,7 @@ public interface SubscriptionManager { * @return deviceDetails - device details for given application release. * @throws {@link ApplicationManagementException} Exception of the application management */ - PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID, - List status) throws ApplicationManagementException; + PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID) throws ApplicationManagementException; /*** * This method used to get category details. @@ -153,7 +152,6 @@ public interface SubscriptionManager { * This method is responsible to provide application subscription data for given application release UUID. * * @param request paginated request object. - * @param status status of the devices. * @param actionStatus status of the operation. * @param appUUID application release UUID * @return {@link PaginationResult} @@ -161,6 +159,6 @@ public interface SubscriptionManager { * application release for given UUID, if an error occurred while getting device details of subscribed device ids, * if an error occurred while getting subscription details of given application release UUID. */ - PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, List status,String actionStatus) + PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus) throws ApplicationManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index d11fb4090f..94559782b3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1219,7 +1219,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID, List status) + public PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); DeviceManagementProviderService deviceManagementProviderService = HelperUtil @@ -1259,7 +1259,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { //pass the device id list to device manager service method try { PaginationResult deviceDetails = deviceManagementProviderService.getAppSubscribedDevices - (request, deviceIdList, status); + (request, deviceIdList); if (deviceDetails == null) { String msg = "Couldn't found an subscribed devices details for device ids: " + deviceIdList; @@ -1338,7 +1338,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, List status,String actionStatus) + public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus) throws ApplicationManagementException { int limitValue = request.getRowCount(); int offsetValue = request.getStartIndex(); @@ -1375,8 +1375,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { .collect(Collectors.toList()); try { //pass the device id list to device manager service method - PaginationResult paginationResult = deviceManagementProviderService - .getAppSubscribedDevices(request, deviceIdList, status); + PaginationResult paginationResult = deviceManagementProviderService.getAppSubscribedDevices + (request, deviceIdList); List deviceSubscriptionDataList = new ArrayList<>(); if (!paginationResult.getData().isEmpty()) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index 6d13e94a6f..820e6bcd5c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -295,39 +295,39 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ if (ownership != null && !ownership.isEmpty()) { request.setOwnership(ownership); } -// if (status != null && !status.isEmpty()) { -// boolean isStatusEmpty = true; -// for (String statusString : status){ -// if (StringUtils.isNotBlank(statusString)){ -// isStatusEmpty = false; -// break; -// } -// } -// if (!isStatusEmpty) { -// for (String status_ : status) { -// switch (status_) { -// case "ACTIVE": -// case "INACTIVE": -// case "UNCLAIMED": -// case "UNREACHABLE": -// case "SUSPENDED": -// case "DISENROLLMENT_REQUESTED": -// case "REMOVED": -// case "BLOCKED": -// case "CREATED": -// break; -// default: -// String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types are " + -// "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + -// "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; -// log.error(msg); -// return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); -// } -// } -// request.setStatusList(status); -// } -// } - PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid, status); + if (status != null && !status.isEmpty()) { + boolean isStatusEmpty = true; + for (String statusString : status) { + if (StringUtils.isNotBlank(statusString)) { + isStatusEmpty = false; + break; + } + } + if (!isStatusEmpty) { + for (String status_ : status) { + switch (status_) { + case "ACTIVE": + case "INACTIVE": + case "UNCLAIMED": + case "UNREACHABLE": + case "SUSPENDED": + case "DISENROLLMENT_REQUESTED": + case "REMOVED": + case "BLOCKED": + case "CREATED": + break; + default: + String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types are " + + "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + + "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + } + request.setStatusList(status); + } + } + PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid); DeviceList devices = new DeviceList(); devices.setList((List) subscribedDeviceDetails.getData()); devices.setCount(subscribedDeviceDetails.getRecordsTotal()); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java index 56c7e94646..5536fc46d8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java @@ -75,41 +75,62 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen if (user != null && !user.isEmpty()) { request.setOwner(user); } -// if (status != null && !status.isEmpty()) { -// boolean isStatusEmpty = true; -// for (String statusString : status){ -// if (StringUtils.isNotBlank(statusString)){ -// isStatusEmpty = false; -// break; -// } -// } -// if (!isStatusEmpty) { -// for (String status_ : status) { -// switch (status_) { -// case "ACTIVE": -// case "INACTIVE": -// case "UNCLAIMED": -// case "UNREACHABLE": -// case "SUSPENDED": -// case "DISENROLLMENT_REQUESTED": -// case "REMOVED": -// case "BLOCKED": -// case "CREATED": -// break; -// default: -// String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types are " + -// "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + -// "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; -// log.error(msg); -// return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); -// } -// } -// request.setStatusList(status); -// } -// } + if (status != null && !status.isEmpty()) { + boolean isStatusEmpty = true; + for (String statusString : status) { + if (StringUtils.isNotBlank(statusString)) { + isStatusEmpty = false; + break; + } + } + if (!isStatusEmpty) { + for (String status_ : status) { + switch (status_) { + case "ACTIVE": + case "INACTIVE": + case "UNCLAIMED": + case "UNREACHABLE": + case "SUSPENDED": + case "DISENROLLMENT_REQUESTED": + case "REMOVED": + case "BLOCKED": + case "CREATED": + break; + default: + String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types " + + "are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + + "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + } + request.setStatusList(status); + } + } + + if (actionStatus != null && !actionStatus.isEmpty()) { + if (StringUtils.isNotBlank(actionStatus)) { + switch (actionStatus) { + case "PENDING": + case "ERROR": + case "IN_PROGRESS": + case "NOTNOW": + case "COMPLETED": + case "REPEATED": + break; + default: + String msg = "Invalid enrollment action status type: " + actionStatus + ". " + + "\nValid action status types are PENDING | ERROR | IN_PROGRESS | NOTNOW | " + + "COMPLETED | REPEATED"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + } + } + SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); - PaginationResult subscriptionData = subscriptionManager - .getAppSubscriptionDetails(request, uuid, status, actionStatus); + PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails + (request, uuid, actionStatus); return Response.status(Response.Status.OK).entity(subscriptionData).build(); } catch (NotFoundException e) { String msg = "Application with application release UUID: " + uuid + " is not found"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 620faf898f..82aded2490 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -654,12 +654,11 @@ public interface DeviceDAO { * @param deviceIds device ids of the subscribed devices. * @param tenantId Id of the current tenant. * @param request paginated request object. - * @param status status of the devices. * @return devices - subscribed device details list * @throws DeviceManagementDAOException if connections establishment fails. */ - List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, - List status) throws DeviceManagementDAOException; + List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException; /** * @param deviceIds device ids of the subscribed devices. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index f7bbfac380..0644fe56b8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -877,12 +877,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, - List status) + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId) throws DeviceManagementDAOException { Connection conn; int limitValue = request.getRowCount(); int offsetValue = request.getStartIndex(); + List status = request.getStatusList(); String name = request.getDeviceName(); String user = request.getOwner(); String ownership = request.getOwnership(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 201a0ba169..07cee11440 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -847,12 +847,12 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, - List status) + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId) throws DeviceManagementDAOException { Connection conn; int limitValue = request.getRowCount(); int offsetValue = request.getStartIndex(); + List status = request.getStatusList(); String name = request.getDeviceName(); String user = request.getOwner(); String ownership = request.getOwnership(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 9234ff6f43..20b0364253 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -827,12 +827,12 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId, - List status) + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId) throws DeviceManagementDAOException { Connection conn; int limitValue = request.getRowCount(); int offsetValue = request.getStartIndex(); + List status = request.getStatusList(); String name = request.getDeviceName(); String user = request.getOwner(); String ownership = request.getOwnership(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index a27191fe32..77b561dde7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -693,12 +693,12 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List getSubscribedDevices(PaginationRequest request, - List deviceIds, int tenantId, List status) + public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId) throws DeviceManagementDAOException { Connection conn; int limitValue = request.getRowCount(); int offsetValue = request.getStartIndex(); + List status = request.getStatusList(); String name = request.getDeviceName(); String user = request.getOwner(); String ownership = request.getOwnership(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index d5f31c1546..157fed7c5d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -910,7 +910,7 @@ public interface DeviceManagementProviderService { * @return {@link PaginationResult} * @throws DeviceManagementException if any service level or DAO level error occurs. */ - PaginationResult getAppSubscribedDevices(PaginationRequest request, List devicesIds, List status) + PaginationResult getAppSubscribedDevices(PaginationRequest request, List devicesIds) throws DeviceManagementException; /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 343acf2602..4959c282c4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -4156,8 +4156,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public PaginationResult getAppSubscribedDevices(PaginationRequest request, List devicesIds, - List status) throws DeviceManagementException { + public PaginationResult getAppSubscribedDevices(PaginationRequest request, List devicesIds) throws DeviceManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); if (log.isDebugEnabled()) { log.debug("Getting all devices details for device ids: " + devicesIds); @@ -4166,14 +4165,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv List subscribedDeviceDetails; try { DeviceManagementDAOFactory.openConnection(); - subscribedDeviceDetails = deviceDAO.getSubscribedDevices(request, devicesIds, tenantId, status); + subscribedDeviceDetails = deviceDAO.getSubscribedDevices(request, devicesIds, tenantId); if (subscribedDeviceDetails.isEmpty()) { paginationResult.setData(new ArrayList<>()); paginationResult.setRecordsFiltered(0); paginationResult.setRecordsTotal(0); return paginationResult; } - int count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, status); + int count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, request.getStatusList()); paginationResult.setRecordsFiltered(count); paginationResult.setRecordsTotal(count); } catch (DeviceManagementDAOException e) { From 645fc43136ab2eb2cfee7d2f04e38dcc9aaf4df0 Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Thu, 18 Mar 2021 17:20:30 +0530 Subject: [PATCH 04/49] Added validations --- .../common/services/SubscriptionManager.java | 1 - .../impl/SubscriptionManagementAPIImpl.java | 26 +---- .../SubscriptionManagementAdminAPIImpl.java | 43 +------- .../impl/util/RequestValidationUtil.java | 102 ++++++++++++++++++ .../mgt/store/api/util/Constants.java | 101 +++++++++++++++++ 5 files changed, 211 insertions(+), 62 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/util/Constants.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java index 5951433c14..12ca873701 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java @@ -129,7 +129,6 @@ public interface SubscriptionManager { * * @param appUUID UUID of the application release. * @param request paginated request object. - * @param status status of the devices. * @return deviceDetails - device details for given application release. * @throws {@link ApplicationManagementException} Exception of the application management */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index 820e6bcd5c..ff6144dcb5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -33,6 +33,7 @@ import org.wso2.carbon.device.application.mgt.common.BasicUserInfo; import org.wso2.carbon.device.application.mgt.common.BasicUserInfoList; import org.wso2.carbon.device.application.mgt.common.RoleList; import org.wso2.carbon.device.application.mgt.common.DeviceGroupList; +import org.wso2.carbon.device.application.mgt.store.api.services.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; @@ -293,6 +294,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ request.setOwner(user); } if (ownership != null && !ownership.isEmpty()) { + RequestValidationUtil.validateOwnershipType(ownership); request.setOwnership(ownership); } if (status != null && !status.isEmpty()) { @@ -304,26 +306,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ } } if (!isStatusEmpty) { - for (String status_ : status) { - switch (status_) { - case "ACTIVE": - case "INACTIVE": - case "UNCLAIMED": - case "UNREACHABLE": - case "SUSPENDED": - case "DISENROLLMENT_REQUESTED": - case "REMOVED": - case "BLOCKED": - case "CREATED": - break; - default: - String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types are " + - "ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + - "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } + RequestValidationUtil.validateStatus(status); request.setStatusList(status); } } @@ -337,8 +320,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ log.error(msg, e); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (BadRequestException e) { - String msg = "Found invalid payload for getting application which has UUID: " + uuid - + ". Hence verify the payload"; + String msg = "User requested details are not valid"; log.error(msg, e); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } catch (ForbiddenException e) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java index 5536fc46d8..4474ddaa81 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java @@ -29,6 +29,7 @@ import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import org.wso2.carbon.device.application.mgt.core.util.APIUtil; import org.wso2.carbon.device.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI; +import org.wso2.carbon.device.application.mgt.store.api.services.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; @@ -84,50 +85,15 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen } } if (!isStatusEmpty) { - for (String status_ : status) { - switch (status_) { - case "ACTIVE": - case "INACTIVE": - case "UNCLAIMED": - case "UNREACHABLE": - case "SUSPENDED": - case "DISENROLLMENT_REQUESTED": - case "REMOVED": - case "BLOCKED": - case "CREATED": - break; - default: - String msg = "Invalid enrollment status type: " + status_ + ". \nValid status types " + - "are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + - "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } + RequestValidationUtil.validateStatus(status); request.setStatusList(status); } } - if (actionStatus != null && !actionStatus.isEmpty()) { if (StringUtils.isNotBlank(actionStatus)) { - switch (actionStatus) { - case "PENDING": - case "ERROR": - case "IN_PROGRESS": - case "NOTNOW": - case "COMPLETED": - case "REPEATED": - break; - default: - String msg = "Invalid enrollment action status type: " + actionStatus + ". " + - "\nValid action status types are PENDING | ERROR | IN_PROGRESS | NOTNOW | " + - "COMPLETED | REPEATED"; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } + RequestValidationUtil.validateStatusFiltering(actionStatus); } } - SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails (request, uuid, actionStatus); @@ -137,8 +103,7 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen log.error(msg, e); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (BadRequestException e) { - String msg = "Found invalid payload for getting application which has UUID: " + uuid - + ". Hence verify the payload"; + String msg = "User requested details are not valid"; log.error(msg, e); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } catch (ApplicationManagementException e) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java new file mode 100644 index 0000000000..f557579c77 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2021, 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.application.mgt.store.api.services.impl.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; +import org.wso2.carbon.device.application.mgt.store.api.util.Constants; + +import java.util.List; + +public class RequestValidationUtil { + + private static final Log log = LogFactory.getLog(RequestValidationUtil.class); + + /** + * Checks if user requested status codes are valid. + * + * @param statusList status codes upon to filter operation logs using status + */ + public static void validateStatus(List statusList) throws BadRequestException { + for (String status : statusList) { + switch (status) { + case "ACTIVE": + case "INACTIVE": + case "UNCLAIMED": + case "UNREACHABLE": + case "SUSPENDED": + case "DISENROLLMENT_REQUESTED": + case "REMOVED": + case "BLOCKED": + case "CREATED": + break; + default: + String msg = "Invalid enrollment status type: " + status + ". \nValid status types " + + "are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " + + "DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED"; + log.error(msg); + throw new BadRequestException(msg); + } + } + } + + /** + * Checks if user requested ownerships are valid. + * + * @param ownership ownerships upon to filter devices using ownership + */ + public static void validateOwnershipType(String ownership) throws BadRequestException { + switch (ownership) { + case "BYOD": + case "COPE": + case "WORK_PROFILE": + case "GOOGLE_ENTERPRISE": + case "COSU": + case "FULLY_MANAGED": + case "DEDICATED_DEVICE": + break; + default: + String msg = "Invalid ownership type received.Valid ownership types are BYOD | COPE | WORK_PROFILE |" + + "GOOGLE_ENTERPRISE | COSU | FULLY_MANAGED | DEDICATED_DEVICE"; + log.error(msg); + throw new BadRequestException(msg); + } + } + + /** + * Checks if user requested Action status codes are valid. + * + * @param status status codes upon to filter operation logs using status + */ + public static void validateStatusFiltering(String status) throws BadRequestException { + if (Constants.OperationStatus.COMPLETED.toUpperCase().equals(status) + || Constants.OperationStatus.ERROR.toUpperCase().equals(status) + || Constants.OperationStatus.NOTNOW.toUpperCase().equals(status) + || Constants.OperationStatus.REPEATED.toUpperCase().equals(status) + || Constants.OperationStatus.PENDING.toUpperCase().equals(status) + || Constants.OperationStatus.IN_PROGRESS.toUpperCase().equals(status)) { + } else { + String msg = "Invalid status type: " + status + ". \nValid status types are COMPLETED | ERROR | " + + "IN_PROGRESS | NOTNOW | PENDING | REPEATED"; + log.error(msg); + throw new BadRequestException(msg); + } + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/util/Constants.java new file mode 100644 index 0000000000..a78c16077f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/util/Constants.java @@ -0,0 +1,101 @@ +/* + * 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. + * + * + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://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 org.wso2.carbon.device.application.mgt.store.api.util; + +/** + * Holds the constants used by DeviceImpl Management Admin web application. + */ +public class Constants { + + public static final String USER_CLAIM_EMAIL_ADDRESS = "http://wso2.org/claims/emailaddress"; + public static final String USER_CLAIM_FIRST_NAME = "http://wso2.org/claims/givenname"; + public static final String USER_CLAIM_LAST_NAME = "http://wso2.org/claims/lastname"; + public static final String USER_CLAIM_CREATED = "http://wso2.org/claims/created"; + public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; + public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; + public static final String PRIMARY_USER_STORE = "PRIMARY"; + public static final String DEFAULT_STREAM_VERSION = "1.0.0"; + public static final String SCOPE = "scope"; + public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; + public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; + public static final int DEFAULT_PAGE_LIMIT = 50; + public static final String FORWARD_SLASH = "/"; + public static final String ANDROID = "android"; + public static final String ANDROID_POLICY_VALIDATOR = "io.entgra.proprietary.platform.android." + + "core.polcy.AndroidPolicyPayloadValidator"; + public static final String IOS = "ios"; + public static final String WINDOWS = "windows"; + + + public final class OperationStatus { + private OperationStatus () { throw new AssertionError(); } + public static final String COMPLETED = "completed"; + public static final String ERROR = "error"; + public static final String IN_PROGRESS = "in_progress"; + public static final String PENDING = "pending"; + public static final String NOTNOW = "notnow"; + public static final String REPEATED = "repeated"; + } + public static final String DEVICES = "devices"; + public static final String ATTRIBUTE_DISPLAY_NAME = "DisplayName"; + public static final String ATTRIBUTE_DESCRIPTION = "Description"; + public static final String EXTERNAL_DEVICE_CLAIM_DISPLAY_NAME = "Devices"; + public static final String EXTERNAL_DEVICE_CLAIM_DESCRIPTION = "Device list"; + + public final class ErrorMessages { + private ErrorMessages () { throw new AssertionError(); } + + public static final String STATUS_BAD_REQUEST_MESSAGE_DEFAULT = "Bad Request"; + + } + + public final class DeviceConstants { + private DeviceConstants () { throw new AssertionError(); } + + public static final String APPLICATION_JSON = "application/json"; + public static final String HEADER_CONTENT_TYPE = "Content-Type"; + } + + public final class Permission { + private Permission() { throw new AssertionError(); } + + public static final String ADMIN = "/permission/admin"; + public static final String LOGIN = "/permission/admin/login"; + public static final String DEVICE_MGT = "/permission/admin/device-mgt"; + public static final String APP_MGT = "/permission/admin/app-mgt"; + } + +} From dca6b53a67cb5e693f9691333c20655c6efb1842 Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Tue, 23 Mar 2021 14:50:36 +0530 Subject: [PATCH 05/49] Added new filter in subscription details page --- .../common/services/SubscriptionManager.java | 3 ++- .../mgt/core/dao/SubscriptionDAO.java | 2 +- .../GenericSubscriptionDAOImpl.java | 23 +++++++++++++++---- .../mgt/core/impl/ApplicationManagerImpl.java | 4 ++-- .../core/impl/SubscriptionManagerImpl.java | 10 ++++---- .../admin/SubscriptionManagementAdminAPI.java | 6 +++++ .../SubscriptionManagementAdminAPIImpl.java | 11 +++++---- .../impl/util/RequestValidationUtil.java | 14 +++++++++++ .../DeviceManagementProviderService.java | 1 - 9 files changed, 54 insertions(+), 20 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java index 12ca873701..a535ffd389 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java @@ -152,12 +152,13 @@ public interface SubscriptionManager { * * @param request paginated request object. * @param actionStatus status of the operation. + * @param action action related to the device. * @param appUUID application release UUID * @return {@link PaginationResult} * @throws ApplicationManagementException if offset or limit contains incorrect values, if it couldn't find an * application release for given UUID, if an error occurred while getting device details of subscribed device ids, * if an error occurred while getting subscription details of given application release UUID. */ - PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus) + PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, String action) throws ApplicationManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java index 0dbd746912..d6ccbe9808 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java @@ -81,7 +81,7 @@ public interface SubscriptionDAO { void addGroupSubscriptions(int tenantId, String subscribedBy, List groups, int releaseId, String action) throws ApplicationManagementDAOException; - List getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus) throws + List getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus, String action) throws ApplicationManagementDAOException; Map getDeviceSubscriptions(List deviceIds, int appReleaseId, int tenantId) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 96a2746022..6ac7adbf96 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -332,13 +332,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public List getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus) throws + public List getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus, String action) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting device subscriptions for the application release id " + appReleaseId + " from the database"); } boolean isActionStatusProvided = false; + boolean isActionProvided = false; + int index = 1; String sql = "SELECT " + "DS.ID AS ID, " + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " @@ -356,13 +358,24 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc sql += " AND DS.STATUS= ?"; isActionStatusProvided = true; } + if (action != null && !action.isEmpty()) { + sql += " AND DS.UNSUBSCRIBED= ?"; + isActionProvided = true; + } try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, appReleaseId); - stmt.setInt(2, tenantId); - if(isActionStatusProvided){ - stmt.setString(3, actionStatus); + stmt.setInt(index++, appReleaseId); + stmt.setInt(index++, tenantId); + if (isActionStatusProvided) { + stmt.setString(index++, actionStatus); + } + if (isActionProvided) { + if (action.equals("SUBSCRIBED")) { + stmt.setString(index, "FALSE"); + } else { + stmt.setString(index, "TRUE"); + } } try (ResultSet rs = stmt.executeQuery()) { if (log.isDebugEnabled()) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 80706aef41..05b757ba45 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1445,7 +1445,7 @@ ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ForbiddenException(msg); } - if (!subscriptionDAO.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null).isEmpty()) { + if (!subscriptionDAO.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null, null).isEmpty()) { String msg = "Application release which has UUID: " + applicationReleaseDTO.getUuid() + " either subscribed to device/s or it had subscribed to device/s. Therefore you are not " + "permitted to delete the application release."; @@ -1580,7 +1580,7 @@ ApplicationManagerImpl implements ApplicationManager { try { ConnectionManagerUtil.beginDBTransaction(); List deviceSubscriptionDTOS = subscriptionDAO - .getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null); + .getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null, null); if (!deviceSubscriptionDTOS.isEmpty()) { String msg = "Application release which has UUID: " + applicationReleaseDTO.getUuid() + " either subscribed to device/s or it had subscribed to device/s. Therefore you " diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 94559782b3..fe590a737f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -377,7 +377,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (applicationDTO != null) { List deviceSubscriptionDTOS = this.subscriptionDAO .getDeviceSubscriptions(applicationDTO.getApplicationReleaseDTOs().get(0).getId(), - tenantId, null); + tenantId, null, null); AtomicBoolean isAppSubscribable = new AtomicBoolean(true); for (DeviceSubscriptionDTO deviceSubscriptionDTO : deviceSubscriptionDTOS) { @@ -1231,7 +1231,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { int applicationReleaseId = applicationDTO.getApplicationReleaseDTOs().get(0).getId(); List deviceSubscriptionDTOS = subscriptionDAO - .getDeviceSubscriptions(applicationReleaseId, tenantId, null); + .getDeviceSubscriptions(applicationReleaseId, tenantId, null, null); if (deviceSubscriptionDTOS.isEmpty()) { PaginationResult paginationResult = new PaginationResult(); paginationResult.setData(new ArrayList<>()); @@ -1338,8 +1338,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus) - throws ApplicationManagementException { + public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, + String action) throws ApplicationManagementException { int limitValue = request.getRowCount(); int offsetValue = request.getStartIndex(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); @@ -1363,7 +1363,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { int applicationReleaseId = applicationDTO.getApplicationReleaseDTOs().get(0).getId(); List deviceSubscriptionDTOS = subscriptionDAO - .getDeviceSubscriptions(applicationReleaseId, tenantId, actionStatus); + .getDeviceSubscriptions(applicationReleaseId, tenantId, actionStatus, action); if (deviceSubscriptionDTOS.isEmpty()) { PaginationResult paginationResult = new PaginationResult(); paginationResult.setData(new ArrayList<>()); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java index 2cb9d63b21..97f6f6851e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java @@ -124,6 +124,12 @@ public interface SubscriptionManagementAdminAPI { required = false) @QueryParam("user") String user, + @ApiParam( + name = "action", + value = "The action, subscribed or unsubscribed.", + required = false) + @Size(max = 45) + @QueryParam("action") String action, @ApiParam( name = "actionStatus", value = "Provide the action status details") diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java index 4474ddaa81..681b3b5f38 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java @@ -18,11 +18,9 @@ package org.wso2.carbon.device.application.mgt.store.api.services.impl.admin; -import io.swagger.annotations.ApiParam; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; @@ -33,7 +31,6 @@ import org.wso2.carbon.device.application.mgt.store.api.services.impl.util.Reque import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; -import javax.validation.constraints.Size; import javax.ws.rs.Consumes; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -60,6 +57,7 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen public Response getAppInstalledDevices( @QueryParam("name") String name, @QueryParam("user") String user, + @QueryParam("action") String action, @QueryParam("actionStatus") String actionStatus, @QueryParam("status") List status, @PathParam("uuid") String uuid, @@ -76,6 +74,9 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen if (user != null && !user.isEmpty()) { request.setOwner(user); } + if (action != null && !action.isEmpty()) { + RequestValidationUtil.validateAction(action); + } if (status != null && !status.isEmpty()) { boolean isStatusEmpty = true; for (String statusString : status) { @@ -96,7 +97,7 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen } SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails - (request, uuid, actionStatus); + (request, uuid, actionStatus, action); return Response.status(Response.Status.OK).entity(subscriptionData).build(); } catch (NotFoundException e) { String msg = "Application with application release UUID: " + uuid + " is not found"; @@ -108,7 +109,7 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } catch (ApplicationManagementException e) { String msg = "Error occurred while getting app installed devices which has application release UUID of: " - + uuid; + + uuid; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java index f557579c77..2a59d220a4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/util/RequestValidationUtil.java @@ -57,6 +57,20 @@ public class RequestValidationUtil { } } + /** + * Checks if user requested action is valid. + * + * @param action action upon to filter devices using action + */ + public static void validateAction(String action) throws BadRequestException { + if (action.equals("SUBSCRIBED") || action.equals("UNSUBSCRIBED")) { + } else { + String msg = "Invalid action type received.Valid action types are SUBSCRIBED | UNSUBSCRIBED"; + log.error(msg); + throw new BadRequestException(msg); + } + } + /** * Checks if user requested ownerships are valid. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index 157fed7c5d..f084e35c3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -906,7 +906,6 @@ public interface DeviceManagementProviderService { * * @param devicesIds devices ids of the subscribed devices. * @param request paginated request object. - * @param status status of the devices. * @return {@link PaginationResult} * @throws DeviceManagementException if any service level or DAO level error occurs. */ From 872299a617ccc2a872fd0225e8261262d5f6fe58 Mon Sep 17 00:00:00 2001 From: vigneshan Date: Thu, 1 Apr 2021 11:30:35 +0530 Subject: [PATCH 06/49] Add login cache for sso and non-sso flow --- .../ui/request/interceptor/LoginHandler.java | 151 +++++++++++------- .../request/interceptor/SsoLoginHandler.java | 146 ++++++++++++----- .../interceptor/cache/LoginCacheManager.java | 63 ++++++++ .../request/interceptor/cache/OAuthApp.java | 79 +++++++++ .../interceptor/cache/OAuthAppCacheKey.java | 74 +++++++++ .../interceptor/util/HandlerConstants.java | 1 + 6 files changed, 414 insertions(+), 100 deletions(-) create mode 100644 components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/LoginCacheManager.java create mode 100644 components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthApp.java create mode 100644 components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthAppCacheKey.java diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index 133681355b..1a98cef5a9 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -24,6 +24,9 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import io.entgra.ui.request.interceptor.beans.AuthData; +import io.entgra.ui.request.interceptor.cache.LoginCacheManager; +import io.entgra.ui.request.interceptor.cache.OAuthApp; +import io.entgra.ui.request.interceptor.cache.OAuthAppCacheKey; import io.entgra.ui.request.interceptor.exceptions.LoginException; import io.entgra.ui.request.interceptor.util.HandlerConstants; import io.entgra.ui.request.interceptor.util.HandlerUtil; @@ -74,26 +77,61 @@ public class LoginHandler extends HttpServlet { JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); - HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); - apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() - .encodeToString((username + HandlerConstants.COLON + password).getBytes())); - apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, username, password)); + // Check if OAuth app cache exists. If not create a new application. + LoginCacheManager loginCacheManager = new LoginCacheManager(); + loginCacheManager.initializeCacheManager(); + OAuthAppCacheKey oAuthAppCacheKey = new OAuthAppCacheKey(HandlerConstants.PUBLISHER_APPLICATION_NAME, username); + OAuthApp oAuthApp = loginCacheManager.getOAuthAppCache(oAuthAppCacheKey); - ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); + if (oAuthApp == null) { + HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); + apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() + .encodeToString((username + HandlerConstants.COLON + password).getBytes())); + apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); + apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, username, password)); - if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, clientAppResponse); - return; + ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); + + if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { + HandlerUtil.handleError(resp, clientAppResponse); + return; + } + + if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { + JsonParser jsonParser = new JsonParser(); + JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); + String clientId = null; + String clientSecret = null; + String encodedClientApp = null; + if (jClientAppResult.isJsonObject()) { + JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); + clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); + clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); + encodedClientApp = Base64.getEncoder() + .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); + + oAuthAppCacheKey = new OAuthAppCacheKey(HandlerConstants.PUBLISHER_APPLICATION_NAME, username); + oAuthApp = new OAuthApp( + HandlerConstants.PUBLISHER_APPLICATION_NAME, + username, + clientId, + clientSecret, + encodedClientApp + ); + loginCacheManager.addOAuthAppToCache(oAuthAppCacheKey, oAuthApp); + } + + if (getTokenAndPersistInSession(req, resp, clientId, clientSecret, encodedClientApp, scopes)) { + ProxyResponse proxyResponse = new ProxyResponse(); + proxyResponse.setCode(HttpStatus.SC_OK); + HandlerUtil.handleSuccess(resp, proxyResponse); + return; + } + } + HandlerUtil.handleError(resp, null); + } else { + getTokenAndPersistInSession(req, resp, oAuthApp.getClientId(), oAuthApp.getClientSecret(), oAuthApp.getEncodedClientApp(), scopes); } - if (clientAppResponse.getCode() == HttpStatus.SC_CREATED && getTokenAndPersistInSession(req, resp, - clientAppResponse.getData(), scopes)) { - ProxyResponse proxyResponse = new ProxyResponse(); - proxyResponse.setCode(HttpStatus.SC_OK); - HandlerUtil.handleSuccess(resp, proxyResponse); - return; - } - HandlerUtil.handleError(resp, null); } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); } catch (JsonSyntaxException e) { @@ -103,57 +141,54 @@ public class LoginHandler extends HttpServlet { } } - /*** + /** * Generates token from token endpoint and persists them inside the session * - * @param req - {@link HttpServletRequest} - * @param clientAppResult - clientAppResult - * @param scopes - scopes defied in the application-mgt.xml - * @throws LoginException - login exception throws when getting token result + * @param req - {@link HttpServletRequest} + * @param resp - {@link HttpServletResponse} + * @param clientId - clientId of the OAuth app + * @param clientSecret - clientSecret of the OAuth app + * @param encodedClientApp - Base64 encoded clientId:clientSecret. + * @param scopes - User scopes JSON Array + * @return boolean response + * @throws LoginException - Throws if any error occurs while getting login response */ private boolean getTokenAndPersistInSession(HttpServletRequest req, HttpServletResponse resp, - String clientAppResult, JsonArray scopes) throws LoginException { + String clientId, String clientSecret, String encodedClientApp, + JsonArray scopes) throws LoginException { JsonParser jsonParser = new JsonParser(); try { - JsonElement jClientAppResult = jsonParser.parse(clientAppResult); - if (jClientAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); - String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); - String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); - String encodedClientApp = Base64.getEncoder() - .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); - ProxyResponse tokenResultResponse = getTokenResult(encodedClientApp, scopes); + ProxyResponse tokenResultResponse = getTokenResult(encodedClientApp, scopes); - if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { - log.error("Error occurred while invoking the API to get token data."); - HandlerUtil.handleError(resp, tokenResultResponse); + if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { + log.error("Error occurred while invoking the API to get token data."); + HandlerUtil.handleError(resp, tokenResultResponse); + return false; + } + String tokenResult = tokenResultResponse.getData(); + if (tokenResult == null) { + log.error("Invalid token response is received."); + HandlerUtil.handleError(resp, tokenResultResponse); + return false; + } + + JsonElement jTokenResult = jsonParser.parse(tokenResult); + if (jTokenResult.isJsonObject()) { + JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); + HttpSession session = req.getSession(false); + if (session == null) { return false; } - String tokenResult = tokenResultResponse.getData(); - if (tokenResult == null) { - log.error("Invalid token response is received."); - HandlerUtil.handleError(resp, tokenResultResponse); - return false; - } - - JsonElement jTokenResult = jsonParser.parse(tokenResult); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - HttpSession session = req.getSession(false); - if (session == null) { - return false; - } - AuthData authData = new AuthData(); - authData.setClientId(clientId); - authData.setClientSecret(clientSecret); - authData.setEncodedClientApp(encodedClientApp); - authData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); - authData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - authData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); - session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); - return true; - } + AuthData authData = new AuthData(); + authData.setClientId(clientId); + authData.setClientSecret(clientSecret); + authData.setEncodedClientApp(encodedClientApp); + authData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); + authData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); + authData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); + session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); + return true; } return false; } catch (IOException e) { diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index 1ade046d43..872fd189d1 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -23,6 +23,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; +import io.entgra.ui.request.interceptor.cache.LoginCacheManager; +import io.entgra.ui.request.interceptor.cache.OAuthApp; +import io.entgra.ui.request.interceptor.cache.OAuthAppCacheKey; import io.entgra.ui.request.interceptor.util.HandlerConstants; import io.entgra.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.text.StrSubstitutor; @@ -72,24 +75,62 @@ public class SsoLoginHandler extends HttpServlet { private static String encodedAdminCredentials; private static String encodedClientApp; private static String applicationId; + private static String applicationName; private static String baseContextPath; private JsonObject uiConfigJsonObject; private HttpSession httpSession; + private LoginCacheManager loginCacheManager; + private OAuthApp oAuthApp; + @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { - dynamicClientRegistration(req, resp); - String clientId = httpSession.getAttribute("clientId").toString(); - JsonArray scopesSsoJson = uiConfigJsonObject.get("scopes").getAsJsonArray(); - String scopesSsoString = HandlerUtil.getScopeString(scopesSsoJson); - String loginCallbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; - resp.sendRedirect(iotsCoreUrl + HandlerConstants.AUTHORIZATION_ENDPOINT + - "?response_type=code" + - "&client_id=" + clientId + - "&state=" + - "&scope=openid " + scopesSsoString + - "&redirect_uri=" + loginCallbackUrl); + protected void doGet(HttpServletRequest req, HttpServletResponse resp) { + try { + httpSession = req.getSession(false); + + if (httpSession != null) { + httpSession.invalidate(); + } + + httpSession = req.getSession(true); + initializeAdminCredentials(); + baseContextPath = req.getContextPath(); + applicationName = baseContextPath.substring(1, baseContextPath.indexOf("-ui-request-handler")); + + // Check if oauth app cache is available + loginCacheManager = new LoginCacheManager(); + loginCacheManager.initializeCacheManager(); + oAuthApp = loginCacheManager.getOAuthAppCache( + new OAuthAppCacheKey(applicationName, adminUsername) + ); + + if (oAuthApp == null) { + dynamicClientRegistration(req, resp); + } + + String clientId = oAuthApp.getClientId(); + JsonArray scopesSsoJson = uiConfigJsonObject.get("scopes").getAsJsonArray(); + String scopesSsoString = HandlerUtil.getScopeString(scopesSsoJson); + String loginCallbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; + persistAuthSessionData(req, oAuthApp.getClientId(), oAuthApp.getClientSecret(), + oAuthApp.getEncodedClientApp(), scopesSsoString); + + resp.sendRedirect(iotsCoreUrl + HandlerConstants.AUTHORIZATION_ENDPOINT + + "?response_type=code" + + "&client_id=" + clientId + + "&state=" + + "&scope=openid " + scopesSsoString + + "&redirect_uri=" + loginCallbackUrl); + } catch (IOException e) { + log.error("Error occurred while sending the response into the socket. ", e); + } catch (JsonSyntaxException e) { + log.error("Error occurred while parsing the response. ", e); + } catch (ParserConfigurationException e) { + log.error("Error while creating the document builder."); + } catch (SAXException e) { + log.error("Error while parsing xml file.", e); + } } /*** @@ -101,17 +142,6 @@ public class SsoLoginHandler extends HttpServlet { */ private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { try { - File userMgtConf = new File("conf/user-mgt.xml"); - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(userMgtConf); - - adminUsername = doc.getElementsByTagName("UserName").item(0).getTextContent(); - adminPassword = doc.getElementsByTagName("Password").item(0).getTextContent(); - - baseContextPath = req.getContextPath(); - String applicationName = baseContextPath.substring(1, baseContextPath.indexOf("-ui-request-handler")); - String iotsCorePort = System.getProperty("iot.core.https.port"); if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { @@ -124,14 +154,7 @@ public class SsoLoginHandler extends HttpServlet { + HandlerConstants.COLON + iotsCorePort; String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; - httpSession = req.getSession(false); - if (httpSession != null) { - httpSession.invalidate(); - } - - httpSession = req.getSession(true); uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); - JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); @@ -153,19 +176,22 @@ public class SsoLoginHandler extends HttpServlet { if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { JsonParser jsonParser = new JsonParser(); JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); + String clientId = null; + String clientSecret = null; + if (jClientAppResult.isJsonObject()) { JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); - String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); - String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); + clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); + clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); encodedClientApp = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes()); - String redirectUrl = req.getParameter("redirect"); - httpSession = req.getSession(false); - httpSession.setAttribute("clientId", clientId); - httpSession.setAttribute("clientSecret", clientSecret); - httpSession.setAttribute("encodedClientApp", encodedClientApp); - httpSession.setAttribute("scope", HandlerUtil.getScopeString(scopes)); - httpSession.setAttribute("redirectUrl", redirectUrl); + String scopesString = HandlerUtil.getScopeString(scopes); + persistAuthSessionData(req, clientId, clientSecret, encodedClientApp, scopesString); } + + // cache the oauth app credentials + OAuthAppCacheKey oAuthAppCacheKey = new OAuthAppCacheKey(applicationName, adminUsername); + oAuthApp = new OAuthApp(applicationName, adminUsername, clientId, clientSecret, encodedClientApp); + loginCacheManager.addOAuthAppToCache(oAuthAppCacheKey, oAuthApp); } // Get the details of the registered application @@ -221,7 +247,6 @@ public class SsoLoginHandler extends HttpServlet { if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_OK) { return; } - HandlerUtil.handleError(resp, null); } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); @@ -229,11 +254,48 @@ public class SsoLoginHandler extends HttpServlet { log.error("Error occurred while parsing the response. ", e); } catch (ParserConfigurationException e) { log.error("Error while creating the document builder."); - } catch ( SAXException e) { + } catch (SAXException e) { log.error("Error while parsing xml file.", e); } } + /** + * Initialize the admin credential variables + * + * @throws ParserConfigurationException - Throws when error occur during initializing the document builder + * @throws IOException - Throws when error occur during document parsing + * @throws SAXException - Throws when error occur during document parsing + */ + private void initializeAdminCredentials() throws ParserConfigurationException, IOException, SAXException { + File userMgtConf = new File("conf/user-mgt.xml"); + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(userMgtConf); + + adminUsername = doc.getElementsByTagName("UserName").item(0).getTextContent(); + adminPassword = doc.getElementsByTagName("Password").item(0).getTextContent(); + } + + + /** + * Persist the Auth data inside the session + * + * @param req - Http Servlet request + * @param clientId - Client ID of the SP + * @param clientSecret - Client secret of the SP + * @param encodedClientApp - Base64 encoded clientId:clientSecret. + * @param scopes - User scopes + */ + private void persistAuthSessionData(HttpServletRequest req, String clientId, String clientSecret, + String encodedClientApp, String scopes) { + httpSession = req.getSession(false); + httpSession.setAttribute("clientId", clientId); + httpSession.setAttribute("clientSecret", clientSecret); + httpSession.setAttribute("encodedClientApp", encodedClientApp); + httpSession.setAttribute("scope", scopes); + httpSession.setAttribute("redirectUrl", req.getParameter("redirect")); + } + /*** * Generates payload for application grant_type update payload * @@ -311,7 +373,7 @@ public class SsoLoginHandler extends HttpServlet { */ private void updateSaasApp(String appName) throws ParserConfigurationException, IOException, SAXException { File getAppRequestXmlFile = new File(HandlerConstants.PAYLOADS_DIR + "/get-app-request.xml"); - String identityAppMgtUrl = iotsCoreUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT;; + String identityAppMgtUrl = iotsCoreUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT; HttpPost getApplicationEndpoint = new HttpPost(identityAppMgtUrl); getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/LoginCacheManager.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/LoginCacheManager.java new file mode 100644 index 0000000000..3ecd741350 --- /dev/null +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/LoginCacheManager.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021, 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.ui.request.interceptor.cache; + +import io.entgra.ui.request.interceptor.util.HandlerConstants; + +import javax.cache.Cache; +import javax.cache.CacheManager; +import javax.cache.Caching; + +/** + * Contains necessary functions to manage oAuth app cache during login handling + */ +public class LoginCacheManager { + + private CacheManager cacheManager = null; + private Cache cache = null; + + /** + * Initialize the cache manager if it is not already initialized + */ + public void initializeCacheManager() { + cacheManager = Caching.getCacheManagerFactory().getCacheManager(HandlerConstants.LOGIN_CACHE); + } + + /** + * Persists OAuth app cache if it is not already persisted + * + * @param oAuthAppCacheKey - The identifier key of the cache + * @param oAuthApp - The value of the cache which contains OAuth app data + */ + public void addOAuthAppToCache(OAuthAppCacheKey oAuthAppCacheKey, OAuthApp oAuthApp) { + cache = cacheManager.getCache(HandlerConstants.LOGIN_CACHE); + cache.put(oAuthAppCacheKey, oAuthApp); + } + + /** + * Retrieves the OAuth app cache + * + * @param oAuthAppCacheKey - The key to identify the cache + * @return - Returns OAuthApp object + */ + public OAuthApp getOAuthAppCache(OAuthAppCacheKey oAuthAppCacheKey) { + cache = cacheManager.getCache(HandlerConstants.LOGIN_CACHE); + return cache.get(oAuthAppCacheKey); + } +} diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthApp.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthApp.java new file mode 100644 index 0000000000..db721ea992 --- /dev/null +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthApp.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021, 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.ui.request.interceptor.cache; + +/** + * The data object used for Login Cache + */ +public class OAuthApp { + + private String appName; + private String appOwner; + private String clientId; + private String clientSecret; + private String encodedClientApp; + + public OAuthApp(String appName, String appOwner, String clientId, String clientSecret, String encodedClientApp) { + this.appName = appName; + this.appOwner = appOwner; + this.clientId = clientId; + this.clientSecret = clientSecret; + this.encodedClientApp = encodedClientApp; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public String getAppOwner() { + return appOwner; + } + + public void setAppOwner(String appOwner) { + this.appOwner = appOwner; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getEncodedClientApp() { + return encodedClientApp; + } + + public void setEncodedClientApp(String encodedClientApp) { + this.encodedClientApp = encodedClientApp; + } +} diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthAppCacheKey.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthAppCacheKey.java new file mode 100644 index 0000000000..aa03eade5a --- /dev/null +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/cache/OAuthAppCacheKey.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021, 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.ui.request.interceptor.cache; + +import java.util.Objects; + +/** + * The key object used for Login Cache + */ +public class OAuthAppCacheKey { + + private String appName; + private String appOwner; + private volatile int hashCode; + + public OAuthAppCacheKey(String appName, String appOwner) { + this.appName = appName; + this.appOwner = appOwner; + } + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + } + + public String getAppOwner() { + return appOwner; + } + + public void setAppOwner(String appOwner) { + this.appOwner = appOwner; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj instanceof OAuthAppCacheKey) { + final OAuthAppCacheKey other = (OAuthAppCacheKey) obj; + String thisId = this.appName + "-" + this.appOwner; + String otherId = other.appName + "-" + other.appOwner; + return thisId.equals(otherId); + } + return false; + } + + @Override + public int hashCode() { + if (hashCode == 0) { + hashCode = Objects.hash(appName, appOwner); + } + return hashCode; + } +} diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index 3d4255c0aa..56e50769b8 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -55,6 +55,7 @@ public class HandlerConstants { public static final String PASSWORD_GRANT_TYPE = "password"; public static final String JWT_BEARER_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer"; public static final String PRODUCTION_KEY = "PRODUCTION"; + public static final String LOGIN_CACHE = "LOGIN_CACHE"; public static final String SCHEME_SEPARATOR = "://"; public static final String COLON = ":"; From 99e5f9f876ddc10571ab9d883657bbeee1e38fa9 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Sat, 10 Apr 2021 16:18:06 +0000 Subject: [PATCH 07/49] Fix executing policy monitoring continuously --- .../task/impl/DeviceStatusMonitoringTask.java | 1 + .../task/impl/DeviceDetailsRetrieverTask.java | 10 +- .../impl/DynamicPartitionedScheduleTask.java | 21 +++- .../mgt/core/enforcement/DelegationTask.java | 22 ++--- .../policy/mgt/core/task/MonitoringTask.java | 96 ++++++++----------- .../core/task/TaskScheduleServiceImpl.java | 12 +-- 6 files changed, 77 insertions(+), 85 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java index 7bc831c313..5182fc3651 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java @@ -52,6 +52,7 @@ public class DeviceStatusMonitoringTask extends DynamicPartitionedScheduleTask { @Override public void setProperties(Map properties) { + super.setProperties(properties); deviceType = properties.get(DeviceStatusTaskManagerServiceImpl.DEVICE_TYPE); deviceTypeId = Integer.parseInt(properties.get(DeviceStatusTaskManagerServiceImpl.DEVICE_TYPE_ID)); String deviceStatusTaskConfigStr = properties.get(DeviceStatusTaskManagerServiceImpl.DEVICE_STATUS_TASK_CONFIG); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java index 360325e9ab..0c6f77c15d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java @@ -39,28 +39,26 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.DynamicTaskContext; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.StartupOperationConfig; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager; -import org.wso2.carbon.ntask.core.Task; -import org.wso2.carbon.user.api.UserStoreException; import java.util.List; import java.util.Map; public class DeviceDetailsRetrieverTask extends DynamicPartitionedScheduleTask { - private static Log log = LogFactory.getLog(DeviceDetailsRetrieverTask.class); + private static final Log log = LogFactory.getLog(DeviceDetailsRetrieverTask.class); private String deviceType; private DeviceManagementProviderService deviceManagementProviderService; @Override public void setProperties(Map map) { + super.setProperties(map); deviceType = map.get("DEVICE_TYPE"); } @@ -122,7 +120,7 @@ public class DeviceDetailsRetrieverTask extends DynamicPartitionedScheduleTask { //pass the configurations also from here, monitoring tasks try { if (deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType)) { - deviceTaskManager.addOperations(super.getTaskContext()); + deviceTaskManager.addOperations(getTaskContext()); } } catch (DeviceMgtTaskException e) { log.error("Error occurred while trying to add the operations to " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java index ef11b3bda2..0bbb59d2bd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java @@ -26,12 +26,27 @@ import org.wso2.carbon.device.mgt.common.DynamicTaskContext; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.ntask.core.Task; +import java.util.Map; + public abstract class DynamicPartitionedScheduleTask implements Task { private static final Log log = LogFactory.getLog(DynamicPartitionedScheduleTask.class); private static DynamicTaskContext taskContext = null; + private Map properties; + + @Override + public void setProperties(Map properties) { + this.properties = properties; + } + + public String getProperty(String name) { + if (properties == null) { + return null; + } + return properties.get(name); + } @Override public final void init() { @@ -97,11 +112,7 @@ public abstract class DynamicPartitionedScheduleTask implements Task { } public static boolean isDynamicTaskEligible(){ - if(taskContext != null && taskContext.isPartitioningEnabled()) { - return true; - } else { - return false; - } + return taskContext != null && taskContext.isPartitioningEnabled(); } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java index b24e84f029..ba4cfd971c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/DelegationTask.java @@ -21,8 +21,8 @@ package org.wso2.carbon.policy.mgt.core.enforcement; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; @@ -36,19 +36,13 @@ import org.wso2.carbon.policy.mgt.core.mgt.impl.PolicyManagerImpl; import java.util.ArrayList; import java.util.List; -import java.util.Map; public class DelegationTask extends DynamicPartitionedScheduleTask { private static final Log log = LogFactory.getLog(DelegationTask.class); - private PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance() + private final PolicyConfiguration policyConfiguration = DeviceConfigurationManager.getInstance() .getDeviceManagementConfig().getPolicyConfiguration(); - @Override - public void setProperties(Map map) { - - } - @Override public void executeDynamicTask() { try { @@ -70,10 +64,10 @@ public class DelegationTask extends DynamicPartitionedScheduleTask { try { devices = new ArrayList<>(); toBeNotified = new ArrayList<>(); - if (super.isDynamicTaskEligible()) { + if (isDynamicTaskEligible()) { devices.addAll(service.getAllocatedDevices(deviceType, - super.getTaskContext().getActiveServerCount(), - super.getTaskContext().getServerHashIndex())); + getTaskContext().getActiveServerCount(), + getTaskContext().getServerHashIndex())); } else { devices.addAll(service.getAllDevices(deviceType, false)); } @@ -81,9 +75,9 @@ public class DelegationTask extends DynamicPartitionedScheduleTask { if (device != null && device.getEnrolmentInfo() != null && device.getEnrolmentInfo().getStatus() != EnrolmentInfo.Status.REMOVED) { toBeNotified.add(device); - } - if (log.isDebugEnabled()) { - log.debug("Adding policy operation to device : " + device.getDeviceIdentifier()); + if (log.isDebugEnabled()) { + log.debug("Adding policy operation to device : " + device.getDeviceIdentifier()); + } } } if (!toBeNotified.isEmpty()) { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java index d51f283a8e..c93ff3d563 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java @@ -24,33 +24,22 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.task.impl.DynamicPartitionedScheduleTask; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager; +import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants; import java.util.ArrayList; import java.util.List; -import java.util.Map; public class MonitoringTask extends DynamicPartitionedScheduleTask { private static final Log log = LogFactory.getLog(MonitoringTask.class); - @Override - public void setProperties(Map map) { - } - - @Override - public void executeDynamicTask() { - if (log.isDebugEnabled()) { - log.debug("Monitoring task started to run."); - } - this.executeforAllTenants(); - } + private String tenant; /** * Check whether Device platform (ex: android) is exist in the cdm-config.xml file before adding a @@ -66,30 +55,27 @@ public class MonitoringTask extends DynamicPartitionedScheduleTask { return policyMonitoringManager != null; } - private void executeforAllTenants() { - + @Override + public void executeDynamicTask() { + tenant = getProperty(PolicyManagementConstants.TENANT_ID); + if (tenant == null) { + log.warn("Tenant id of the Monitoring Task got null"); + return; + } + int tenantId = Integer.parseInt(tenant); if (log.isDebugEnabled()) { - log.debug("Monitoring task started to run for all tenants."); + log.debug("Monitoring task started to run for tenant: " + tenant); + } + if (MultitenantConstants.SUPER_TENANT_ID == tenantId) { + this.executeTask(); + return; } try { - DeviceManagementProviderService deviceManagementService = PolicyManagementDataHolder - .getInstance().getDeviceManagementService(); - List tenants = deviceManagementService.getDeviceEnrolledTenants(); - for (Integer tenant : tenants) { - if (MultitenantConstants.SUPER_TENANT_ID == tenant) { - this.executeTask(); - continue; - } - try { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant, true); - this.executeTask(); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - } catch (DeviceManagementException e) { - log.error("Error occurred while trying to get the available tenants from device manager service ", e); + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true); + this.executeTask(); + } finally { + PrivilegedCarbonContext.endTenantFlow(); } } @@ -105,7 +91,7 @@ public class MonitoringTask extends DynamicPartitionedScheduleTask { } } } catch (PolicyComplianceException e) { - log.error("Error occurred while getting the device types."); + log.error("TID:[" + tenant + "] Error occurred while getting the device types."); } if (!deviceTypes.isEmpty()) { try { @@ -113,42 +99,42 @@ public class MonitoringTask extends DynamicPartitionedScheduleTask { PolicyManagementDataHolder.getInstance().getDeviceManagementService(); for (String deviceType : configDeviceTypes) { if (log.isDebugEnabled()) { - log.debug("Running task for device type : " + deviceType); + log.debug("TID:[" + tenant + "] Running task for device type : " + deviceType); } PolicyMonitoringManager monitoringService = PolicyManagementDataHolder.getInstance().getDeviceManagementService() .getPolicyMonitoringManager(deviceType); List devices; - if(super.isDynamicTaskEligible()){ - devices = deviceManagementProviderService.getAllocatedDevices(deviceType, - super.getTaskContext().getActiveServerCount(), - super.getTaskContext().getServerHashIndex()); + if(isDynamicTaskEligible()){ + devices = deviceManagementProviderService + .getAllocatedDevices(deviceType, getTaskContext().getActiveServerCount(), + getTaskContext().getServerHashIndex()); } else { devices = deviceManagementProviderService.getAllDevices(deviceType, false); } if (monitoringService != null && !devices.isEmpty()) { List notifiableDevices = new ArrayList<>(); if (log.isDebugEnabled()) { - log.debug("Removing inactive and blocked devices from the list for the device type : " + - deviceType); + log.debug("TID:[" + tenant + "] Removing inactive and blocked devices from " + + "the list for the device type : " + deviceType); } + StringBuilder sb = new StringBuilder(); for (Device device : devices) { EnrolmentInfo.Status status = device.getEnrolmentInfo().getStatus(); if (status.equals(EnrolmentInfo.Status.ACTIVE) || - status.equals(EnrolmentInfo.Status.INACTIVE) || status.equals(EnrolmentInfo.Status.UNREACHABLE)) { notifiableDevices.add(device); - } - if (log.isDebugEnabled()) { - log.debug("Adding monitoring operation to device : " + device.getDeviceIdentifier()); + if (log.isDebugEnabled()) { + if (sb.length() > 0) { + sb.append(", "); + } + sb.append(device.getDeviceIdentifier()); + } } } if (log.isDebugEnabled()) { - log.debug("Following '" + deviceType + "' devices selected to send the notification " + - "for policy monitoring"); - for (Device device : notifiableDevices) { - log.debug(device.getDeviceIdentifier()); - } + log.debug("TID:[" + tenant + "] Sending monitoring to '" + deviceType + + "' devices with ids [" + sb + "]"); } if (!notifiableDevices.isEmpty()) { monitoringManager.addMonitoringOperation(deviceType, notifiableDevices); @@ -156,13 +142,14 @@ public class MonitoringTask extends DynamicPartitionedScheduleTask { } } if (log.isDebugEnabled()) { - log.debug("Monitoring task running completed."); + log.debug("TID:[" + tenant + "] Monitoring task running completed."); } } catch (Exception e) { - log.error("Error occurred while trying to run a task.", e); + log.error("TID:[" + tenant + "] Error occurred while trying to run a task.", e); } } else { - log.info("No device types registered currently. So did not run the monitoring task."); + log.info("TID:[" + tenant + "] No device types registered currently. " + + "So did not run the monitoring task."); } } @@ -170,4 +157,5 @@ public class MonitoringTask extends DynamicPartitionedScheduleTask { protected void setup() { } + } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java index b4b358bc32..d6aefcee11 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/TaskScheduleServiceImpl.java @@ -39,7 +39,7 @@ import java.util.Map; public class TaskScheduleServiceImpl implements TaskScheduleService { private static final Log log = LogFactory.getLog(TaskScheduleServiceImpl.class); - private PolicyConfiguration policyConfiguration; + private final PolicyConfiguration policyConfiguration; public TaskScheduleServiceImpl() { @@ -72,7 +72,7 @@ public class TaskScheduleServiceImpl implements TaskScheduleService { Map properties = new HashMap<>(); properties.put(PolicyManagementConstants.TENANT_ID, String.valueOf(tenantId)); - String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId); + String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + tenantId; if (!taskManager.isTaskScheduled(taskName)) { @@ -101,7 +101,7 @@ public class TaskScheduleServiceImpl implements TaskScheduleService { public void stopTask() throws PolicyMonitoringTaskException { int tenantId = getTenantId(); try { - String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId); + String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + tenantId; TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); if (taskService.isServerInit()) { TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.MONITORING_TASK_TYPE); @@ -117,7 +117,7 @@ public class TaskScheduleServiceImpl implements TaskScheduleService { public void updateTask(int monitoringFrequency) throws PolicyMonitoringTaskException { int tenantId = getTenantId(); try { - String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId); + String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + tenantId; TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.MONITORING_TASK_TYPE); @@ -129,7 +129,7 @@ public class TaskScheduleServiceImpl implements TaskScheduleService { triggerInfo.setRepeatCount(-1); Map properties = new HashMap<>(); - properties.put("tenantId", String.valueOf(tenantId)); + properties.put(PolicyManagementConstants.TENANT_ID, String.valueOf(tenantId)); TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.MONITORING_TASK_CLAZZ, properties, triggerInfo); @@ -150,7 +150,7 @@ public class TaskScheduleServiceImpl implements TaskScheduleService { @Override public boolean isTaskScheduled() throws PolicyMonitoringTaskException { int tenantId = getTenantId(); - String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + String.valueOf(tenantId); + String taskName = PolicyManagementConstants.MONITORING_TASK_NAME + "_" + tenantId; TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); TaskManager taskManager; try { From 10166069d33c445a70eca55ddaeab1664ec57468 Mon Sep 17 00:00:00 2001 From: vigneshan Date: Mon, 19 Apr 2021 15:42:15 +0530 Subject: [PATCH 08/49] Fix token refresh issue --- .../ui/request/interceptor/DefaultTokenHandler.java | 2 +- .../io/entgra/ui/request/interceptor/InvokerHandler.java | 2 +- .../io/entgra/ui/request/interceptor/LoginHandler.java | 8 ++++---- .../entgra/ui/request/interceptor/OTPInvokerHandler.java | 2 +- .../ui/request/interceptor/SsoLoginCallbackHandler.java | 9 +++++---- .../entgra/ui/request/interceptor/SsoLoginHandler.java | 8 ++++---- .../io/entgra/ui/request/interceptor/UserHandler.java | 2 +- .../ui/request/interceptor/util/HandlerConstants.java | 6 +++++- .../entgra/ui/request/interceptor/util/HandlerUtil.java | 8 ++++---- 9 files changed, 26 insertions(+), 21 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java index 1079e78b27..7aaae1ca70 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java @@ -132,7 +132,7 @@ public class DefaultTokenHandler extends HttpServlet { URIBuilder ub = new URIBuilder(); ub.setScheme(HandlerConstants.WSS_PROTOCOL); ub.setHost(System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR)); - ub.setPort(Integer.parseInt(System.getProperty(HandlerConstants.IOT_CORE_PORT_ENV_VAR))); + ub.setPort(Integer.parseInt(System.getProperty(HandlerConstants.IOT_CORE_HTTPS_PORT_ENV_VAR))); ub.setPath(HandlerConstants.REMOTE_SESSION_CONTEXT); JsonObject responseJsonObj = new JsonObject(); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java index 49e0489de3..51a6c06674 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java @@ -369,7 +369,7 @@ public class InvokerHandler extends HttpServlet { log.debug("refreshing the token"); } HttpPost tokenEndpoint = new HttpPost( - apiEndpoint + HandlerConstants.API_COMMON_CONTEXT + HandlerConstants.TOKEN_ENDPOINT); + apiEndpoint + HandlerConstants.TOKEN_ENDPOINT); HttpSession session = req.getSession(false); if (session == null) { log.error("Couldn't find a session, hence it is required to login and proceed."); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index 1a98cef5a9..e4246fbfc0 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -202,15 +202,15 @@ public class LoginHandler extends HttpServlet { * Define username and password static parameters. */ private static void validateLoginRequest(HttpServletRequest req) throws LoginException { - String iotsCorePort = System.getProperty("iot.core.https.port"); + String iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTPS_PORT_ENV_VAR); if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { - iotsCorePort = System.getProperty("iot.core.http.port"); + iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTP_PORT_ENV_VAR); } username = req.getParameter("username"); password = req.getParameter("password"); - gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") + gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + HandlerConstants.COLON + iotsCorePort + HandlerConstants.UI_CONFIG_ENDPOINT; if (username == null || password == null) { String msg = "Invalid login request. Username or Password is not received for login request."; diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/OTPInvokerHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/OTPInvokerHandler.java index a97d8be7c5..7194001cca 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/OTPInvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/OTPInvokerHandler.java @@ -241,7 +241,7 @@ public class OTPInvokerHandler extends HttpServlet { private static boolean validateRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException { String schema = req.getScheme(); - apiEndpoint = schema + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + apiEndpoint = schema + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getCorePort(schema); if (StringUtils.isBlank(req.getHeader(HandlerConstants.OTP_HEADER))) { diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java index 8ee6ec776b..92bd0e6b70 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -27,6 +27,7 @@ import io.entgra.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHeaders; +import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -50,15 +51,15 @@ public class SsoLoginCallbackHandler extends HttpServlet { String code = req.getParameter("code"); HttpSession session = req.getSession(false); String scope = session.getAttribute("scope").toString(); - String iotsCorePort = System.getProperty("iot.core.https.port"); + String iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTPS_PORT_ENV_VAR); if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { - iotsCorePort = System.getProperty("iot.core.http.port"); + iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTP_PORT_ENV_VAR); } - String gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") + String gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + HandlerConstants.COLON + iotsCorePort; HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index 872fd189d1..1a5a550571 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -142,15 +142,15 @@ public class SsoLoginHandler extends HttpServlet { */ private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { try { - String iotsCorePort = System.getProperty("iot.core.https.port"); + String iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTPS_PORT_ENV_VAR); if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { - iotsCorePort = System.getProperty("iot.core.http.port"); + iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTP_PORT_ENV_VAR); } - gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") + gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + HandlerConstants.COLON + iotsCorePort; String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java index 9686979d53..276413b217 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java @@ -52,7 +52,7 @@ public class UserHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { String serverUrl = - req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") + req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); HttpSession httpSession = req.getSession(false); if (httpSession == null) { diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index 56e50769b8..6760fcf236 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -75,6 +75,10 @@ public class HandlerConstants { public static final String REMOTE_SESSION_CONTEXT = "/remote/session/clients"; public static final String IOT_CORE_HOST_ENV_VAR = "iot.core.host"; - public static final String IOT_CORE_PORT_ENV_VAR = "iot.core.https.port"; + public static final String IOT_CORE_HTTP_PORT_ENV_VAR = "iot.core.http.port"; + public static final String IOT_CORE_HTTPS_PORT_ENV_VAR = "iot.core.https.port"; + public static final String IOT_GW_HOST_ENV_VAR = "iot.gateway.host"; + public static final String IOT_GW_HTTP_PORT_ENV_VAR = "iot.gateway.http.port"; + public static final String IOT_GW_HTTPS_PORT_ENV_VAR = "iot.gateway.https.port"; } diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java index 4582468a0c..5acec832ce 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java @@ -226,9 +226,9 @@ public class HandlerUtil { * @return {@link String} gateway port */ public static String getGatewayPort(String scheme) { - String gatewayPort = System.getProperty("iot.gateway.https.port"); + String gatewayPort = System.getProperty(HandlerConstants.IOT_GW_HTTPS_PORT_ENV_VAR); if (HandlerConstants.HTTP_PROTOCOL.equals(scheme)) { - gatewayPort = System.getProperty("iot.gateway.http.port"); + gatewayPort = System.getProperty(HandlerConstants.IOT_GW_HTTP_PORT_ENV_VAR); } return gatewayPort; } @@ -240,9 +240,9 @@ public class HandlerUtil { * @return {@link String} gateway port */ public static String getCorePort(String scheme) { - String productCorePort = System.getProperty("iot.core.https.port"); + String productCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTPS_PORT_ENV_VAR); if (HandlerConstants.HTTP_PROTOCOL.equals(scheme)) { - productCorePort = System.getProperty("iot.core.https.por"); + productCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTP_PORT_ENV_VAR); } return productCorePort; } From 365b073e6a5128af8c51e0513ab0af34d1f60774 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 19 Apr 2021 08:55:21 +0530 Subject: [PATCH 09/49] Fix app schedule installation issue in single node --- .../mgt/common/DeviceSubscriptionData.java | 6 +++--- .../common/dto/ScheduledSubscriptionDTO.java | 8 ++++---- .../mgt/core/dao/SubscriptionDAO.java | 2 +- .../GenericSubscriptionDAOImpl.java | 6 +++--- .../core/impl/SubscriptionManagerImpl.java | 4 ++-- .../ScheduledAppSubscriptionCleanupTask.java | 2 +- .../task/ScheduledAppSubscriptionTask.java | 2 +- .../ScheduledAppSubscriptionTaskManager.java | 19 +++++++++++------- .../application/mgt/core/util/DAOUtil.java | 2 +- .../services/SubscriptionManagementAPI.java | 8 ++++---- .../impl/SubscriptionManagementAPIImpl.java | 20 +++++++++---------- .../impl/RandomlyAssignedScheduleTask.java | 2 ++ .../dbscripts/cdm/application-mgt/h2.sql | 2 +- .../dbscripts/cdm/application-mgt/mssql.sql | 2 +- .../dbscripts/cdm/application-mgt/mysql.sql | 2 +- .../dbscripts/cdm/application-mgt/oracle.sql | 2 +- .../cdm/application-mgt/postgresql.sql | 2 +- 17 files changed, 49 insertions(+), 42 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/DeviceSubscriptionData.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/DeviceSubscriptionData.java index 3afac36acd..550c1c98fc 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/DeviceSubscriptionData.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/DeviceSubscriptionData.java @@ -24,7 +24,7 @@ import java.sql.Timestamp; public class DeviceSubscriptionData { private String action; - private Timestamp actionTriggeredTimestamp; + private long actionTriggeredTimestamp; private String actionTriggeredBy; private String actionType; private String status; @@ -38,11 +38,11 @@ public class DeviceSubscriptionData { this.action = action; } - public Timestamp getActionTriggeredTimestamp() { + public long getActionTriggeredTimestamp() { return actionTriggeredTimestamp; } - public void setActionTriggeredTimestamp(Timestamp actionTriggeredTimestamp) { + public void setActionTriggeredTimestamp(long actionTriggeredTimestamp) { this.actionTriggeredTimestamp = actionTriggeredTimestamp; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ScheduledSubscriptionDTO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ScheduledSubscriptionDTO.java index 65801e9415..da3e1e01e0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ScheduledSubscriptionDTO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ScheduledSubscriptionDTO.java @@ -69,7 +69,7 @@ public class ScheduledSubscriptionDTO { /** * Scheduled time of subscription. */ - private LocalDateTime scheduledAt; + private long scheduledAt; /** * Username of the scheduler. @@ -86,7 +86,7 @@ public class ScheduledSubscriptionDTO { } - public ScheduledSubscriptionDTO(String taskName, String applicationUUID, LocalDateTime scheduledAt, + public ScheduledSubscriptionDTO(String taskName, String applicationUUID, long scheduledAt, List subscriberList, String scheduledBy) { this.taskName = taskName; this.applicationUUID = applicationUUID; @@ -135,11 +135,11 @@ public class ScheduledSubscriptionDTO { this.status = status; } - public LocalDateTime getScheduledAt() { + public long getScheduledAt() { return scheduledAt; } - public void setScheduledAt(LocalDateTime scheduledAt) { + public void setScheduledAt(long scheduledAt) { this.scheduledAt = scheduledAt; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java index 4b99420e50..99b7395b1f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java @@ -124,7 +124,7 @@ public interface SubscriptionDAO { * @param scheduledBy username of the user who scheduled the subscription * @throws ApplicationManagementDAOException if error occurred while updating the entry */ - boolean updateScheduledSubscription(int id, LocalDateTime scheduledAt, String scheduledBy) + boolean updateScheduledSubscription(int id, long scheduledAt, String scheduledBy) throws ApplicationManagementDAOException; /** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index c2f559e96b..7018ca662f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -765,7 +765,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc stmt.setString(2, subscriptionDTO.getApplicationUUID()); stmt.setString(3, subscriptionDTO.getSubscribersString()); stmt.setString(4, ExecutionStatus.PENDING.toString()); - stmt.setTimestamp(5, Timestamp.valueOf(subscriptionDTO.getScheduledAt())); + stmt.setLong(5, subscriptionDTO.getScheduledAt()); stmt.setTimestamp(6, new Timestamp(calendar.getTime().getTime())); stmt.setString(7, subscriptionDTO.getScheduledBy()); stmt.setBoolean(8, false); @@ -785,7 +785,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public boolean updateScheduledSubscription(int id, LocalDateTime scheduledAt, String scheduledBy) + public boolean updateScheduledSubscription(int id, long scheduledAt, String scheduledBy) throws ApplicationManagementDAOException { String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION " + "SET " @@ -797,7 +797,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { Calendar calendar = Calendar.getInstance(); - stmt.setTimestamp(1, Timestamp.valueOf(scheduledAt)); + stmt.setLong(1, scheduledAt); stmt.setString(2, scheduledBy); stmt.setTimestamp(3, new Timestamp(calendar.getTime().getTime())); stmt.setInt(4, id); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 19008cbb0d..dcd641f102 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1392,12 +1392,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceSubscriptionData.setAction(Constants.UNSUBSCRIBED); deviceSubscriptionData.setActionTriggeredBy(subscription.getUnsubscribedBy()); deviceSubscriptionData - .setActionTriggeredTimestamp(subscription.getUnsubscribedTimestamp()); + .setActionTriggeredTimestamp(subscription.getUnsubscribedTimestamp().getTime() / 1000); } else { deviceSubscriptionData.setAction(Constants.SUBSCRIBED); deviceSubscriptionData.setActionTriggeredBy(subscription.getSubscribedBy()); deviceSubscriptionData - .setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); + .setActionTriggeredTimestamp(subscription.getSubscribedTimestamp().getTime() / 1000); } deviceSubscriptionData.setActionType(subscription.getActionTriggeredFrom()); deviceSubscriptionData.setStatus(subscription.getStatus()); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java index 113b16cf3f..351a4477b2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java @@ -40,7 +40,7 @@ public class ScheduledAppSubscriptionCleanupTask extends RandomlyAssignedSchedul @Override public void executeRandomlyAssignedTask() { try { - if(super.isQualifiedToExecuteTask()) { + if(isQualifiedToExecuteTask()) { subscriptionManager.cleanScheduledSubscriptions(); } } catch (SubscriptionManagementException e) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTask.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTask.java index caff4ec460..8a95efc0aa 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTask.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTask.java @@ -68,7 +68,7 @@ public class ScheduledAppSubscriptionTask extends RandomlyAssignedScheduleTask { @Override public void executeRandomlyAssignedTask() { - if(super.isQualifiedToExecuteTask()) { + if(isQualifiedToExecuteTask()) { try { ScheduledSubscriptionDTO subscriptionDTO = subscriptionManager.getPendingScheduledSubscription( this.taskName); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java index c07053f3d5..326a358e1b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java @@ -40,6 +40,8 @@ import org.wso2.carbon.ntask.core.service.TaskService; import java.time.LocalDateTime; import java.time.format.TextStyle; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -64,24 +66,27 @@ public class ScheduledAppSubscriptionTaskManager { * either {@link org.wso2.carbon.device.mgt.common.DeviceIdentifier} if {@param subType} is * equal to DEVICE or {@link String} if {@param subType} is USER, ROLE or GROUP * @param subscriptionType subscription type. E.g. DEVICE, USER, ROLE, GROUP - * {@see {@link org.wso2.carbon.device.application.mgt.common.SubscriptionType}} + * {@see {@link SubscriptionType}} * @param action action subscription action. E.g. {@code INSTALL/UNINSTALL} - * {@see {@link org.wso2.carbon.device.application.mgt.common.SubAction}} + * {@see {@link SubAction}} * @param timestamp timestamp to schedule the application subscription * @throws ApplicationOperationTaskException if error occurred while scheduling the subscription */ public void scheduleAppSubscriptionTask(String applicationUUID, List subscribers, - SubscriptionType subscriptionType, SubAction action, LocalDateTime timestamp) + SubscriptionType subscriptionType, SubAction action, long timestamp) throws ApplicationOperationTaskException { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date(timestamp * 1000)); String space = " "; String cronExpression = - String.valueOf(timestamp.getSecond()) + space + timestamp.getMinute() + space + timestamp.getHour() - + space + timestamp.getDayOfMonth() + space + timestamp.getMonth().getDisplayName(TextStyle.SHORT, - Locale.getDefault()).toUpperCase() + " ? " + timestamp.getYear(); + calendar.get(Calendar.SECOND) + space + calendar.get(Calendar.MINUTE) + space + + calendar.get(Calendar.HOUR_OF_DAY) + space + calendar.get(Calendar.DAY_OF_MONTH) + space + + calendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault()).toUpperCase() + " ? " + + calendar.get(Calendar.YEAR); if (!CronExpression.isValidExpression(cronExpression)) { String msg = "The cron expression [" + cronExpression + "] generated by the" + " timestamp [" + timestamp - .toString() + "] is invalid"; + + "] is invalid"; log.error(msg); throw new ApplicationOperationTaskException(msg); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java index c56df53109..56be92ac9b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java @@ -274,7 +274,7 @@ public class DAOUtil { } subscription.setStatus(ExecutionStatus.valueOf(rs.getString("STATUS"))); - subscription.setScheduledAt(rs.getTimestamp("SCHEDULED_AT").toLocalDateTime()); + subscription.setScheduledAt(rs.getTimestamp("SCHEDULED_AT").getTime()); subscription.setScheduledBy(rs.getString("SCHEDULED_BY")); subscription.setDeleted(rs.getBoolean("DELETED")); subscriptionDTOS.add(subscription); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java index 75a4522d68..85485f1a08 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/SubscriptionManagementAPI.java @@ -129,7 +129,7 @@ public interface SubscriptionManagementAPI { name = "timestamp", value = "Timestamp of scheduled install/uninstall operation" ) - @QueryParam("timestamp") String timestamp + @QueryParam("timestamp") long timestamp ); @POST @@ -182,7 +182,7 @@ public interface SubscriptionManagementAPI { name = "timestamp", value = "Timestamp of scheduled install/uninstall operation" ) - @QueryParam("timestamp") String timestamp + @QueryParam("timestamp") long timestamp ); @POST @@ -229,7 +229,7 @@ public interface SubscriptionManagementAPI { name = "timestamp", value = "Timestamp of scheduled ent. install operation" ) - @QueryParam("timestamp") String timestamp, + @QueryParam("timestamp") long timestamp, @ApiParam( name = "requiresUpdatingExternal", value = "Should external system such as Google EMM APIs need to be updated." @@ -287,7 +287,7 @@ public interface SubscriptionManagementAPI { name = "timestamp", value = "Timestamp of scheduled ent app install operation" ) - @QueryParam("timestamp") String timestamp, + @QueryParam("timestamp") long timestamp, @ApiParam( name = "requiresUpdatingExternal", value = "Should external system such as Google EMM APIs need to be updated." diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index 984f689d07..4e71aa760c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -73,9 +73,9 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ @PathParam("uuid") String uuid, @PathParam("action") String action, @Valid List deviceIdentifiers, - @QueryParam("timestamp") String timestamp) { + @QueryParam("timestamp") long timestamp) { try { - if (StringUtils.isEmpty(timestamp)) { + if (0 == timestamp) { SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); ApplicationInstallResponse response = subscriptionManager .performBulkAppOperation(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(), action); @@ -114,9 +114,9 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ @PathParam("subType") String subType, @PathParam("action") String action, @Valid List subscribers, - @QueryParam("timestamp") String timestamp) { + @QueryParam("timestamp") long timestamp) { try { - if (StringUtils.isEmpty(timestamp)) { + if (0 == timestamp) { SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); ApplicationInstallResponse response = subscriptionManager .performBulkAppOperation(uuid, subscribers, subType, action); @@ -155,10 +155,10 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ @PathParam("uuid") String uuid, @PathParam("action") String action, @Valid List deviceIdentifiers, - @QueryParam("timestamp") String timestamp, + @QueryParam("timestamp") long timestamp, @QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) { try { - if (StringUtils.isEmpty(timestamp)) { + if (0 == timestamp) { SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); subscriptionManager .performEntAppSubscription(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(), @@ -202,10 +202,10 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ @PathParam("subType") String subType, @PathParam("action") String action, @Valid List subscribers, - @QueryParam("timestamp") String timestamp, + @QueryParam("timestamp") long timestamp, @QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) { try { - if (StringUtils.isEmpty(timestamp)) { + if (0 == timestamp) { SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); subscriptionManager.performEntAppSubscription(uuid, subscribers, subType, action, requiresUpdatingExternal); String msg = "Application release which has UUID " + uuid + " is installed to subscriber's valid device" @@ -253,11 +253,11 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{ * @return {@link Response} of the operation */ private Response scheduleApplicationOperationTask(String applicationUUID, List subscribers, - SubscriptionType subType, SubAction subAction, String timestamp) { + SubscriptionType subType, SubAction subAction, long timestamp) { try { ScheduledAppSubscriptionTaskManager subscriptionTaskManager = new ScheduledAppSubscriptionTaskManager(); subscriptionTaskManager.scheduleAppSubscriptionTask(applicationUUID, subscribers, subType, subAction, - LocalDateTime.parse(timestamp, DateTimeFormatter.ISO_LOCAL_DATE_TIME)); + timestamp); } catch (ApplicationOperationTaskException e) { String msg = "Error occurred while scheduling the application install operation"; log.error(msg, e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java index 56a1c498a0..fb8a5b9235 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java @@ -61,6 +61,8 @@ public abstract class RandomlyAssignedScheduleTask implements Task { log.error("Error refreshing Variables necessary for Randomly Assigned Scheduled Task. " + "Dynamic Tasks will not function.", e); } + } else { + qualifiedToExecuteTask = true; } } diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index f16927301b..dcbebd74b4 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -269,7 +269,7 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION( APPLICATION_UUID VARCHAR(36) NOT NULL, SUBSCRIBER_LIST LONGVARCHAR NOT NULL, STATUS VARCHAR(15) NOT NULL, - SCHEDULED_AT TIMESTAMP NOT NULL, + SCHEDULED_AT BIGINT NOT NULL, SCHEDULED_BY VARCHAR(100) NOT NULL, SCHEDULED_TIMESTAMP TIMESTAMP NOT NULL, DELETED BOOLEAN, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql index 78e05c1371..25fc47e38e 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql @@ -270,7 +270,7 @@ CREATE TABLE AP_SCHEDULED_SUBSCRIPTION( APPLICATION_UUID VARCHAR(200) NOT NULL, SUBSCRIBER_LIST VARCHAR(MAX) NOT NULL, STATUS VARCHAR(15) NOT NULL, - SCHEDULED_AT DATETIME2(0) NOT NULL, + SCHEDULED_AT BIGINT NOT NULL, SCHEDULED_BY VARCHAR(100) NOT NULL, SCHEDULED_TIMESTAMP DATETIME2(0) NOT NULL, DELETED BIT, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index 1daa796858..5d5db38b2d 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -269,7 +269,7 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION( APPLICATION_UUID VARCHAR(36) NOT NULL, SUBSCRIBER_LIST TEXT NOT NULL, STATUS VARCHAR(15) NOT NULL, - SCHEDULED_AT TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + SCHEDULED_AT BIGINT NOT NULL, SCHEDULED_BY VARCHAR(100) NOT NULL, SCHEDULED_TIMESTAMP TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, DELETED BOOLEAN, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql index c4f2c99f06..edbc277ab2 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql @@ -372,7 +372,7 @@ CREATE TABLE AP_SCHEDULED_SUBSCRIPTION ( APPLICATION_UUID VARCHAR(36) NOT NULL, SUBSCRIBER_LIST VARCHAR(4000) NOT NULL, STATUS VARCHAR(15) NOT NULL, - SCHEDULED_AT TIMESTAMP NOT NULL, + SCHEDULED_AT NUMBER(19) NOT NULL, SCHEDULED_BY VARCHAR(100) NOT NULL, SCHEDULED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, DELETED NUMBER(1) NOT_NULL DEFAULT 0, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql index 5c20aa4a75..d871549d89 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql @@ -299,7 +299,7 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION( APPLICATION_UUID VARCHAR(36) NOT NULL, SUBSCRIBER_LIST TEXT NOT NULL, STATUS VARCHAR(15) NOT NULL, - SCHEDULED_AT TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL, + SCHEDULED_AT BIGINT NOT NULL, SCHEDULED_BY VARCHAR(100) NOT NULL, SCHEDULED_TIMESTAMP TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL, DELETED BOOLEAN, From 86720b1a458cc1ab1ba35896921ed8077f4ee6b2 Mon Sep 17 00:00:00 2001 From: Farheen99 Date: Sat, 24 Apr 2021 11:26:59 +0530 Subject: [PATCH 10/49] Add a query to get the applications sort according to latest timestamp order --- .../application/GenericApplicationDAOImpl.java | 15 +++++++++++++-- .../application/OracleApplicationDAOImpl.java | 15 +++++++++++++-- .../application/SQLServerApplicationDAOImpl.java | 15 +++++++++++++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index a4d9d4a87a..dd8880c6fc 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -134,7 +134,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, " + "AP_APP_RELEASE.RATING AS RELEASE_RATING, " + "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, " - + "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT " + + "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT, " + + "NEW_AP_APP_LIFECYCLE_STATE.UPDATED_AT AS LATEST_UPDATE " + "FROM AP_APP " + "INNER JOIN AP_APP_RELEASE ON " + "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID " @@ -181,7 +182,17 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic if (filter.getLimit() != -1) { sql += "LIMIT ? OFFSET ? "; } - sql += ") AS app_data ON app_data.ID = AP_APP.ID WHERE AP_APP.TENANT_ID = ? ORDER BY AP_APP.ID"; + sql += ") AS app_data ON app_data.ID = AP_APP.ID " + + "INNER JOIN (" + + "SELECT AP_APP_LIFECYCLE_STATE.UPDATED_AT, AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID " + + "FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_LIFECYCLE_STATE.ID " + + "IN(SELECT MAX(AP_APP_LIFECYCLE_STATE.ID) " + + "FROM AP_APP_LIFECYCLE_STATE " + + "GROUP BY AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID)) AS NEW_AP_APP_LIFECYCLE_STATE " + + "ON AP_APP_RELEASE.ID = NEW_AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID " + + "WHERE AP_APP.TENANT_ID = ? " + + "ORDER BY AP_APP.ID, LATEST_UPDATE DESC"; + try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java index c57ef8a07d..bb705d7f82 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java @@ -80,7 +80,8 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl { + "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, " + "AP_APP_RELEASE.RATING AS RELEASE_RATING, " + "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, " - + "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT " + + "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT, " + + "NEW_AP_APP_LIFECYCLE_STATE.UPDATED_AT AS LATEST_UPDATE " + "FROM AP_APP " + "INNER JOIN AP_APP_RELEASE ON " + "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID " @@ -125,7 +126,17 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl { if (filter.getLimit() != -1) { sql += "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY "; } - sql += ") AS app_data ON app_data.ID = AP_APP.ID WHERE AP_APP.TENANT_ID = ? ORDER BY AP_APP.ID"; + sql += ") AS app_data ON app_data.ID = AP_APP.ID " + + "INNER JOIN (" + + "SELECT AP_APP_LIFECYCLE_STATE.UPDATED_AT, AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID " + + "FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_LIFECYCLE_STATE.ID " + + "IN(SELECT MAX(AP_APP_LIFECYCLE_STATE.ID) " + + "FROM AP_APP_LIFECYCLE_STATE " + + "GROUP BY AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID)) AS NEW_AP_APP_LIFECYCLE_STATE " + + "ON AP_APP_RELEASE.ID = NEW_AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID " + + "WHERE AP_APP.TENANT_ID = ? " + + "ORDER BY AP_APP.ID, LATEST_UPDATE DESC"; + try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java index ee7c78f8ba..d27e55aa9b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java @@ -79,7 +79,8 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { + "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, " + "AP_APP_RELEASE.RATING AS RELEASE_RATING, " + "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, " - + "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT " + + "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT, " + + "NEW_AP_APP_LIFECYCLE_STATE.UPDATED_AT AS LATEST_UPDATE " + "FROM AP_APP " + "INNER JOIN AP_APP_RELEASE ON " + "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID " @@ -124,7 +125,17 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { if (filter.getLimit() != -1) { sql += "ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY "; } - sql += ") AS app_data ON app_data.ID = AP_APP.ID WHERE AP_APP.TENANT_ID = ? ORDER BY AP_APP.ID"; + sql += ") AS app_data ON app_data.ID = AP_APP.ID " + + "INNER JOIN (" + + "SELECT AP_APP_LIFECYCLE_STATE.UPDATED_AT, AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID " + + "FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_LIFECYCLE_STATE.ID " + + "IN(SELECT MAX(AP_APP_LIFECYCLE_STATE.ID) " + + "FROM AP_APP_LIFECYCLE_STATE " + + "GROUP BY AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID)) AS NEW_AP_APP_LIFECYCLE_STATE " + + "ON AP_APP_RELEASE.ID = NEW_AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID " + + "WHERE AP_APP.TENANT_ID = ? " + + "ORDER BY AP_APP.ID, LATEST_UPDATE DESC"; + try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { From 4dee16dffbeeb4aefd8478d95decf7acf7188c53 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 28 Apr 2021 18:54:31 +0530 Subject: [PATCH 11/49] Fix schedule install DAO issue --- .../wso2/carbon/device/application/mgt/core/util/DAOUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java index 56be92ac9b..4950fe3c6e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/DAOUtil.java @@ -274,7 +274,7 @@ public class DAOUtil { } subscription.setStatus(ExecutionStatus.valueOf(rs.getString("STATUS"))); - subscription.setScheduledAt(rs.getTimestamp("SCHEDULED_AT").getTime()); + subscription.setScheduledAt(rs.getLong("SCHEDULED_AT")); subscription.setScheduledBy(rs.getString("SCHEDULED_BY")); subscription.setDeleted(rs.getBoolean("DELETED")); subscriptionDTOS.add(subscription); From 0060083499a411ef79ada46d44c718d61218334d Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 3 May 2021 11:21:05 +0530 Subject: [PATCH 12/49] Add DAO fix for app schedule subscription --- .../core/dao/impl/subscription/GenericSubscriptionDAOImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 7018ca662f..c6937a05a8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -1037,7 +1037,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, ExecutionStatus.PENDING.toString()); stmt.setBoolean(2, false); - stmt.setTimestamp(3, new Timestamp(Calendar.getInstance().getTime().getTime())); + stmt.setLong(3, Calendar.getInstance().getTime().getTime() / 1000); try (ResultSet rs = stmt.executeQuery()) { return DAOUtil.loadScheduledSubscriptions(rs); } From 429e76cfdc8184e99df84f1678eb17d0780b22ad Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 3 May 2021 23:11:21 +0530 Subject: [PATCH 13/49] Add session scope handler --- .../interceptor/PermissionScopeHandler.java | 65 +++++++++++++++++++ .../interceptor/util/HandlerConstants.java | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/PermissionScopeHandler.java diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/PermissionScopeHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/PermissionScopeHandler.java new file mode 100644 index 0000000000..96d1d1151f --- /dev/null +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/PermissionScopeHandler.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019, 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.ui.request.interceptor; + +import io.entgra.ui.request.interceptor.beans.AuthData; +import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import io.entgra.ui.request.interceptor.util.HandlerConstants; +import io.entgra.ui.request.interceptor.util.HandlerUtil; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.json.JSONObject; + +import javax.servlet.ServletException; +import javax.servlet.annotation.MultipartConfig; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; + +@MultipartConfig +@WebServlet("/login-user/scopes") +public class PermissionScopeHandler extends HttpServlet { + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + HttpSession httpSession = req.getSession(false); + if (httpSession == null) { + HandlerUtil.sendUnAuthorizeResponse(resp); + return; + } + + AuthData authData = (AuthData) httpSession.getAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY); + if (authData == null) { + HandlerUtil.sendUnAuthorizeResponse(resp); + return; + } + + if (!StringUtils.isEmpty(authData.getScope())) { + ProxyResponse proxyResponse = new ProxyResponse(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put(HandlerConstants.USER_SCOPES, authData.getScope()); + proxyResponse.setCode(HttpStatus.SC_OK); + proxyResponse.setData(jsonObject.toString()); + HandlerUtil.handleSuccess(resp, proxyResponse); + } + HandlerUtil.handleError(resp, null); + } +} diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index 6760fcf236..b94309be57 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -80,5 +80,5 @@ public class HandlerConstants { public static final String IOT_GW_HOST_ENV_VAR = "iot.gateway.host"; public static final String IOT_GW_HTTP_PORT_ENV_VAR = "iot.gateway.http.port"; public static final String IOT_GW_HTTPS_PORT_ENV_VAR = "iot.gateway.https.port"; - + public static final String USER_SCOPES = "user-scopes"; } From b2691996ab23890566fa8542e6a31e83bd26eefe Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Wed, 21 Apr 2021 19:57:48 +0530 Subject: [PATCH 14/49] Added device filter using serial number. --- .../service/api/DeviceManagementService.java | 6 +++ .../impl/DeviceManagementServiceImpl.java | 4 ++ .../impl/DeviceManagementServiceImplTest.java | 48 ++++++++++++------- .../device/mgt/common/PaginationRequest.java | 5 ++ .../dao/impl/device/GenericDeviceDAOImpl.java | 15 +++++- .../dao/impl/device/OracleDeviceDAOImpl.java | 15 +++++- .../impl/device/PostgreSQLDeviceDAOImpl.java | 17 +++++-- .../impl/device/SQLServerDeviceDAOImpl.java | 14 +++++- 8 files changed, 98 insertions(+), 26 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index f90a205c0a..8268fbaac6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -269,6 +269,12 @@ public interface DeviceManagementService { @QueryParam("ownership") @Size(max = 45) String ownership, + @ApiParam( + name = "serialNumber", + value = "The serialNumber of the device.", + required = false) + @QueryParam("serialNumber") + String serialNumber, @ApiParam( name = "status", value = "Provide the device status details, such as active or inactive.", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index b2f2d1ab11..1a151bddf9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -172,6 +172,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("userPattern") String userPattern, @QueryParam("role") String role, @QueryParam("ownership") String ownership, + @QueryParam("serialNumber") String serialNumber, @QueryParam("status") List status, @QueryParam("groupId") int groupId, @QueryParam("since") String since, @@ -205,6 +206,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { RequestValidationUtil.validateOwnershipType(ownership); request.setOwnership(ownership); } + if (serialNumber != null && !serialNumber.isEmpty()) { + request.setSerialNumber(serialNumber); + } if (status != null && !status.isEmpty()) { boolean isStatusEmpty = true; for (String statusString : status){ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java index bb9de05c1f..7b995660ad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -175,7 +175,8 @@ public class DeviceManagementServiceImplTest { .toReturn(this.deviceAccessAuthorizationService); Response response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 1, null, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -194,19 +195,23 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 1, null, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, null, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 1, null, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 1, null, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 1, null, null, true, 10, 5); + null, DEFAULT_STATUS_LIST, 1, null, null, true, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -319,7 +324,7 @@ public class DeviceManagementServiceImplTest { .toReturn(this.deviceManagementProviderService); Mockito.when(deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(true); deviceManagementService.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, - DEFAULT_ROLE, DEFAULT_OWNERSHIP, DEFAULT_STATUS_LIST, 1, + DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); } @@ -339,11 +344,11 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + , null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, null, DEFAULT_USERNAME, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + , null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -365,7 +370,8 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, "newuser", null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 0, null, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 0, null, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); } @@ -386,15 +392,18 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, false, 10, 5); + null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, true, 10, 5); + null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, true, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 0, null, "ErrorModifiedSince", false, 10, 5); + null, DEFAULT_STATUS_LIST, 0, null, "ErrorModifiedSince", + false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -414,15 +423,18 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 0, since, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 0, since, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 0, since, null, true, 10, 5); + null, DEFAULT_STATUS_LIST, 0, since, null, true, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 0, "ErrorSince", null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 0, "ErrorSince", null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -444,7 +456,8 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 1, null, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceManagementProviderService); } @@ -466,7 +479,8 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + null, DEFAULT_STATUS_LIST, 1, null, null, false, + 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java index 94cf5c5272..29bb7922e9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java @@ -40,6 +40,7 @@ public class PaginationRequest { private String ownerRole; private Date since; private String filter; + private String serialNumber; private Map property = new HashMap<>(); private List statusList = new ArrayList<>(); private OperationLogFilters operationLogFilters = new OperationLogFilters(); @@ -153,6 +154,10 @@ public class PaginationRequest { return this.property.get(key); } + public String getSerialNumber() { return serialNumber; } + + public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } + public Map getProperties() { Map temp = new HashMap<>(); temp.putAll(property); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index a5959cc5f9..69cc4e887b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -67,6 +67,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isStatusProvided = false; Date since = request.getSince(); boolean isSinceProvided = false; + String serial = request.getSerialNumber(); + boolean isSerialProvided = false; + try { Connection conn = getConnection(); @@ -88,9 +91,14 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t "; + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; - sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + if (serial != null) { + sql = sql + "AND i.VALUE_FIELD = ? "; + isSerialProvided = true; + } + sql = sql + "AND d.TENANT_ID = ?"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; @@ -128,6 +136,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; + if (isSerialProvided) { + stmt.setString(paramIdx++, serial); + } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 109fac5507..301267e52e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -68,6 +68,8 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isStatusProvided = false; Date since = request.getSince(); boolean isSinceProvided = false; + String serial = request.getSerialNumber(); + boolean isSerialProvided = false; try { conn = getConnection(); @@ -89,8 +91,14 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; + + if (serial != null) { + sql = sql + "AND i.VALUE_FIELD = ? "; + isSerialProvided = true; + } + sql = sql + "AND d.TENANT_ID = ?"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; @@ -128,6 +136,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; + if (isSerialProvided) { + stmt.setString(paramIdx++, serial); + } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index fdf81826ad..f170d3cb71 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -67,6 +67,8 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isStatusProvided = false; Date since = request.getSince(); boolean isSinceProvided = false; + String serial = request.getSerialNumber(); + boolean isSerialProvided = false; try { conn = getConnection(); @@ -88,10 +90,14 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t " + - "WHERE DEVICE_TYPE_ID = t.ID " + - "AND d.TENANT_ID = ?"; + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; + + if (serial != null) { + sql = sql + "AND i.VALUE_FIELD = ? "; + isSerialProvided = true; + } + sql = sql + "AND d.TENANT_ID = ?"; //Add the query for device-type if (deviceType != null && !deviceType.isEmpty()) { sql = sql + " AND t.NAME = ?"; @@ -124,6 +130,9 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; + if (isSerialProvided) { + stmt.setString(paramIdx++, serial); + } stmt.setInt(paramIdx++, tenantId); if (isDeviceTypeProvided) { stmt.setString(paramIdx++, deviceType); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 673d63304d..7380d93a85 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -69,6 +69,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isStatusProvided = false; Date since = request.getSince(); boolean isSinceProvided = false; + String serial = request.getSerialNumber(); + boolean isSerialProvided = false; try { conn = getConnection(); @@ -90,7 +92,14 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; + + if (serial != null) { + sql = sql + "AND i.VALUE_FIELD = ? "; + isSerialProvided = true; + } + sql = sql + "AND d.TENANT_ID = ?"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; @@ -128,6 +137,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; + if (isSerialProvided) { + stmt.setString(paramIdx++, serial); + } stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); From 60b59f455d3ba8beb2d37dd4caef2ce402f7b65d Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Wed, 5 May 2021 14:37:06 +0530 Subject: [PATCH 15/49] Solved test case failure. --- .../core/dao/impl/device/GenericDeviceDAOImpl.java | 11 ++++++----- .../mgt/core/dao/impl/device/OracleDeviceDAOImpl.java | 11 ++++++----- .../core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 11 ++++++----- .../core/dao/impl/device/SQLServerDeviceDAOImpl.java | 11 ++++++----- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 69cc4e887b..22f06c3471 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -90,15 +90,16 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.DESCRIPTION, " + "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; + "t.NAME AS DEVICE_TYPE "; if (serial != null) { - sql = sql + "AND i.VALUE_FIELD = ? "; + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; isSerialProvided = true; + } else { + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; } - sql = sql + "AND d.TENANT_ID = ?"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 301267e52e..044a681c9d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -90,15 +90,16 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.DESCRIPTION, " + "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; + "t.NAME AS DEVICE_TYPE "; if (serial != null) { - sql = sql + "AND i.VALUE_FIELD = ? "; + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; isSerialProvided = true; + } else { + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; } - sql = sql + "AND d.TENANT_ID = ?"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index f170d3cb71..5bcbbea8bc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -89,15 +89,16 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.DESCRIPTION, " + "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; + "t.NAME AS DEVICE_TYPE "; if (serial != null) { - sql = sql + "AND i.VALUE_FIELD = ? "; + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; isSerialProvided = true; + } else { + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; } - sql = sql + "AND d.TENANT_ID = ?"; //Add the query for device-type if (deviceType != null && !deviceType.isEmpty()) { sql = sql + " AND t.NAME = ?"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 7380d93a85..95a69d3642 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -91,15 +91,16 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.DESCRIPTION, " + "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID AND i.KEY_FIELD='serial' "; + "t.NAME AS DEVICE_TYPE "; if (serial != null) { - sql = sql + "AND i.VALUE_FIELD = ? "; + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + + "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; isSerialProvided = true; + } else { + sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; } - sql = sql + "AND d.TENANT_ID = ?"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; From 6f325862ec927ee3772fc811da401b205d07c2c3 Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Thu, 6 May 2021 14:12:03 +0530 Subject: [PATCH 16/49] Formatting the SQL query. --- .../mgt/jaxrs/service/api/DeviceManagementService.java | 2 +- .../jaxrs/service/impl/DeviceManagementServiceImpl.java | 2 +- .../mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 7 +++++-- .../mgt/core/dao/impl/device/OracleDeviceDAOImpl.java | 7 +++++-- .../mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 7 +++++-- .../mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java | 7 +++++-- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 8268fbaac6..01145b05ec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -271,7 +271,7 @@ public interface DeviceManagementService { String ownership, @ApiParam( name = "serialNumber", - value = "The serialNumber of the device.", + value = "The serial number of the device.", required = false) @QueryParam("serialNumber") String serialNumber, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 1a151bddf9..7648a102b8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -206,7 +206,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { RequestValidationUtil.validateOwnershipType(ownership); request.setOwnership(ownership); } - if (serialNumber != null && !serialNumber.isEmpty()) { + if (StringUtils.isNotBlank(serialNumber)) { request.setSerialNumber(serialNumber); } if (status != null && !status.isEmpty()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 22f06c3471..eb3fa87f54 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -94,8 +94,11 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (serial != null) { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + - "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; + "WHERE DEVICE_TYPE_ID = t.ID " + + "AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD = 'serial' " + + "AND i.VALUE_FIELD = ? " + + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 044a681c9d..4393a4546e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -94,8 +94,11 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { if (serial != null) { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + - "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; + "WHERE DEVICE_TYPE_ID = t.ID " + + "AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD = 'serial' " + + "AND i.VALUE_FIELD = ? " + + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 5bcbbea8bc..66313603cb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -93,8 +93,11 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { if (serial != null) { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + - "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; + "WHERE DEVICE_TYPE_ID = t.ID " + + "AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD = 'serial' " + + "AND i.VALUE_FIELD = ? " + + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 95a69d3642..4e87d8ab61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -95,8 +95,11 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { if (serial != null) { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.ID= i.DEVICE_ID " + - "AND i.KEY_FIELD='serial' AND i.VALUE_FIELD = ? AND d.TENANT_ID = ? "; + "WHERE DEVICE_TYPE_ID = t.ID " + + "AND d.ID= i.DEVICE_ID " + + "AND i.KEY_FIELD = 'serial' " + + "AND i.VALUE_FIELD = ? " + + "AND d.TENANT_ID = ? "; isSerialProvided = true; } else { sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; From c2369cde71ec6c8ef96539d636d2804fd815eb2e Mon Sep 17 00:00:00 2001 From: vigneshan Date: Thu, 6 May 2021 22:42:37 +0530 Subject: [PATCH 17/49] Fix session expire issue during sso authorization --- .../interceptor/SsoLoginCallbackHandler.java | 19 +++++++++++++------ .../request/interceptor/SsoLoginHandler.java | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java index 92bd0e6b70..c437398d20 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -27,7 +27,6 @@ import io.entgra.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -50,9 +49,7 @@ public class SsoLoginCallbackHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String code = req.getParameter("code"); HttpSession session = req.getSession(false); - String scope = session.getAttribute("scope").toString(); String iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTPS_PORT_ENV_VAR); - if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { iotsCorePort = System.getProperty(HandlerConstants.IOT_CORE_HTTP_PORT_ENV_VAR); } @@ -62,6 +59,19 @@ public class SsoLoginCallbackHandler extends HttpServlet { String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + HandlerConstants.COLON + iotsCorePort; + if (session == null) { + String baseContextPath = req.getContextPath(); + String applicationName = baseContextPath.substring(1, baseContextPath.indexOf("-ui-request-handler")); + if (applicationName.equals("entgra")) { + resp.sendRedirect(iotsCoreUrl + "/endpoint-mgt"); + } else { + resp.sendRedirect(iotsCoreUrl + "/" + applicationName); + } + return; + } + + String scope = session.getAttribute("scope").toString(); + HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); @@ -76,11 +86,9 @@ public class SsoLoginCallbackHandler extends HttpServlet { ProxyResponse tokenResultResponse = HandlerUtil.execute(tokenEndpoint); JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResultResponse.getData()); if (jTokenResult.isJsonObject()) { JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - AuthData authData = new AuthData(); authData.setClientId(session.getAttribute("clientId").toString()); authData.setClientSecret(session.getAttribute("clientSecret").toString()); @@ -89,7 +97,6 @@ public class SsoLoginCallbackHandler extends HttpServlet { authData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); authData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); - resp.sendRedirect(session.getAttribute("redirectUrl").toString()); } } diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index 1a5a550571..e23019d2c8 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -88,12 +88,12 @@ public class SsoLoginHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { httpSession = req.getSession(false); - if (httpSession != null) { httpSession.invalidate(); } httpSession = req.getSession(true); + httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT)); initializeAdminCredentials(); baseContextPath = req.getContextPath(); applicationName = baseContextPath.substring(1, baseContextPath.indexOf("-ui-request-handler")); From 2d6f3298bff49591e4fb7884d1da77f73acfe3c6 Mon Sep 17 00:00:00 2001 From: charithag Date: Fri, 7 May 2021 14:14:37 +0530 Subject: [PATCH 18/49] Add NOTNOW status to activity result --- .../carbon/device/mgt/common/operation/mgt/ActivityStatus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java index 1007c18058..234aa084c2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/ActivityStatus.java @@ -30,7 +30,7 @@ import java.util.List; public class ActivityStatus { public enum Status { - IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, INVALID, UNAUTHORIZED + IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, INVALID, UNAUTHORIZED, NOTNOW } @ApiModelProperty( From 515d6b5797f35b4b35a57fa638d83e32d414c6dd Mon Sep 17 00:00:00 2001 From: charithag Date: Fri, 7 May 2021 17:47:25 +0530 Subject: [PATCH 19/49] Allow dynamic control of operations --- .../dto/operation/mgt/CommandOperation.java | 8 ++++---- .../dto/operation/mgt/ConfigOperation.java | 18 +++++++----------- .../dto/operation/mgt/PolicyOperation.java | 14 +++++++------- .../dto/operation/mgt/ProfileOperation.java | 9 ++++----- .../core/operation/mgt/CommandOperation.java | 7 ++++--- .../core/operation/mgt/ConfigOperation.java | 19 +++++++++---------- .../core/operation/mgt/PolicyOperation.java | 9 +++++---- .../core/operation/mgt/ProfileOperation.java | 11 ++++++----- 8 files changed, 46 insertions(+), 49 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java index bc132a9b20..c7eb730c4e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/CommandOperation.java @@ -22,6 +22,10 @@ public class CommandOperation extends Operation { private boolean enabled; + public CommandOperation() { + setControl(Control.NO_REPEAT); + } + public boolean isEnabled() { return enabled; } @@ -34,8 +38,4 @@ public class CommandOperation extends Operation { return Type.COMMAND; } - public Control getControl(){ - return Control.NO_REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java index c2be65a372..28116d5dc6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ConfigOperation.java @@ -23,10 +23,11 @@ import java.util.List; public class ConfigOperation extends Operation { - private List properties; + private final List properties; public ConfigOperation() { - properties = new ArrayList(); + properties = new ArrayList<>(); + setControl(Control.REPEAT); } public List getConfigProperties() { @@ -37,6 +38,10 @@ public class ConfigOperation extends Operation { properties.add(new Property(name, value, type)); } + public Type getType() { + return Type.CONFIG; + } + public static class Property { private String name; private Object value; @@ -73,13 +78,4 @@ public class ConfigOperation extends Operation { } } - public Type getType() { - return Type.CONFIG; - } - - - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java index dc6ae4dd78..bc93bcf0f8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/PolicyOperation.java @@ -19,7 +19,13 @@ package org.wso2.carbon.device.mgt.core.dto.operation.mgt; import java.util.List; -public class PolicyOperation extends Operation{ +public class PolicyOperation extends Operation { + + private List profileOperations; + + public PolicyOperation() { + setControl(Control.REPEAT); + } public List getProfileOperations() { return profileOperations; @@ -29,10 +35,4 @@ public class PolicyOperation extends Operation{ this.profileOperations = profileOperations; } - private List profileOperations; - - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java index 107cf091d7..9e3db16f2e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/operation/mgt/ProfileOperation.java @@ -22,13 +22,12 @@ import java.io.Serializable; public class ProfileOperation extends ConfigOperation implements Serializable { + public ProfileOperation() { + super(); + } + public Type getType() { return Type.PROFILE; } - - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java index 3a9ecefca3..618c05adf3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/CommandOperation.java @@ -24,6 +24,10 @@ public class CommandOperation extends Operation { private boolean enabled; + public CommandOperation() { + setControl(Control.NO_REPEAT); + } + public boolean isEnabled() { return enabled; } @@ -35,8 +39,5 @@ public class CommandOperation extends Operation { public Type getType() { return Type.COMMAND; } - public Control getControl(){ - return Control.NO_REPEAT; - } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java index 69d8aafc4a..753b170a1b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ConfigOperation.java @@ -21,8 +21,6 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; public class ConfigOperation extends Operation { @@ -38,6 +36,15 @@ public class ConfigOperation extends Operation { properties.add(new Property(name, value, type)); }*/ + public ConfigOperation() { + //properties = new ArrayList<>(); + setControl(Control.REPEAT); + } + + public Type getType() { + return Type.CONFIG; + } + public static class Property implements Serializable { private String name; private Object value; @@ -74,12 +81,4 @@ public class ConfigOperation extends Operation { } } - public Type getType() { - return Type.CONFIG; - } - - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java index 6b36492a83..47ca55f95e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/PolicyOperation.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; + import java.util.List; public class PolicyOperation extends Operation { @@ -25,6 +26,10 @@ public class PolicyOperation extends Operation { public static final String POLICY_OPERATION_CODE = "POLICY_BUNDLE"; private List profileOperations; + public PolicyOperation() { + setControl(Control.REPEAT); + } + public List getProfileOperations() { return profileOperations; } @@ -33,8 +38,4 @@ public class PolicyOperation extends Operation { this.profileOperations = profileOperations; } - public Control getControl(){ - return Control.REPEAT; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java index 3423524666..ac1082317b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/ProfileOperation.java @@ -19,21 +19,21 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; public class ProfileOperation extends ConfigOperation implements Serializable { + private static final long serialVersionUID = -3322674908775087365L; private List correctiveActionIds; private List reactiveActionIds; - public Type getType() { - return Type.PROFILE; + public ProfileOperation() { + super(); } - public Control getControl(){ - return Control.REPEAT; + public Type getType() { + return Type.PROFILE; } public List getCorrectiveActionIds() { @@ -51,4 +51,5 @@ public class ProfileOperation extends ConfigOperation implements Serializable { public void setReactiveActionIds(List reactiveActionIds) { this.reactiveActionIds = reactiveActionIds; } + } From c33e13b04cb52f6163ee8b16340d7ed2a6b56715 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 09:41:45 +0530 Subject: [PATCH 20/49] updating to kernel 4.6.1 --- .../pom.xml | 4 +- .../pom.xml | 72 +- ...ApiApplicationRegistrationServiceImpl.java | 8 +- .../api/filter/ApiPermissionFilter.java | 7 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../pom.xml | 70 +- .../APIManagementProviderService.java | 9 +- .../APIManagementProviderServiceImpl.java | 300 +- ...ApplicationManagerExtensionDataHolder.java | 20 +- ...ationManagerExtensionServiceComponent.java | 28 +- .../pom.xml | 166 +- .../client/publisher/PublisherClient.java | 89 +- .../integration/client/store/StoreClient.java | 124 +- .../pom.xml | 268 +- .../src/main/resources/publisher-api.yaml | 14129 ++++++++++++---- .../pom.xml | 228 +- .../publisher/APIPublisherServiceImpl.java | 196 +- .../internal/APIPublisherDataHolder.java | 18 +- .../APIPublisherServiceComponent.java | 28 +- components/apimgt-extensions/pom.xml | 6 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 74 +- .../application/mgt/core/util/OAuthUtils.java | 2 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../pom.xml | 52 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../pom.xml | 40 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 3 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 17 +- .../DeviceManagementConfigServiceImpl.java | 4 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../pom.xml | 4 +- .../org.wso2.carbon.device.mgt.api/pom.xml | 67 +- .../api/DeviceEventManagementService.java | 466 +- .../service/api/GeoLocationBasedService.java | 366 +- .../service/impl/DeviceAgentServiceImpl.java | 52 +- .../DeviceEventManagementServiceImpl.java | 622 +- .../impl/GeoLocationBasedServiceImpl.java | 390 +- .../CredentialManagementResponseBuilder.java | 10 +- .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 61 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../org.wso2.carbon.device.mgt.common/pom.xml | 18 +- .../org.wso2.carbon.device.mgt.core/pom.xml | 62 +- .../mgt/core/DeviceManagementConstants.java | 2 + .../impl/DeviceInformationManagerImpl.java | 24 +- .../DeviceManagementProviderServiceImpl.java | 34 +- .../mgt/core/util/DeviceManagerUtil.java | 24 +- .../pom.xml | 6 +- .../pom.xml | 4 +- components/device-mgt/pom.xml | 4 +- .../pom.xml | 28 +- .../pom.xml | 9 +- .../grant/AccessTokenGrantHandler.java | 5 +- .../grant/ExtendedJWTGrantHandler.java | 8 +- .../ExtendedSAML2BearerGrantHandler.java | 5 +- .../pom.xml | 4 +- .../pom.xml | 4 +- components/identity-extensions/pom.xml | 4 +- .../pom.xml | 6 +- .../org.wso2.carbon.policy.mgt.core/pom.xml | 4 +- components/policy-mgt/pom.xml | 2 +- .../org.wso2.carbon.email.sender.core/pom.xml | 4 +- .../pom.xml | 26 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../io.entgra.ui.request.interceptor/pom.xml | 31 +- .../request/interceptor/InvokerHandler.java | 9 +- .../ui/request/interceptor/LoginHandler.java | 77 +- .../interceptor/SsoLoginCallbackHandler.java | 2 +- .../request/interceptor/SsoLoginHandler.java | 6 +- .../ui/request/interceptor/UserHandler.java | 33 +- .../interceptor/util/HandlerConstants.java | 3 +- .../request/interceptor/util/HandlerUtil.java | 19 +- .../webapp/META-INF/webapp-classloading.xml | 2 +- .../pom.xml | 22 +- .../pom.xml | 6 +- .../conf/webapp-publisher-config.xml | 2 +- features/apimgt-extensions/pom.xml | 4 +- .../application-mgt-datasources.xml | 2 +- features/certificate-mgt/pom.xml | 1 - .../pom.xml | 98 +- .../apis/admin--OAuth2TokenManagement.xml | 2 +- .../admin--UserManagementValidateUser.xml | 2 +- .../src/main/resources/conf/mdm-ui-config.xml | 2 +- .../pom.xml | 4 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 16 +- pom.xml | 143 +- 96 files changed, 13684 insertions(+), 5135 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 4c32e6f2ae..a530cbcfa1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -73,8 +73,8 @@ org.wso2.carbon.apimgt.annotations.* - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, javax.servlet, javax.xml.*, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index a77543fc93..9ec68e7315 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -34,42 +34,56 @@ http://wso2.org + + io.swagger + swagger-annotations + + + org.springframework + spring-web + provided + + + org.apache.cxf + cxf-bundle-jaxrs + provided + - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - + + + + + + + + + + + + + + + - - org.codehaus.jackson - jackson-core-asl - + + + + org.codehaus.jackson jackson-jaxrs - - javax - javaee-web-api - provided - - - javax.ws.rs - jsr311-api - provided - + + + + + + + + + + commons-httpclient.wso2 commons-httpclient diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index aec0df4a16..96d3c8e059 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -27,8 +27,8 @@ import org.wso2.carbon.apimgt.application.extension.api.util.RegistrationProfile import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; -import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; -import org.wso2.carbon.apimgt.integration.client.store.StoreClient; +//import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; +//import org.wso2.carbon.apimgt.integration.client.store.StoreClient; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; @@ -110,12 +110,10 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { - StoreClient storeClient = new StoreClient(new OAuthRequestInterceptor(registrationProfile.getUsername(), - registrationProfile.getPassword())); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, - registrationProfile.isAllowedToAllDomains(), validityPeriod, storeClient); + registrationProfile.isAllowedToAllDomains(), validityPeriod); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java index 0c78488a2d..fc3efadb42 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java @@ -25,7 +25,12 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import javax.servlet.*; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.bind.JAXBContext; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/webapp-classloading.xml index b410b42670..5cb6aa6282 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index a04bf65bb9..9e70ed3009 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -51,14 +51,25 @@ org.wso2.carbon org.wso2.carbon.logging - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.integration.client - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.integration.generated.client - + + + + + + + + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + 9.0.5 + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.impl + 9.0.5 + provided + com.googlecode.json-simple.wso2 json-simple @@ -72,6 +83,11 @@ org.wso2.carbon.identity.jwt.client.extension provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + provided + @@ -100,24 +116,26 @@ ${carbon.device.mgt.version} API Management Application Bundle org.wso2.carbon.apimgt.application.extension.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging.*, - org.wso2.carbon.user.core.*, - org.wso2.carbon.user.api, - org.wso2.carbon.utils.multitenancy, - org.json.simple, - org.wso2.carbon.context, - org.wso2.carbon.base, - org.wso2.carbon.registry.core.*;resolution:=optional, - org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", - org.wso2.carbon.apimgt.integration.client.*, - org.wso2.carbon.apimgt.integration.generated.client.store.api, - org.wso2.carbon.apimgt.integration.generated.client.store.model, - org.wso2.carbon.identity.jwt.client.extension.*, - feign - + + org.apache.commons.lang;version="[2.6,3)",org.apache.c + ommons.logging;version="[1.2,2)",org.json.simple,org.osgi.framework;v + ersion="${imp.package.version.osgi.framework}",org.osgi.service.component;version="${imp.package.version.osgi.service}",org.wso + 2.carbon.apimgt.api;version="[9.0,10)",org.wso2.carbon.apimgt.api.dto + ;version="[9.0,10)",org.wso2.carbon.apimgt.api.model;version="[9.0,10 + )",org.wso2.carbon.apimgt.application.extension.bean,org.wso2.carbon. + apimgt.application.extension.dto,org.wso2.carbon.apimgt.application.e + xtension.exception,org.wso2.carbon.apimgt.impl;version="[9.0,10)",org + .wso2.carbon.apimgt.impl.utils;version="[9.0,10)",org.wso2.carbon.con + text;version="[4.6,5)",org.wso2.carbon.device.mgt.core.config.ui;vers + ion="[4.1,5)",org.wso2.carbon.identity.jwt.client.extension,org.wso2. + carbon.identity.jwt.client.extension.dto,org.wso2.carbon.identity.jwt + .client.extension.exception,org.wso2.carbon.identity.jwt.client.exten + sion.service,org.wso2.carbon.registry.core.exceptions;version="[1.0,2 + )",org.wso2.carbon.registry.core.service;version="[1.0,2)",org.wso2.c + arbon.registry.indexing.service;version="[4.7,5)",org.wso2.carbon.use + r.api;version="[1.0,2)",org.wso2.carbon.user.core.service;version="[4 + .6,5)",org.wso2.carbon.user.core.tenant;version="[4.6,5)" + !org.wso2.carbon.apimgt.application.extension.internal, org.wso2.carbon.apimgt.application.extension.* diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java index 62d353d0fd..67fe9e2583 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java @@ -20,8 +20,9 @@ package org.wso2.carbon.apimgt.application.extension; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; -import org.wso2.carbon.apimgt.integration.client.store.StoreClient; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +//import org.wso2.carbon.apimgt.integration.client.store.StoreClient; +//import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; /** * This comprise on operation that is been done with api manager from CDMF. This service needs to be implemented in APIM. @@ -61,17 +62,17 @@ public interface APIManagementProviderService { * @param username to whom the application is created * @param isAllowedAllDomains application is allowed to all the tenants * @param validityTime validity period of the application - * @param storeClient Specified store client +// * @param storeClient Specified store client * @return consumerkey and secrete of the created application. * @throws APIManagerException */ + ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], String keyType, String username, boolean isAllowedAllDomains, - String validityTime, - StoreClient storeClient) throws APIManagerException; + String validityTime, String scopes) throws APIManagerException; /** * Remove APIM Application. diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0c957fd4e7..cc385dff44 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -18,19 +18,46 @@ package org.wso2.carbon.apimgt.application.extension; -import feign.FeignException; +//import feign.FeignException; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.api.APIAdmin; +import org.wso2.carbon.apimgt.api.APIConsumer; +import org.wso2.carbon.apimgt.api.APIManagementException; +import org.wso2.carbon.apimgt.api.APIProvider; +import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; +import org.wso2.carbon.apimgt.api.model.API; +import org.wso2.carbon.apimgt.api.model.APIKey; +import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; +import org.wso2.carbon.apimgt.api.model.Application; +import org.wso2.carbon.apimgt.api.model.KeyManagerConfiguration; +import org.wso2.carbon.apimgt.api.model.SubscribedAPI; +import org.wso2.carbon.apimgt.api.model.Subscriber; import org.wso2.carbon.apimgt.application.extension.bean.APIRegistrationProfile; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; -import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; -import org.wso2.carbon.apimgt.integration.client.store.StoreClient; -import org.wso2.carbon.apimgt.integration.generated.client.store.model.*; +import org.wso2.carbon.apimgt.impl.APIAdminImpl; +import org.wso2.carbon.apimgt.impl.APIConstants; +import org.wso2.carbon.apimgt.impl.APIManagerFactory; +//import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; +//import org.wso2.carbon.apimgt.integration.client.store.StoreClient; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIInfo; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIList; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Application; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationInfo; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKey; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKeyGenerateRequest; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationList; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Subscription; +//import org.wso2.carbon.apimgt.integration.generated.client.store.model.SubscriptionList; +import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager; import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; @@ -39,7 +66,11 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; /** * This class represents an implementation of APIManagementProviderService. @@ -50,48 +81,66 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private static final String CONTENT_TYPE = "application/json"; private static final int MAX_API_PER_TAG = 200; private static final String APP_TIER_TYPE = "application"; + public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); + @Override public boolean isTierLoaded() { - StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() - .getStoreClient(); +// StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() +// .getStoreClient(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() .getTenantDomain(); +// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); +// try { try { - storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, - APP_TIER_TYPE, - tenantDomain, CONTENT_TYPE, null, null); - return true; - } catch (FeignException e) { - log.error("Feign Exception", e); - if (e.status() == 401) { - OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); - String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - oAuthRequestInterceptor.removeToken(username, tenantDomain); - try { - storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, - APP_TIER_TYPE, tenantDomain, CONTENT_TYPE, null, null); - } catch (FeignException ex) { - log.error("Invalid Attempt : " + ex); - } - } - } catch (Exception e) { + APIUtil.getTiers(APIConstants.TIER_APPLICATION_TYPE, tenantDomain); + } catch (APIManagementException e) { log.error("APIs not ready", e); } - return false; + // storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, +// APP_TIER_TYPE, +// tenantDomain, CONTENT_TYPE, null, null); + return true; +// } catch (FeignException e) { +// log.error("Feign Exception", e); +// if (e.status() == 401) { +// OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); +// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); +// oAuthRequestInterceptor.removeToken(username, tenantDomain); +// try { +// storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, +// APP_TIER_TYPE, tenantDomain, CONTENT_TYPE, null, null); +// } catch (FeignException ex) { +// log.error("Invalid Attempt : " + ex); +// } +// } +// } catch (Exception e) { +// log.error("APIs not ready", e); +// } +// return false; } @Override public void removeAPIApplication(String applicationName, String username) throws APIManagerException { - StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() - .getStoreClient(); - ApplicationList applicationList = storeClient.getApplications() - .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); - if (applicationList.getList() != null && applicationList.getList().size() > 0) { - ApplicationInfo applicationInfo = applicationList.getList().get(0); - storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), - null, null); +// StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() +// .getStoreClient(); +// ApplicationList applicationList = storeClient.getApplications() +// .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); + try { + APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); + Application application = apiConsumer.getApplicationsByName(username, applicationName, ""); + if (application != null) { +// ApplicationInfo applicationInfo = applicationList.getList().get(0); +// storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), +// null, null); + apiConsumer.removeApplication(application, username); + } + } catch (APIManagementException e) { + //todo:amalka + e.printStackTrace(); } + + } /** @@ -100,94 +149,80 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], String keyType, String username, - boolean isAllowedAllDomains, String validityTime, - StoreClient sClient) throws APIManagerException { + boolean isAllowedAllDomains, + String validityTime, String scopes) throws APIManagerException { - StoreClient storeClient; - - if (sClient == null) { - storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() - .getStoreClient(); - } else { - storeClient = sClient; + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + if (StringUtils.isEmpty(username)) { + username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); } - - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() - .getTenantDomain(); try { - ApplicationList applicationList = storeClient.getApplications() - .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); - Application application; - if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) { - //create application; - application = new Application(); - application.setName(applicationName); - application.setSubscriber(username); - application.setDescription(""); - application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER); - application.setGroupId(""); - application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE); - } else { - ApplicationInfo applicationInfo = applicationList.getList().get(0); - application = storeClient.getIndividualApplication() - .applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null); - } + APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); + Application application = apiConsumer.getApplicationsByName(username, applicationName, ""); + + int applicationId = 0; + Subscriber subscriber = null; if (application == null) { - throw new APIManagerException( - "Api application creation failed for " + applicationName + " to the user " + username); + subscriber = apiConsumer.getSubscriber(username); + if (subscriber == null) { + // create subscriber + apiConsumer.addSubscriber(username, ""); + subscriber = apiConsumer.getSubscriber(username); + } + //create application + application = new Application(applicationName, subscriber); + application.setTier(ApiApplicationConstants.DEFAULT_TIER); + application.setGroupId(""); + applicationId = apiConsumer.addApplication(application, username); + } else { + applicationId = application.getId(); + subscriber = apiConsumer.getSubscriber(username); } - SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet - (null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null); - List needToSubscribe = new ArrayList<>(); + Set subscribedAPIs = + apiConsumer.getSubscribedAPIsByApplicationId(subscriber, applicationId, ""); + + log.info("Already subscribed API count: " + subscribedAPIs.size()); + // subscribe to apis. + Set tempApiIds = new HashSet<>(); if (tags != null && tags.length > 0) { for (String tag : tags) { - APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag - , CONTENT_TYPE, null); - if (apiList.getList() == null || apiList.getList().size() == 0) { - apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0 - , MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null); + Set apisWithTag = apiConsumer.getAPIsWithTag(tag, tenantDomain); + if (apisWithTag == null || apisWithTag.size() == 0) { + apisWithTag = apiConsumer.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); } - if (apiList.getList() != null && apiList.getList().size() > 0) { - for (APIInfo apiInfo : apiList.getList()) { - String id = apiInfo.getProvider().replace("@", "-AT-") - + "-" + apiInfo.getName() + "-" + apiInfo.getVersion(); - id = id.replace(" ", "+"); + if (apisWithTag != null && apisWithTag.size() > 0) { + for (API apiInfo : apisWithTag) { + String id = apiInfo.getId().getProviderName().replace("@", "-AT-") + + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); + // todo: amalka will this break old apis? boolean subscriptionExist = false; - if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) { - for (Subscription subs : subscriptionList.getList()) { - if (subs.getApiIdentifier().equals(id)) { + if (subscribedAPIs.size() > 0) { + for (SubscribedAPI subscribedAPI : subscribedAPIs) { + if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { subscriptionExist = true; break; } } } - if (!subscriptionExist) { - Subscription subscription = new Subscription(); - //fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0 - - subscription.setApiIdentifier(id); - subscription.setApplicationId(application.getApplicationId()); - subscription.tier(ApiApplicationConstants.DEFAULT_TIER); - if (!needToSubscribe.contains(subscription)) { - needToSubscribe.add(subscription); - } + if (!subscriptionExist && !tempApiIds.contains(id)) { + ApiTypeWrapper apiTypeWrapper = new ApiTypeWrapper(apiInfo); + apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); + apiConsumer.addSubscription(apiTypeWrapper, username, applicationId, ""); + tempApiIds.add(id); } } } } } - if (!needToSubscribe.isEmpty()) { - storeClient.getSubscriptionMultitpleApi().subscriptionsMultiplePost(needToSubscribe, CONTENT_TYPE); - } //end of subscription - List applicationKeys = application.getKeys(); + List applicationKeys = application.getKeys(); if (applicationKeys != null) { - for (ApplicationKey applicationKey : applicationKeys) { - if (keyType.equals(applicationKey.getKeyType().toString())) { + for (APIKey applicationKey : applicationKeys) { + if (keyType.equals(applicationKey.getType())) { if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); @@ -198,33 +233,74 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } - ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest(); List allowedDomains = new ArrayList<>(); if (isAllowedAllDomains) { allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); } else { allowedDomains.add(APIManagerUtil.getTenantDomain()); } - applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains); - applicationKeyGenerateRequest.setCallbackUrl(""); - applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION); - applicationKeyGenerateRequest.setValidityTime(validityTime); - ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost( - application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null); - if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; + APIAdmin apiAdmin = new APIAdminImpl(); + String keyManagerId = null; + try { + List keyManagerConfigurations = apiAdmin + .getKeyManagerConfigurationsByTenant(tenantDomain); + if (keyManagerConfigurations != null) { + for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { + keyManagerId = keyManagerConfigurationDTO.getUuid(); + } + } + String jsonString = "{\"grant_types\":\"refresh_token,urn:ietf:params:oauth:grant-type:saml2-bearer," + + "password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," + + "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"N\\/A\\\"," + + "\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," + + "\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," + + "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + + "\"username\":\"" + username + "\"}"; + + // if scopes not defined + if (StringUtils.isEmpty(scopes)) { + UIConfigurationManager uiConfigurationManager = UIConfigurationManager.getInstance(); + UIConfiguration uiConfiguration = uiConfigurationManager.getUIConfig(); + List scopeList = uiConfiguration.getScopes(); + + if (scopeList != null && scopeList.size() > 0) { + StringBuilder builder = new StringBuilder(); + for (String scope : scopeList) { + String tmpScope = scope + " "; + builder.append(tmpScope); + } + scopes = builder.toString(); + } + + if (StringUtils.isEmpty(scopes)) { + scopes = scopes.trim(); + } else { + scopes = "default"; + } + } + + Map keyDetails = apiConsumer + .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", + allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, scopes, "", + jsonString, keyManagerId, tenantDomain); + + if (keyDetails != null) { + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey")); + apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret")); + return apiApplicationKey; + } + throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); + } catch (APIManagementException e) { + throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); } - throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); - } catch (FeignException e) { + } catch (APIManagementException e) { throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); } } - /** + /** * {@inheritDoc} */ @Override @@ -311,7 +387,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) { info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), - registrationProfile.getTags(), tokenType, registrationProfile.getApplicationName(), + registrationProfile.getTags(), tokenType, null, registrationProfile.isAllowedToAllDomains(), validityPeriod); } } finally { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 90f297e6d3..368fda3a3b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,7 +18,7 @@ package org.wso2.carbon.apimgt.application.extension.internal; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; @@ -35,7 +35,7 @@ public class APIApplicationManagerExtensionDataHolder { private TenantManager tenantManager; private TenantRegistryLoader tenantRegistryLoader; private TenantIndexingLoader indexLoader; - private IntegrationClientService integrationClientService; +// private IntegrationClientService integrationClientService; private JWTClientManagerService jwtClientManagerService; private APIApplicationManagerExtensionDataHolder() { @@ -94,14 +94,14 @@ public class APIApplicationManagerExtensionDataHolder { return indexLoader; } - public IntegrationClientService getIntegrationClientService() { - return integrationClientService; - } - - public void setIntegrationClientService( - IntegrationClientService integrationClientService) { - this.integrationClientService = integrationClientService; - } +// public IntegrationClientService getIntegrationClientService() { +// return integrationClientService; +// } +// +// public void setIntegrationClientService( +// IntegrationClientService integrationClientService) { +// this.integrationClientService = integrationClientService; +// } public JWTClientManagerService getJwtClientManagerService() { if (jwtClientManagerService == null) { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 9d28c89f16..4d98527956 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -23,7 +23,7 @@ import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext;; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; @@ -49,12 +49,6 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" - * @scr.reference name="integration.client.service" - * interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService" - * cardinality="1..1" - * policy="dynamic" - * bind="setIntegrationClientService" - * unbind="unsetIntegrationClientService" */ public class APIApplicationManagerExtensionServiceComponent { @@ -97,16 +91,16 @@ public class APIApplicationManagerExtensionServiceComponent { APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null); } - protected void setIntegrationClientService(IntegrationClientService integrationClientService) { - if (integrationClientService != null && log.isDebugEnabled()) { - log.debug("integrationClientService initialized"); - } - APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService); - } - - protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { - APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null); - } +// protected void setIntegrationClientService(IntegrationClientService integrationClientService) { +// if (integrationClientService != null && log.isDebugEnabled()) { +// log.debug("integrationClientService initialized"); +// } +// APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService); +// } +// +// protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { +// APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null); +// } /** * Sets Realm Service. diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index eeddf628a5..0784f282aa 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -47,46 +47,39 @@ org.wso2.carbon.apimgt.integration.client.*, !org.wso2.carbon.apimgt.integration.client.internal - - org.osgi.framework, - org.osgi.service.component, - feign, - feign.codec, - feign.auth, - feign.gson, - feign.slf4j, - org.wso2.carbon.apimgt.integration.generated.client.publisher.api, - org.wso2.carbon.apimgt.integration.generated.client.store.api, - javax.xml.bind, - javax.xml.bind.annotation, - javax.xml.parsers;resolution:=optional, - org.apache.commons.logging, - org.w3c.dom, - org.wso2.carbon.context, - org.wso2.carbon.identity.jwt.client.*, - org.wso2.carbon.user.api, - org.wso2.carbon.utils, - com.fasterxml.jackson.annotation, - io.swagger.annotations, - org.wso2.carbon.core.util, - javax.xml, - org.wso2.carbon.base, - javax.net.ssl, - org.apache.commons.lang, - android.util;resolution:=optional, - javax.annotation;resolution:=optional, - javax.net;resolution:=optional, - javax.security.auth.x500;resolution:=optional, - javax.crypto;resolution:=optional, - javax.crypto.spec;resolution:=optional - - - jsr311-api, - feign-jaxrs, - feign-okhttp, - okhttp, - okio - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -120,55 +113,60 @@ - - com.squareup.okhttp3 - okhttp - - - com.squareup.okio - okio - + + + + + + + + io.github.openfeign feign-okhttp - - org.wso2.carbon - org.wso2.carbon.logging - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - com.google.code.gson - gson - - - javax.ws.rs - jsr311-api - + + io.github.openfeign + feign-slf4j + 10.7.2 + + + + + + + + + + + + + + + + + + + + + - - io.swagger - swagger-annotations - - - junit - junit - + + + + + + + + io.github.openfeign feign-core - - io.github.openfeign - feign-jackson - + + + + io.github.openfeign feign-jaxrs @@ -178,10 +176,10 @@ feign-gson - - org.testng - testng - + + + + org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java index 3887d59c66..73a4234a91 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java @@ -27,7 +27,8 @@ import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.*; +import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApIsApi; +import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApiLifecycleApi; import org.wso2.carbon.core.util.Utils; /** @@ -36,13 +37,15 @@ import org.wso2.carbon.core.util.Utils; public class PublisherClient { private static final Log log = LogFactory.getLog(PublisherClient.class); - private APIIndividualApi api = null; - private APICollectionApi apis = null; - private DocumentIndividualApi document = null; - private ApplicationIndividualApi application = null; - private EnvironmentCollectionApi environments = null; - private SubscriptionCollectionApi subscriptions = null; - private ThrottlingTierCollectionApi tiers = null; + private ApIsApi apIsApi = null; + private ApiLifecycleApi apiLifecycleApi = null; +// private APIIndividualApi api = null; +// private APICollectionApi apis = null; +// private DocumentIndividualApi document = null; +// private ApplicationIndividualApi application = null; +// private EnvironmentCollectionApi environments = null; +// private SubscriptionApi subscriptions = null; +// private ThrottlingTierCollectionApi tiers = null; /** @@ -57,40 +60,50 @@ public class PublisherClient { .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint()); - api = builder.target(APIIndividualApi.class, basePath); - apis = builder.target(APICollectionApi.class, basePath); - document = builder.target(DocumentIndividualApi.class, basePath); - application = builder.target(ApplicationIndividualApi.class, basePath); - environments = builder.target(EnvironmentCollectionApi.class, basePath); - subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); - tiers = builder.target(ThrottlingTierCollectionApi.class, basePath); + apIsApi = builder.target(ApIsApi.class, basePath); + apiLifecycleApi = builder.target(ApiLifecycleApi.class, basePath); +// api = builder.target(APIIndividualApi.class, basePath); +// apis = builder.target(APICollectionApi.class, basePath); +// document = builder.target(DocumentIndividualApi.class, basePath); +// application = builder.target(ApplicationIndividualApi.class, basePath); +// environments = builder.target(EnvironmentCollectionApi.class, basePath); +// subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); +// tiers = builder.target(ThrottlingTierCollectionApi.class, basePath); } - public APIIndividualApi getApi() { - return api; + public ApIsApi getApIsApi() { + return apIsApi; } - public APICollectionApi getApis() { - return apis; + public ApiLifecycleApi getApiLifecycleApi() { + return apiLifecycleApi; } - public DocumentIndividualApi getDocument() { - return document; - } - - public ApplicationIndividualApi getApplication() { - return application; - } - - public EnvironmentCollectionApi getEnvironments() { - return environments; - } - - public SubscriptionCollectionApi getSubscriptions() { - return subscriptions; - } - - public ThrottlingTierCollectionApi getTiers() { - return tiers; - } + // public APIIndividualApi getApi() { +// return api; +// } +// +// public APICollectionApi getApis() { +// return apis; +// } +// +// public DocumentIndividualApi getDocument() { +// return document; +// } +// +// public ApplicationIndividualApi getApplication() { +// return application; +// } +// +// public EnvironmentCollectionApi getEnvironments() { +// return environments; +// } +// +// public SubscriptionCollectionApi getSubscriptions() { +// return subscriptions; +// } +// +// public ThrottlingTierCollectionApi getTiers() { +// return tiers; +// } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java index db751f204e..5d8a46d586 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java @@ -39,16 +39,17 @@ import java.util.concurrent.TimeUnit; public class StoreClient { private static final org.apache.commons.logging.Log log = LogFactory.getLog(StoreClient.class); - private APICollectionApi apis = null; - private APIIndividualApi individualApi = null; - private ApplicationCollectionApi applications = null; - private ApplicationIndividualApi individualApplication = null; - private SubscriptionCollectionApi subscriptions = null; - private SubscriptionIndividualApi individualSubscription = null; - private SubscriptionMultitpleApi subscriptionMultitpleApi = null; - private ThrottlingTierIndividualApi individualTier = null; - private TagCollectionApi tags = null; - private ThrottlingTierCollectionApi tiers = null; + private ApplicationsApi applicationsApi = null; +// private APICollectionApi apis = null; +// private ApIsApi individualApi = null; +// private ApplicationsApi applications = null; +// private ApplicationIndividualApi individualApplication = null; +// private SubscriptionCollectionApi subscriptions = null; +// private SubscriptionIndividualApi individualSubscription = null; +// private SubscriptionMultitpleApi subscriptionMultitpleApi = null; +// private ThrottlingTierIndividualApi individualTier = null; +// private TagsApi tags = null; +// private ThrottlingTierCollectionApi tiers = null; public StoreClient(RequestInterceptor requestInterceptor) { @@ -60,58 +61,59 @@ public class StoreClient { .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint()); - apis = builder.target(APICollectionApi.class, basePath); - individualApi = builder.target(APIIndividualApi.class, basePath); - applications = builder.target(ApplicationCollectionApi.class, basePath); - individualApplication = builder.target(ApplicationIndividualApi.class, basePath); - subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); - individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath); - subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath); - tags = builder.target(TagCollectionApi.class, basePath); - individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath); - tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1)) - .options(new Request.Options(10000, 5000)) - .target(ThrottlingTierCollectionApi.class, basePath); + applicationsApi = builder.target(ApplicationsApi.class, basePath); +// apis = builder.target(APICollectionApi.class, basePath); +// individualApi = builder.target(ApIsApi.class, basePath); +// applications = builder.target(ApplicationCollectionApi.class, basePath); +// individualApplication = builder.target(ApplicationIndividualApi.class, basePath); +// subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); +// individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath); +// subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath); +// tags = builder.target(TagCollectionApi.class, basePath); +// individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath); +// tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1)) +// .options(new Request.Options(10000, 5000)) +// .target(ThrottlingTierCollectionApi.class, basePath); } - public APICollectionApi getApis() { - return apis; - } - - public APIIndividualApi getIndividualApi() { - return individualApi; - } - - public ApplicationCollectionApi getApplications() { - return applications; - } - - public ApplicationIndividualApi getIndividualApplication() { - return individualApplication; - } - - public SubscriptionCollectionApi getSubscriptions() { - return subscriptions; - } - - public SubscriptionIndividualApi getIndividualSubscription() { - return individualSubscription; - } - - public ThrottlingTierIndividualApi getIndividualTier() { - return individualTier; - } - - public TagCollectionApi getTags() { - return tags; - } - - public ThrottlingTierCollectionApi getTiers() { - return tiers; - } - - public SubscriptionMultitpleApi getSubscriptionMultitpleApi() { - return subscriptionMultitpleApi; - } +// public APICollectionApi getApis() { +// return apis; +// } +// +// public APIIndividualApi getIndividualApi() { +// return individualApi; +// } +// +// public ApplicationCollectionApi getApplications() { +// return applications; +// } +// +// public ApplicationIndividualApi getIndividualApplication() { +// return individualApplication; +// } +// +// public SubscriptionCollectionApi getSubscriptions() { +// return subscriptions; +// } +// +// public SubscriptionIndividualApi getIndividualSubscription() { +// return individualSubscription; +// } +// +// public ThrottlingTierIndividualApi getIndividualTier() { +// return individualTier; +// } +// +// public TagCollectionApi getTags() { +// return tags; +// } +// +// public ThrottlingTierCollectionApi getTiers() { +// return tiers; +// } +// +// public SubscriptionMultitpleApi getSubscriptionMultitpleApi() { +// return subscriptionMultitpleApi; +// } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 22c399e5b7..cc300b8014 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -26,61 +26,59 @@ http://wso2.org + - - - io.swagger - swagger-codegen-maven-plugin - 2.2.1 - - - process-resources - publisher - - generate - - - ${project.basedir}/src/main/resources/publisher-api.yaml - java - - ${project.artifactId}.publisher.api - ${project.artifactId}.publisher.model - - feign - - - - process-resources - store - - generate - - - ${project.basedir}/src/main/resources/store-api.yaml - java - - ${project.artifactId}.store.api - ${project.artifactId}.store.model - - feign - - - - + + org.openapitools + openapi-generator-maven-plugin + 5.0.0 + + + process-resources + publisher + + generate + + + ${project.basedir}/src/main/resources/publisher-api.yaml + java + + ${project.artifactId}.publisher.api + ${project.artifactId}.publisher.model + + + + + process-resources + store + + generate + + + ${project.basedir}/src/main/resources/devportal-api.yaml + java + + ${project.artifactId}.store.api + ${project.artifactId}.store.model + + + + + com.google.code.maven-replacer-plugin replacer 1.5.2 - + process-resources - replace-for-swagger-genenerated-code-publisher + replace-for-openapi-genenerated-code-publisher replace - ${project.basedir}/target/generated-sources/swagger/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java + ${project.basedir}/target/generated-sources/openapi/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java CURRENT_TENANT @@ -115,28 +113,33 @@ org.wso2.carbon.apimgt.integration.generated.client.store.api.*, org.wso2.carbon.apimgt.integration.generated.client.store.model.* - - feign;version="${io.github.openfeign.version.range}", - feign.jackson;version="${io.github.openfeign.version.range}", - feign.codec;version="${io.github.openfeign.version.range}", - feign.auth;version="${io.github.openfeign.version.range}", - feign.gson;version="${io.github.openfeign.version.range}", - feign.slf4j;version="${io.github.openfeign.version.range}", - com.google.gson, - com.fasterxml.jackson.core;resolution:=optional, - com.fasterxml.jackson.annotation, - com.fasterxml.jackson.databind;resolution:=optional, - io.swagger.annotations, - javax.net.ssl, - com.fasterxml.jackson.datatype.joda;resolution:=optional, - org.apache.oltu.oauth2.client.*;resolution:=optional, - org.apache.oltu.oauth2.common.*;resolution:=optional, - org.junit;resolution:=optional, - - - jsr311-api, - feign-jaxrs - + + com.google.gson;version="[2.8,3)", + com.google.gson.annotations;version="[2.8,3)", + com.google.gson.internal.bind.util, + com.google.gson.reflect;version="[2.8,3)", + com.google.gson.stream;version="[2.8,3)", + io.gsonfire;version="[1.8,2)", + io.swagger.annotations;version="[1.5,2)", + javax.annotation;version="[3.0,4)", + javax.net.ssl, + okhttp3, + okhttp3.internal.http, + okhttp3.internal.tls, + okhttp3.logging, + okio, + org.apache.oltu.oauth2.client;version="[1.0,2)", + org.apache.oltu.oauth2.client.request;version="[1.0,2)", + org.apache.oltu.oauth2.client.response;version="[1.0,2)", + org.apache.oltu.oauth2.common.exception;version="[1.0,2)", + org.apache.oltu.oauth2.common.message.types;version="[1.0,2)", + org.threeten.bp;version="[1.5,2)", + org.threeten.bp.format;version="[1.5,2)", + org.threeten.bp.temporal;version="[1.5,2)", + org.wso2.carbon.apimgt.integration.generated.client.publisher.model, + org.wso2.carbon.apimgt.integration.generated.client.store.model + + @@ -145,60 +148,105 @@ + + + io.swagger.core.v3 + swagger-annotations + 2.1.7 + + + com.google.code.gson gson + 2.8.5 - - javax.ws.rs - jsr311-api - + + + + io.swagger swagger-annotations - - junit - junit - - - io.github.openfeign - feign-core - - - io.github.openfeign - feign-jackson - - - io.github.openfeign - feign-jaxrs - - - io.github.openfeign - feign-gson - - - org.testng - testng - - - org.apache.oltu.oauth2 - org.apache.oltu.oauth2.client - - - io.github.openfeign - feign-slf4j - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-databind - ${jackson-databind.version} - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - + + com.squareup.okhttp3 + okhttp + 4.9.1 + + + + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + 1.0.1 + + + + com.squareup.okhttp3 + logging-interceptor + 4.9.1 + + + + org.threeten + threetenbp + 1.5.0 + + + + io.gsonfire + gson-fire + 1.8.5 + + + io.swagger.parser.v3 + swagger-parser + 2.0.25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml index b2068857a7..76fdb6f92d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml @@ -1,115 +1,122 @@ - -swagger: '2.0' -###################################################### -# Prolog -###################################################### +# Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +# +# Licensed 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. +################################################################################ +openapi: 3.0.1 info: - version: "0.12.0" - title: "WSO2 API Manager - Publisher API" + title: WSO2 API Manager - Publisher API description: | - This specifies a **RESTful API** for WSO2 **API Manager** - Publisher. + This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. - Please see [full swagger definition](https://raw.githubusercontent.com/wso2/carbon-apimgt/v6.1.66/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher/src/main/resources/publisher-api.yaml) of the API which is written using [swagger 2.0](http://swagger.io/) specification. + # Authentication + Our REST APIs are protected using OAuth2 and access control is achieved through scopes. Before you start invoking + the the API you need to obtain an access token with the required scopes. This guide will walk you through the steps + that you will need to follow to obtain an access token. + First you need to obtain the consumer key/secret key pair by calling the dynamic client registration (DCR) endpoint. You can add your preferred grant types + in the payload. A Sample payload is shown below. + ``` + { + "callbackUrl":"www.google.lk", + "clientName":"rest_api_publisher", + "owner":"admin", + "grantType":"client_credentials password refresh_token", + "saasApp":true + } + ``` + Create a file (payload.json) with the above sample payload, and use the cURL shown bellow to invoke the DCR endpoint. Authorization header of this should contain the + base64 encoded admin username and password. + **Format of the request** + ``` + curl -X POST -H "Authorization: Basic Base64(admin_username:admin_password)" -H "Content-Type: application/json" + \ -d @payload.json https://:/client-registration/v0.17/register + ``` + **Sample request** + ``` + curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" + \ -d @payload.json https://localhost:9443/client-registration/v0.17/register + ``` + Following is a sample response after invoking the above curl. + ``` + { + "clientId": "fOCi4vNJ59PpHucC2CAYfYuADdMa", + "clientName": "rest_api_publisher", + "callBackURL": "www.google.lk", + "clientSecret": "a4FwHlq0iCIKVs2MPIIDnepZnYMa", + "isSaasApplication": true, + "appOwner": "admin", + "jsonString": "{\"grant_types\":\"client_credentials password refresh_token\",\"redirect_uris\":\"www.google.lk\",\"client_name\":\"rest_api123\"}", + "jsonAppAttribute": "{}", + "tokenType": null + } + ``` + Next you must use the above client id and secret to obtain the access token. + We will be using the password grant type for this, you can use any grant type you desire. + You also need to add the proper **scope** when getting the access token. All possible scopes for publisher REST API can be viewed in **OAuth2 Security** section + of this document and scope for each resource is given in **authorization** section of resource documentation. + Following is the format of the request if you are using the password grant type. + ``` + curl -k -d "grant_type=password&username=&password=" + \ -H "Authorization: Basic base64(cliet_id:client_secret)" + \ https://:/token + ``` + **Sample request** + ``` + curl https://localhost:8243/token -k \ + -H "Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h" \ + -d "grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create" + ``` + Shown below is a sample response to the above request. + ``` + { + "access_token": "e79bda48-3406-3178-acce-f6e4dbdcbb12", + "refresh_token": "a757795d-e69f-38b8-bd85-9aded677a97c", + "scope": "apim:api_create apim:api_view", + "token_type": "Bearer", + "expires_in": 3600 + } + ``` + Now you have a valid access token, which you can use to invoke an API. + Navigate through the API descriptions to find the required API, obtain an access token as described above and invoke the API with the authentication header. + If you use a different authentication mechanism, this process may change. + + # Try out in Postman + If you want to try-out the embedded postman collection with "Run in Postman" option, please follow the guidelines listed below. + * All of the OAuth2 secured endpoints have been configured with an Authorization Bearer header with a parameterized access token. Before invoking any REST API resource make sure you run the `Register DCR Application` and `Generate Access Token` requests to fetch an access token with all required scopes. + * Make sure you have an API Manager instance up and running. + * Update the `basepath` parameter to match the hostname and port of the APIM instance. + + [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/a09044034b5c3c1b01a9) contact: - name: "WSO2" - url: "http://wso2.com/products/api-manager/" - email: "architecture@wso2.com" + name: WSO2 + url: http://wso2.com/products/api-manager/ + email: architecture@wso2.com license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0.html" - -###################################################### -# The fixed parts of the URLs of the API -###################################################### - -# The schemes supported by the API -schemes: - - https - -# The domain of the API. -# This is configured by the customer during deployment. -# The given host is just an example. -host: apis.wso2.com - -# The base path of the API. -# Will be prefixed to all paths. -basePath: /api/am/publisher/v0.12 - -# The following media types can be passed as input in message bodies of the API. -# The actual media type must be specified in the Content-Type header field of the request. -# The default is json, i.e. the Content-Type header is not needed to -# be set, but supporting it serves extensibility. -consumes: - - application/json - -# The following media types may be passed as output in message bodies of the API. -# The media type(s) consumable by the requestor is specified in the Accept header field -# of the corresponding request. -# The actual media type returned will be specfied in the Content-Type header field -# of the of the response. -# The default of the Accept header is json, i.e. there is not needed to -# set the value, but supporting it serves extensibility. -produces: - - application/json - - -x-wso2-security: - apim: - x-wso2-scopes: - - description: "" - roles: admin - name: apim:api_view - key: apim:api_view - - description: "" - roles: admin - name: apim:api_create - key: apim:api_create - - description: "" - roles: admin - name: apim:api_publish - key: apim:api_publish - - description: "" - roles: admin - name: apim:tier_view - key: apim:tier_view - - description: "" - roles: admin - name: apim:tier_manage - key: apim:tier_manage - - description: "" - roles: admin - name: apim:subscription_view - key: apim:subscription_view - - description: "" - roles: admin - name: apim:subscription_block - key: apim:subscription_block - - description: "" - roles: admin - name: apim:mediation_policy_view - key: apim:mediation_policy_view - - description: "" - roles: admin - name: apim:api_workflow - key: apim:api_workflow - - -###################################################### -# The "API Collection" resource APIs -###################################################### + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: v2 +servers: + - url: https://apis.wso2.com/api/am/publisher/v2 +security: + - OAuth2Security: + - apim:api_view paths: + ###################################################### + # The "API Collection" resource APIs + ###################################################### /apis: - -#----------------------------------------------------- -# Retrieving the list of all APIs qualifying under a given search condition -#----------------------------------------------------- get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This sample API provides Account Status Validation\",\n \"name\": \"AccountVal\",\n \"context\": \"/account\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\",\n \"status\": \"PUBLISHED\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"name\": \"api1\",\n \"context\": \"/api1\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\",\n \"status\": \"PUBLISHED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" + tags: + - APIs summary: | Retrieve/Search APIs description: | @@ -117,9 +124,10 @@ paths: Each retrieved API is represented with a minimal amount of attributes. If you want to get complete details of an API, you need to use **Get details of an API** operation. parameters: - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - name : query + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/requestedTenant' + - name: query in: query description: | **Search condition**. @@ -127,610 +135,1011 @@ paths: You can search in attributes by using an **":"** modifier. Eg. - "provider:wso2" will match an API if the provider of the API is exactly "wso2". - - Additionally you can use wildcards. + "provider:wso2" will match an API if the provider of the API contains "wso2". + "provider:"wso2"" will match an API if the provider of the API is exactly "wso2". + "status:PUBLISHED" will match an API if the API is in PUBLISHED state. + "label:external" will match an API if it contains a Microgateway label called "external". + Also you can use combined modifiers Eg. - "provider:wso2*" will match an API if the provider of the API starts with "wso2". + name:pizzashack version:v1 will match an API if the name of the API is pizzashack and version is v1. - Supported attribute modifiers are [**version, context, status, - description, subcontext, doc, provider**] + Supported attribute modifiers are [**version, context, name, status, + description, subcontext, doc, provider, label**] If no advanced attribute modifier has been specified, the API names containing the search term will be returned as a result. - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - API (Collection) + Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) + schema: + type: string + - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/components/parameters/expand' + - $ref: '#/components/parameters/Accept' responses: 200: description: | OK. List of qualifying APIs is returned. - schema: - $ref: '#/definitions/APIList' headers: - Content-Type: - description: The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIList' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis"' + x-examples: + $ref: docs/examples/apis/apis_get.yaml + operationId: getAllAPIs -#----------------------------------------------------- -# Create a new API -API (Individual) -#----------------------------------------------------- post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"PUBLISHED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": false,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\": \"in\"},{\"name\":\"log_out_message\",\"type\": \"out\"}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\":\"in\",\"id\":\"142ece76-b208-4aab-b29a-f382045ed066\",\"shared\":false},{\"name\":\"log_out_message\",\"type\":\"out\",\"id\":\"b3527be8-95e6-41e0-8097-3276987b7d4b\",\"shared\":false}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - summary: Create a new API + tags: + - APIs + summary: Create a New API description: | This operation can be used to create a new API specifying the details of the API in the payload. The new API will be in `CREATED` state. There is a special capability for a user who has `APIM Admin` permission such that he can create APIs on behalf of other users. For that he can to specify `"provider" : "some_other_user"` in the payload so that the API's creator will be shown as `some_other_user` in the UI. parameters: - - in: body - name: body - description: | - API object that needs to be added - required: true + - name: openAPIVersion + in: query + description: Open api version schema: - $ref: '#/definitions/API' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/Authorization' - tags: - - API (Individual) + type: string + default: v3 + enum: + - v2 + - v3 + requestBody: + description: API object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/API' + required: true responses: 201: description: | Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/API' headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - Authorization: - description: | - The brearer token. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 415: - description: | - Unsupported Media Type. - The entity of the request was in a not supported format. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis"' + x-examples: + $ref: docs/examples/apis/apis_post.yaml + operationId: createAPI -###################################################### -# The "Individual API" resource APIs -###################################################### + ###################################################### + # The "Individual API" resource APIs + ###################################################### /apis/{apiId}: - -#----------------------------------------------------- -# Retrieve the details of an API definition -#----------------------------------------------------- get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - summary: Get details of an API + tags: + - APIs + summary: Get Details of an API description: | Using this operation, you can retrieve complete details of a single API. You need to provide the Id of the API to retrive it. parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/requestedTenant' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. Requested API is returned headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string - schema: - $ref: '#/definitions/API' + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + - apim:api_import_export + - apim:api_product_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f"' + x-examples: + $ref: docs/examples/apis/apis_id_get.yaml + operationId: getAPI -#----------------------------------------------------- -# Update the definition of an API -#----------------------------------------------------- put: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\",\"chicken\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\": \"in\"},{\"name\":\"log_out_message\",\"type\": \"out\"}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\"https\"],\r\n \"tags\": [\r\n \"chicken\",\r\n \"pizza\"\r\n ],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\":\"in\",\"id\":\"142ece76-b208-4aab-b29a-f382045ed066\",\"shared\":false},{\"name\":\"log_out_message\",\"type\":\"out\",\"id\":\"b3527be8-95e6-41e0-8097-3276987b7d4b\",\"shared\":false}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" + tags: + - APIs summary: Update an API description: | This operation can be used to update an existing API. But the properties `name`, `version`, `context`, `provider`, `state` will not be changed by this operation. parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - API object that needs to be added - required: true - schema: - $ref: '#/definitions/API' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + description: API object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/API' + required: true responses: 200: description: | OK. Successful response with updated API object - schema: - $ref: '#/definitions/API' headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/Forbidden' 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' + 409: + $ref: '#/components/responses/Conflict' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f"' + operationId: updateAPI -#----------------------------------------------------- -# Delete the definition of an API -#----------------------------------------------------- delete: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/6fb74674-4ab8-4b52-9886-f9a376985060" - x-wso2-request: | - DELETE https://localhost:9443/api/am/publisher/v0.12/apis/6fb74674-4ab8-4b52-9886-f9a376985060 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" + tags: + - APIs summary: Delete an API description: | This operation can be used to delete an existing API proving the Id of the API. parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' responses: 200: description: | OK. Resource successfully deleted. + content: {} 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/Forbidden' 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' + 409: + $ref: '#/components/responses/Conflict' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_delete + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f"' + operationId: deleteAPI -################################################################ -# The swagger resource of "Individual API" resource APIs -################################################################ + /apis/{apiId}/topics: + put: + tags: + - APIs + summary: Update Topics + description: This operation can be used to update topics of an existing API. + operationId: updateTopics + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + description: API object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/TopicList' + required: true + responses: + 200: + description: | + OK. + Successful response with updated API object + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' + + /apis/{apiId}/reimport-service: + put: + tags: + - APIs + summary: Update the Service that is used to create the API + description: This operation can be used to re-import the Service used to create the API + operationId: reimportServiceFromCatalog + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Successful response with updated API object + headers: + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' /apis/{apiId}/swagger: -#----------------------------------------------------- -# Retrieve the API swagger definition -#----------------------------------------------------- get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\nContent-Length: 329\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" - summary: Get swagger definition + tags: + - APIs + summary: Get Swagger Definition description: | This operation can be used to retrieve the swagger definition of an API. parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. Requested swagger document of the API is returned headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + type: string + example: "" 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f/swagger"' + operationId: getAPISwagger -#----------------------------------------------------- -# Update the API swagger definition -#----------------------------------------------------- put: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013\" -F apiDefinition=\"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\" -X PUT \"https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/swagger\"" - x-wso2-request: | - PUT https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/swagger - Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013 - Content-Length: 477 - Content-Type: multipart/form-data; boundary=------------------------4f51e636c0003d99 - - --------------------------4f51e636c0003d99 - Content-Disposition: form-data; name="apiDefinition" - - {"paths":{"\/*":{"get":{"x-auth-type":"Application","x-throttling-tier":"Unlimited","responses":{"200":{"description":"OK"}}}}},"x-wso2-security":{"apim":{"x-wso2-scopes":[]}},"swagger":"2.0","info":{"title":"PhoneVerification","description":"Verify a phone number","contact":{"email":"xx@ee.com","name":"xx"},"version":"1.0.0"}} - --------------------------4f51e636c0003d99-- - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" - summary: Update swagger definition + tags: + - APIs + summary: Update Swagger Definition description: | This operation can be used to update the swagger definition of an existing API. Swagger definition to be updated is passed as a form data parameter `apiDefinition`. parameters: - - $ref: '#/parameters/apiId' - - in: formData - name: apiDefinition - description: Swagger definition of the API - type: string - required: true - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + properties: + apiDefinition: + type: string + description: Swagger definition of the API + url: + type: string + description: Swagger definition URL of the API + file: + type: string + description: Swagger definitio as a file + format: binary responses: 200: description: | OK. Successful response with updated Swagger definition headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + type: string + example: "" 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/Forbidden' 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F apiDefinition=@swagger.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/swagger"' + operationId: updateAPISwagger -################################################################ -# The thumbnail resource of "Individual API" resource APIs -################################################################ + /apis/{apiId}/generate-mock-scripts: + post: + tags: + - APIs + summary: Generate Mock Response Payloads + description: | + This operation can be used to generate mock responses from examples of swagger definition of an API. + operationId: generateMockScripts + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested swagger document of the API is returned with example responses + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + type: string + example: "" + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f/generate-mock-scripts"' + + /apis/{apiId}/generated-mock-scripts: + get: + tags: + - APIs + summary: Get Generated Mock Response Payloads + description: | + This operation can be used to get generated mock responses from examples of swagger definition of an API. + operationId: getGeneratedMockScriptsOfAPI + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested swagger document of the API is returned with example responses + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/MockResponsePayloadList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f/generated-mock-scripts"' + + /apis/{apiId}/resource-policies: + get: + tags: + - API Resource Policies + summary: Get the Resource Policy(inflow/outflow) Definitions + description: | + This operation can be used to retrieve conversion policy resource definitions of an API. + parameters: + - $ref: '#/components/parameters/apiId' + - name: resourcePath + in: query + description: Resource path of the resource policy definition + schema: + type: string + - name: verb + in: query + description: HTTP verb of the resource path of the resource policy definition + schema: + type: string + - name: sequenceType + in: query + description: sequence type of the resource policy resource definition + required: true + schema: + type: string + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + List of resource policy definitions of the API is returned + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ResourcePolicyList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/resource-policies?resourcePath=checkPhoneNumber&verb=post&sequenceType=in"' + operationId: getAPIResourcePolicies + + /apis/{apiId}/resource-policies/{resourcePolicyId}: + get: + tags: + - API Resource Policies + summary: Get the Resource Policy(inflow/outflow) Definition for a Given Resource + Identifier. + description: | + This operation can be used to retrieve conversion policy resource definitions of an API given the resource identifier. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/resourcePolicyId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested resource policy definition of the API is returned for the given resource identifier. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ResourcePolicyInfo' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/resource-policies/8efc32a4-c7f1-4bee-b860-b7566e2bc0d5"' + operationId: getAPIResourcePoliciesByPolicyId + + put: + tags: + - API Resource Policies + summary: Update the Resource Policy(inflow/outflow) Definition for the Given + Resource Identifier + description: | + This operation can be used to update the resource policy(inflow/outflow) definition for the given resource identifier of an existing API. resource policy definition to be updated is passed as a body parameter `content`. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/resourcePolicyId' + - $ref: '#/components/parameters/If-Match' + requestBody: + description: Content of the resource policy definition that needs to be updated + content: + application/json: + schema: + $ref: '#/components/schemas/ResourcePolicyInfo' + required: true + responses: + 200: + description: | + OK. + Successful response with updated the resource policy definition + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ResourcePolicyInfo' + 400: + $ref: '#/components/responses/BadRequest' + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/resource-policies/8efc32a4-c7f1-4bee-b860-b7566e2bc0d5"' + operationId: updateAPIResourcePoliciesByPolicyId /apis/{apiId}/thumbnail: -#------------------------------------------------------------------------------------------------- -# Downloads a thumbnail image of an API -#------------------------------------------------------------------------------------------------- get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail > image.jpg" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail - Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9 - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" - summary: Get thumbnail image + tags: + - APIs + summary: Get Thumbnail Image description: | This operation can be used to download a thumbnail image of an API. parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. Thumbnail image returned headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/thumbnail"' + operationId: getAPIThumbnail -#---------------------------------------------------------------------------- -# Upload a thumbnail image to a certain API -#---------------------------------------------------------------------------- - post: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -X POST -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail -F file=@image.jpg" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail - Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9 - Content-Type: multipart/form-data; boundary=------------------------5e542e0e5b50e1e4 - Content-Length: 18333 - - --------------------------5e542e0e5b50e1e4 - Content-Disposition: form-data; name="file"; filename="image.jpg" - Content-Type: image/jpeg - - [image content] - - --------------------------5e542e0e5b50e1e4-- - x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail\r\nContent-Type: application/json\r\n\r\n{\r\n \"relativePath\": \"/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail\",\r\n \"mediaType\": \"image/jpeg\"\r\n}" - summary: Upload a thumbnail image + put: + tags: + - APIs + summary: Upload a Thumbnail Image description: | This operation can be used to upload a thumbnail image of an API. The thumbnail to be uploaded should be given as a form data parameter `file`. + operationId: updateAPIThumbnail parameters: - - $ref: '#/parameters/apiId' - - in: formData - name: file - description: Image to upload - type: file - required: true - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + required: + - file + properties: + file: + type: string + description: Image to upload + format: binary + required: true responses: 200: description: | OK. Image updated - schema: - $ref : '#/definitions/FileInfo' headers: - Location: - description: | - The URL of the uploaded thumbnail image of the API. - type: string - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Location: + description: | + The URL of the uploaded thumbnail image of the API. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/FileInfo' 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=image.jpeg "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/thumbnail"' + + /apis/{apiId}/subscription-policies: + get: + tags: + - APIs + summary: | + Get Details of the Subscription Throttling Policies of an API + description: | + This operation can be used to retrieve details of the subscription throttling policy of an API by specifying the API Id. + + `X-WSO2-Tenant` header can be used to retrive API subscription throttling policies that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/requestedTenant' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + OK. + Throttling Policy returned + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ThrottlingPolicy' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/subscription-policies"' + operationId: getAPISubscriptionPolicies -###################################################### -# The "Copy API" Processing Function resource API -###################################################### /apis/copy-api: - -#----------------------------------------------------- -# Create a new API based on an already existing one -#----------------------------------------------------- post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/25a84fc9-38c0-4578-95e8-29fb6b1c4771\nContent-Type: application/json\n\n{\r\n \"id\": \"25a84fc9-38c0-4578-95e8-29fb6b1c4771\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"2.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\\\/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"schema\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/Order\\\"},\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"Created.\\\"}}}},\\\"\\\\/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"headers\\\":{},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application\\\\/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application\\\\/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http:\\\\/\\\\/www.apache.org\\\\/licenses\\\\/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http:\\\\/\\\\/www.pizzashack.com\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\"https\"],\r\n \"tags\": [\r\n \"chicken\",\r\n \"pizza\"\r\n ],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - summary: Create a new API version + tags: + - APIs + summary: Create a New API Version description: | This operation can be used to create a new version of an existing API. The new version is specified as `newVersion` query parameter. New API will be in `CREATED` state. parameters: - - name: newVersion - description: Version of the new API. + - name: newVersion + in: query + description: Version of the new API. + required: true + schema: + maxLength: 30 type: string - in: query - required: true - - $ref: '#/parameters/apiId-Q' - tags: - - API (Individual) + - name: defaultVersion + in: query + description: Specifies whether new API should be added as default version. + schema: + type: boolean + default: false + - name: serviceVersion + in: query + description: Version of the Service that will used in creating new version + schema: + type: string + required: false + - $ref: '#/components/parameters/apiId-Q' responses: 201: description: | @@ -740,38 +1149,31 @@ paths: Location: description: | The URL of the newly created API. - type: string + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 404: - description: | - Not Found. - API to copy does not exist. - 401: - description: | - Unauthenticated request. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/copy-api?newVersion=2.0&defaultVersion=false&apiId=2fd14eb8-b828-4013-b448-0739d2e76bf7"' + x-examples: + $ref: docs/examples/apis/apis_copyapi.yaml#/post + operationId: createNewAPIVersion -###################################################### -# The "Change Lifecycle" Processing Function resource API -###################################################### /apis/change-lifecycle: - -#----------------------------------------------------- -# Change the lifecycle of an API -#----------------------------------------------------- post: - x-scope: apim:api_publish - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" + tags: + - API Lifecycle summary: Change API Status description: | This operation is used to change the lifecycle of an API. Eg: Publish an API which is in `CREATED` state. In order to change the lifecycle, we need to provide the lifecycle `action` as a query parameter. @@ -781,43 +1183,36 @@ paths: Some actions supports providing additional paramters which should be provided as `lifecycleChecklist` parameter. Please see parameters table for more information. parameters: - name: action + in: query description: | The action to demote or promote the state of the API. - Supported actions are [ **Publish, Deploy as a Prototype, Demote to Created, Demote to Prototyped, Block, Deprecate, Re-Publish, Retire **] - - in: query - type: string + Supported actions are [ **Publish**, **Deploy as a Prototype**, **Demote to Created**, **Block**, **Deprecate**, **Re-Publish**, **Retire** ] required: true - enum: - - Publish - - Deploy as a Prototype - - Demote to Created - - Demote to Prototyped - - Block - - Deprecate - - Re-Publish - - Retire + schema: + type: string + enum: + - Publish + - Deploy as a Prototype + - Demote to Created + - Block + - Deprecate + - Re-Publish + - Retire - name: lifecycleChecklist - description: | + in: query + description: |2 Supported checklist items are as follows. - 1. **Deprecate Old Versions**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. - 2. **Require Re-Subscription**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. - + 1. **Deprecate old versions after publishing the API**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. + 2. **Requires re-subscription when publishing the API**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. You can specify additional checklist items by using an **"attribute:"** modifier. - - Eg: "Deprecate Old Versions:true" will deprecate older versions of a particular API when it is promoted to Published state from Created state. Multiple checklist items can be given in "attribute1:true, attribute2:false" format. - - **Sample CURL :** curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X POST "https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish&lifecycleChecklist=Deprecate Old Versions:true,Require Re-Subscription:true" - - type: string - in: query - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) + Eg: "Deprecate old versions after publishing the API:true" will deprecate older versions of a particular API when it is promoted to Published state from Created state. Multiple checklist items can be given in "attribute1:true, attribute2:false" format. + **Sample CURL :** curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X POST "https://localhost:9443/api/am/publisher/v2/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish&lifecycleChecklist=Deprecate%20old%20versions%20after%20publishing%20the%20API%3Atrue,Requires%20re-subscription%20when%20publishing%20the%20API%3Afalse" + schema: + type: string + - $ref: '#/components/parameters/apiId-Q' + - $ref: '#/components/parameters/If-Match' responses: 200: description: | @@ -827,1151 +1222,3198 @@ paths: ETag: description: | Entity Tag of the changed API. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the API lifecycle has been modified the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowResponse' + 202: + description: | + Accepted. + The request has been accepted. + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowResponse' 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' + 409: + $ref: '#/components/responses/Conflict' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish"' + operationId: changeAPILifecycle -###################################################### -# The "Document Collection" resource APIs -###################################################### - /apis/{apiId}/documents: - -#----------------------------------------------------- -# Retrieve the documents associated with an API that qualify under a search condition -#----------------------------------------------------- + /apis/{apiId}/lifecycle-history: get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"4145df31-04f1-440c-8d08-68952874622c\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" - summary: Get a list of documents of an API - description: | - This operation can be used to retrive a list of documents belonging to an API by providing the id of the API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' tags: - - Document (Collection) + - API Lifecycle + summary: Get Lifecycle State Change History of the API. + description: | + This operation can be used to retrieve Lifecycle state change history of the API. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Lifecycle state change history returned successfully. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/LifecycleHistory' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/lifecycle-history"' + operationId: getAPILifecycleHistory + + /apis/{apiId}/lifecycle-state: + get: + tags: + - API Lifecycle + summary: Get Lifecycle State Data of the API. + description: | + This operation can be used to retrieve Lifecycle state data of the API. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Lifecycle state data returned successfully. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/LifecycleState' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/lifecycle-state"' + operationId: getAPILifecycleState + + /apis/{apiId}/lifecycle-state/pending-tasks: + delete: + tags: + - API Lifecycle + summary: Delete Pending Lifecycle State Change Tasks + description: | + This operation can be used to remove pending lifecycle state change requests that are in pending state + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Lifecycle state change pending task removed successfully. + content: {} + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/lifecycle-state/pending-tasks"' + operationId: deleteAPILifecycleStatePendingTasks + + ###################################################### + # The "API Revisions" resource API + ###################################################### + /apis/{apiId}/revisions: + + #-------------------------------------------- + # List available revisions of an API + #-------------------------------------------- + get: + tags: + - API Revisions + summary: List available revisions of an API + description: | + List available revisions of an API + operationId: getAPIRevisions + parameters: + - $ref: '#/components/parameters/apiId' + - name: query + in: query + schema: + type: string + responses: + 200: + description: | + OK. + List of API revisions are returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevisionList' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions?query=deployed:true"' + + #-------------------------------------------- + # Create a new API revision + #-------------------------------------------- + post: + tags: + - API Revisions + summary: Create a new API revision + description: | + Create a new API revision + operationId: createAPIRevision + parameters: + - $ref: '#/components/parameters/apiId' + requestBody: + description: API object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevision' + responses: + 201: + description: | + Created. + Successful response with the newly created APIRevision object as the entity in the body. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevision' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions"' + + ###################################################### + # The "API Revisions" individual resource API + ###################################################### + /apis/{apiId}/revisions/{revisionId}: + + #-------------------------------------------- + # Get a revision + #-------------------------------------------- + get: + tags: + - API Revisions + summary: Retrieve a revision of an API + description: | + Retrieve a revision of an API + operationId: getAPIRevision + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/revisionId' + responses: + 200: + description: | + OK. + An API revision is returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevision' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' + + #-------------------------------------------- + # Delete a revision + #-------------------------------------------- + delete: + tags: + - API Revisions + summary: Delete a revision of an API + description: | + Delete a revision of an API + operationId: deleteAPIRevision + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/revisionId' + responses: + 200: + description: | + OK. + List of remaining API revisions are returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevisionList' + 204: + description: | + No Content. + Successfully deleted the revision + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /apis/{apiId}/deploy-revision: + + #-------------------------------------------- + # List available deployed revision deployment details of an API + #-------------------------------------------- + get: + tags: + - API Revisions + summary: List available deployed revision deployment details of an API + description: | + List available deployed revision deployment details of an API + operationId: getAPIRevisionDeployments + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + List of deployed revision deployment details are returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevisionDeploymentList' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision"' + + #-------------------------------------------- + # Deploy a revision + #-------------------------------------------- + post: + tags: + - API Revisions + summary: Deploy a revision + description: | + Deploy a revision + operationId: deployAPIRevision + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/revisionId-Q' + requestBody: + description: Deployment object that needs to be added + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + responses: + 200: + description: | + OK. + 201: + description: | + Created. + Successful response with the newly deployed APIRevisionDeployment List object as the entity in the body. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /apis/{apiId}/undeploy-revision: + #-------------------------------------------- + # Un-Deploy a revision from deployed gateway + #-------------------------------------------- + post: + tags: + - API Revisions + summary: Un-Deploy a revision + description: | + Un-Deploy a revision + operationId: undeployAPIRevision + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/revisionId-Q' + - $ref: '#/components/parameters/revisionNum-Q' + - name: allEnvironments + in: query + schema: + type: boolean + default: false + requestBody: + description: Deployment object that needs to be added + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + responses: + 200: + description: | + OK. + 201: + description: | + Created. + Successful response with the newly undeployed APIRevisionDeploymentList object as the entity in the body. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/undeploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /apis/{apiId}/restore-revision: + + #-------------------------------------------------------- + # Restore a revision to the working copy of the API + #-------------------------------------------------------- + post: + tags: + - API Revisions + summary: Restore a revision + description: | + Restore a revision to the working copy of the API + operationId: restoreAPIRevision + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/revisionId-Q' + responses: + 201: + description: | + Restored. + Successful response with the newly restored API object as the entity in the body. + content: + application/json: + schema: + $ref: '#/components/schemas/API' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/restore-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /apis/import-service: + post: + tags: + - APIs + summary: Import a Service from Service Catalog + description: This operation can be used to create an API from a Service from Service Catalog + operationId: importServiceFromCatalog + parameters: + - name: serviceKey + in: query + required: true + schema: + type: string + description: ID of service that should be imported from Service Catalog + requestBody: + content: + application/json: + schema: + '$ref': '#/components/schemas/API' + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains the URL of the newly created entity. + headers: + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + + /apis/{apiId}/comments: + get: + tags: + - Comments + summary: Retrieve API Comments + description: | + Get a list of Comments that are already added to APIs + operationId: getAllCommentsOfAPI + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/requestedTenant' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/includeCommenterInfo' + responses: + 200: + description: | + OK. + Comments list is returned. + content: + application/json: + schema: + $ref: '#/components/schemas/CommentList' + 401: + $ref: '#/components/responses/Unauthorized' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: [] + x-code-samples: + - lang: Curl + source: curl -k "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments" + + post: + tags: + - Comments + summary: Add an API Comment + operationId: addCommentToAPI + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/parentCommentID' + requestBody: + description: | + Comment object that should to be added + content: + application/json: + schema: + title: Post request body + type: object + properties: + content: + type: string + description: | + Content of the comment + example: This is a comment + category: + type: string + description: | + Category of the comment + example: general + required: + - content + required: true + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request. + schema: + type: string + Location: + description: | + Location to the newly created Comment. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Comment' + 400: + $ref: '#/components/responses/BadRequest' + 401: + $ref: '#/components/responses/Unauthorized' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments"' + + /apis/{apiId}/comments/{commentId}: + get: + tags: + - Comments + summary: Get Details of an API Comment + description: | + Get the individual comment given by a username for a certain API. + operationId: getCommentOfAPI + parameters: + - $ref: '#/components/parameters/commentId' + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/requestedTenant' + - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/components/parameters/includeCommenterInfo' + - $ref: '#/components/parameters/replyLimit' + - $ref: '#/components/parameters/replyOffset' + responses: + 200: + description: | + OK. + Comment returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Comment' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + content: {} + 401: + $ref: '#/components/responses/Unauthorized' + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: [] + x-code-samples: + - lang: Curl + source: curl -k "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" + + patch: + tags: + - Comments + summary: Edit a comment + description: | + Edit the individual comment + operationId: editCommentOfAPI + parameters: + - $ref: '#/components/parameters/commentId' + - $ref: '#/components/parameters/apiId' + requestBody: + description: | + Comment object that should to be updated + content: + application/json: + schema: + title: Patch request body + type: object + properties: + content: + type: string + description: | + Content of the comment + example: This is a comment + category: + type: string + description: | + Category of the comment + example: general + required: true + responses: + 200: + description: | + OK. + Comment updated. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional request. + schema: + type: string + Location: #??? + description: | + Location to the newly created Comment. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Comment' + 400: + $ref: '#/components/responses/BadRequest' + 401: + $ref: '#/components/responses/Unauthorized' + 404: + $ref: '#/components/responses/NotFound' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4"' + + delete: + tags: + - Comments + summary: Delete an API Comment + description: | + Remove a Comment + operationId: deleteComment + parameters: + - $ref: '#/components/parameters/commentId' + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + responses: + 200: + description: | + OK. + Resource successfully deleted. + content: {} + 401: + $ref: '#/components/responses/Unauthorized' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: curl -k -X DELETE -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" + + /apis/{apiId}/comments/{commentId}/replies: + get: + tags: + - Comments + summary: Get replies of a comment + description: | + Get replies of a comment + operationId: getRepliesOfComment + parameters: + - $ref: '#/components/parameters/commentId' + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/requestedTenant' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/components/parameters/includeCommenterInfo' + responses: + 200: + description: | + OK. + Comment returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests. + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/CommentList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource. + content: {} + 401: + $ref: '#/components/responses/Unauthorized' + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: [] + x-code-samples: + - lang: Curl + source: curl -k "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" + + /apis/import-openapi: + post: + tags: + - APIs + summary: Import an OpenAPI Definition + description: | + This operation can be used to create an API from an OpenAPI definition. Provide either `url` or `file` + to specify the definition. + + Specify additionalProperties with **at least** API's name, version, context and endpointConfig. + operationId: importOpenAPIDefinition + requestBody: + content: + multipart/form-data: + schema: + properties: + file: + type: string + description: Definition to upload as a file + format: binary + url: + type: string + description: Definition url + additionalProperties: + type: string + description: Additional attributes specified as a stringified JSON with API's schema + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@openapi.json -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-openapi"' + x-examples: + $ref: docs/examples/apis/import_openapi_post.yaml + + /apis/import-wsdl: + post: + tags: + - APIs + summary: Import a WSDL Definition + description: | + This operation can be used to create an API using a WSDL definition. Provide either `url` or `file` + to specify the definition. + + WSDL can be speficied as a single file or a ZIP archive with WSDLs and reference XSDs etc. + Specify additionalProperties with **at least** API's name, version, context and endpointConfig. + operationId: importWSDLDefinition + requestBody: + content: + multipart/form-data: + schema: + properties: + file: + type: string + description: | + WSDL definition as a file or archive + + **Sample cURL to Upload WSDL File** + + curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -F file=@api.wsdl -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-wsdl" + + **Sample cURL to Upload WSDL Archive** + + curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -F file="@wsdl.zip;type=application/zip" -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-wsdl" + format: binary + url: + type: string + description: WSDL Definition url + additionalProperties: + type: string + description: Additional attributes specified as a stringified JSON + with API's schema + implementationType: + type: string + description: | + If 'SOAP' is specified, the API will be created with only one resource 'POST /*' which is to be used for SOAP + operations. + + If 'HTTP_BINDING' is specified, the API will be created with resources using HTTP binding operations + which are extracted from the WSDL. + default: SOAP + enum: + - SOAPTOREST + - SOAP + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@api.wsdl -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-wsdl"' + x-examples: + $ref: docs/examples/apis/wsdl/import_wsdl_post.yaml + + /apis/import-graphql-schema: + post: + tags: + - APIs + summary: Import API Definition + description: | + This operation can be used to create api from api definition.APIMgtDAOTest + + API definition is GraphQL Schema + parameters: + - name: If-Match + in: header + description: | + Validator for conditional requests; based on ETag. + schema: + type: string + requestBody: + content: + multipart/form-data: + schema: + properties: + type: + type: string + description: Definition type to upload + file: + type: string + description: Definition to uploads a file + format: binary + additionalProperties: + type: string + description: Additional attributes specified as a stringified JSON + with API's schema + responses: + 201: + description: | + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@schema.graphql -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-graphql-schema"' + operationId: importGraphQLSchema + + /apis/validate-openapi: + post: + tags: + - Validation + summary: Validate an OpenAPI Definition + description: | + This operation can be used to validate an OpenAPI definition and retrieve a summary. Provide either `url` + or `file` to specify the definition. + operationId: validateOpenAPIDefinition + parameters: + - name: returnContent + in: query + description: | + Specify whether to return the full content of the OpenAPI definition in the response. This is only + applicable when using url based validation + schema: + type: boolean + default: false + requestBody: + content: + multipart/form-data: + schema: + properties: + url: + type: string + description: OpenAPI definition url + file: + type: string + description: OpenAPI definition as a file + format: binary + responses: + 200: + description: | + OK. + API definition validation information is returned + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/OpenAPIDefinitionValidationResponse' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@openapi.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-openapi"' + x-examples: + $ref: docs/examples/apis/validate_openapi_post.yaml + + /apis/validate-endpoint: + post: + tags: + - Validation + summary: Check Whether Given Endpoint URL is Valid + description: | + Using this operation, it is possible check whether the given API endpoint url is a valid url + operationId: validateEndpoint + parameters: + - name: endpointUrl + in: query + description: API endpoint url + required: true + schema: + type: string + - name: apiId + in: query + schema: + type: string + responses: + 200: + description: | + OK. + API definition validation information is returned + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ApiEndpointValidationResponse' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-endpoint?apiId=e0824883-3e86-403a-aec1-22bbc454eb7c&endpointUrl=https%3A%2F%2Flocalhost%3A9443%2Fam%2Fsample%2Fpizzashack%2Fv1%2Fapi%2F"' + + /apis/validate: + post: + tags: + - Validation + summary: Check Given API Context Name already Exists + description: | + Using this operation, you can check a given API context is already used. You need to provide the context name you want to check. + operationId: validateAPI + parameters: + - name: query + in: query + description: | + **Search condition**. + + You can search in attributes by using an **":"** modifier. + + Eg. + "name:wso2" will match an API if the provider of the API is exactly "wso2". + + Supported attribute modifiers are [** version, context, name **] + + If no advanced attribute modifier has been specified, search will match the + given query string against API Name. + required: true + schema: + type: string + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + API definition validation information is returned + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate?query=name%3Awso2"' + x-examples: + $ref: docs/examples/apis/apis_validate.yaml + + /apis/validate-wsdl: + post: + tags: + - Validation + summary: Validate a WSDL Definition + description: | + This operation can be used to validate a WSDL definition and retrieve a summary. Provide either `url` + or `file` to specify the definition. + operationId: validateWSDLDefinition + requestBody: + content: + multipart/form-data: + schema: + properties: + url: + type: string + description: Definition url + file: + type: string + description: Definition to upload as a file + format: binary + responses: + 200: + description: | + OK. + API definition validation information is returned + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/WSDLValidationResponse' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@api.wsdl "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-wsdl"' + x-examples: + $ref: docs/examples/apis/wsdl/validate_wsdl_post.yaml + + /apis/validate-graphql-schema: + post: + tags: + - Validation + summary: Validate GraphQL API Definition and Retrieve a Summary + description: | + This operation can be used to validate a graphQL definition and retrieve a summary. + requestBody: + content: + multipart/form-data: + schema: + required: + - file + properties: + file: + type: string + description: Definition to upload as a file + format: binary + required: true + responses: + 200: + description: | + OK. + API definition validation information is returned + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/GraphQLValidationResponse' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@schema.graphql "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-graphql-schema"' + operationId: validateGraphQLSchema + + /apis/{apiId}/graphql-schema: + get: + tags: + - GraphQL Schema (Individual) + summary: Get the Schema of a GraphQL API + description: | + This operation can be used to retrieve the Schema definition of a GraphQL API. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested GraphQL Schema DTO object belongs to the API + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/GraphQLSchema' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/graphql-schema"' + operationId: getAPIGraphQLSchema + + put: + tags: + - GraphQL Schema + summary: Add a Schema to a GraphQL API + description: | + This operation can be used to add a GraphQL Schema definition to an existing GraphQL API. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + required: + - schemaDefinition + properties: + schemaDefinition: + type: string + description: schema definition of the GraphQL API + required: true + responses: + 200: + description: | + OK. + Successful response with updated schema definition + headers: + ETag: + description: | + Entity Tag of the response resource. Used by cache, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F schemaDefinition=@schema.graphql "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/graphql-schema"' + operationId: updateAPIGraphQLSchema + + /apis/{apiId}/amznResourceNames: + get: + tags: + - AWS Lambda (Individual) + summary: Retrieve the ARNs of AWS Lambda Functions + description: | + This operation can be use to retrieve ARNs of AWS Lambda function for a given AWS credentials. + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Requested ARN List of the API is returned + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + type: string + example: |- + { + "count": "2", + "list": [ + "arn:aws:lambda:us-west-2:123456789012:function:my-function1", + "arn:aws:lambda:us-west-2:123456789012:function:my-function2" + ] + } + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/amznResourceNames"' + x-examples: + $ref: docs/examples/apis/apis_id_amznresourcenames_get.yaml + operationId: getAmazonResourceNamesOfAPI + + /apis/{apiId}/monetize: + post: + tags: + - API Monetization + summary: Configure Monetization for a Given API + description: | + This operation can be used to configure monetization for a given API. + parameters: + - $ref: '#/components/parameters/apiId' + requestBody: + description: Monetization data object + content: + application/json: + schema: + $ref: '#/components/schemas/APIMonetizationInfo' + required: true + responses: + 201: + description: | + OK. + Monetization status changed successfully. + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/monetize' + operationId: addAPIMonetization + + /apis/{apiId}/monetization: + get: + tags: + - API Monetization + summary: Get Monetization Status for each Tier in a Given API + description: | + This operation can be used to get monetization status for each tier in a given API + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Monetization status for each tier returned successfully. + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/monetize"' + operationId: getAPIMonetization + + /apis/{apiId}/revenue: + get: + tags: + - API Monetization + summary: Get Total Revenue Details of a Given Monetized API with Meterd Billing + description: | + This operation can be used to get details of total revenue details of a given monetized API with meterd billing. + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Details of a total revenue returned. + headers: + ETag: + description: Entity Tag of the response resource. Used by caches, or + in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: Date and time the resource has been modified the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevenue' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/revenue"' + operationId: getAPIRevenue + + /apis/{apiId}/documents: + get: + tags: + - API Documents + summary: Get a List of Documents of an API + description: | + This operation can be used to retrieve a list of documents belonging to an API by providing the id of the API. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. Document list is returned. - schema: - $ref: '#/definitions/DocumentList' headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/DocumentList' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/documents"' + operationId: getAPIDocuments -#----------------------------------------------------- -# Add a document to a certain API -#----------------------------------------------------- post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" - summary: Add a new document to an API + tags: + - API Documents + summary: Add a New Document to an API description: | This operation can be used to add a new documentation to an API. This operation only adds the metadata of a document. To add the actual content we need to use **Upload the content of an API document ** API once we obtain a document Id by this operation. parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - Document object that needs to be added - required: true - schema: - $ref: '#/definitions/Document' - - $ref: '#/parameters/Content-Type' - tags: - - Document (Collection) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + description: Document object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + required: true responses: 201: description: | Created. Successful response with the newly created Document object as entity in the body. Location header contains URL of newly added document. - schema: - $ref: '#/definitions/Document' headers: - Location: - description: | - Location to the newly created Document. - type: string - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Location: + description: | + Location to the newly created Document. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_create + - apim:document_create + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents"' + operationId: addAPIDocument -###################################################### -# The "Individual Document" resource APIs -###################################################### - '/apis/{apiId}/documents/{documentId}': - -#----------------------------------------------------- -# Retrieve a particular document of a certain API -#----------------------------------------------------- + /apis/{apiId}/documents/{documentId}: get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: Get a document of an API + tags: + - API Documents + summary: Get a Document of an API description: | This operation can be used to retrieve a particular document's metadata associated with an API. parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Document (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. Document returned. - schema: - $ref: '#/definitions/Document' headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5"' + operationId: getAPIDocumentByDocumentId -#----------------------------------------------------- -# Update a particular document of a certain API -#----------------------------------------------------- put: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\nAuthorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: Update a document of an API + tags: + - API Documents + summary: Update a Document of an API description: | This operation can be used to update metadata of an API's document. parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - in: body - name: body - description: | - Document object that needs to be added - required: true - schema: - $ref: '#/definitions/Document' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Document (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-Match' + requestBody: + description: Document object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + required: true responses: 200: description: | OK. Document updated - schema: - $ref: '#/definitions/Document' headers: - Location: - description: | - The URL of the updated document. - type: string - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Location: + description: | + The URL of the updated document. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:document_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @doc.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5"' + operationId: updateAPIDocument -#----------------------------------------------------- -# Delete a particular document of a certain API -#----------------------------------------------------- delete: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058" - x-wso2-request: | - DELETE https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete a document of an API + tags: + - API Documents + summary: Delete a Document of an API description: | This operation can be used to delete a document associated with an API. parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Document (Individual) + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-Match' responses: 200: description: | OK. Resource successfully deleted. + content: {} 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:document_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5"' + operationId: deleteAPIDocument -################################################################ -# The content resource of "Individual Document" resource APIs -################################################################ - - '/apis/{apiId}/documents/{documentId}/content': - - #------------------------------------------------------------------------------------------------- - # Downloads a FILE type document/get the inline content or source url of a certain document - #------------------------------------------------------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\" > sample.pdf" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content - Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a - x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" - summary: Get the content of an API document - description: | - This operation can be used to retrive the content of an API's document. - - The document can be of 3 types. In each cases responses are different. - - 1. **Inline type**: - The content of the document will be retrieved in `text/plain` content type - - _Sample cURL_ : `curl -k -H "Authorization:Bearer 579f0af4-37be-35c7-81a4-f1f1e9ee7c51" -F inlineContent=@"docs.txt" -X POST "https://localhost:9443/api/am/publisher/v0.12/apis/995a4972-3178-4b17-a374-756e0e19127c/documents/43c2bcce-60e7-405f-bc36-e39c0c5e189e/content` - 2. **FILE type**: - The file will be downloaded with the related content type (eg. `application/pdf`) - 3. **URL type**: - The client will recieve the URL of the document as the Location header with the response with - `303 See Other` - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - File or inline content returned. - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 303: - description: | - See Other. - Source can be retrived from the URL specified at the Location header. - headers: - Location: - description: | - The Source URL of the document. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - #---------------------------------------------------------------------------- - # Upload a file or add inline content to a document of a certain API - #---------------------------------------------------------------------------- - post: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -F file=@\"sample.pdf\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/documents/b3a79270-02bb-4e39-9ac1-90ce8f6c84af/content - Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - Content-Length: 8004 - Content-Type: multipart/form-data; boundary=------------------------7b9a53f1ffa452b9 - - --------------------------7b9a53f1ffa452b9 - Content-Disposition: form-data; name="file"; filename="sample.pdf" - Content-Type: application/octet-stream - - [file content] - - --------------------------7b9a53f1ffa452b9-- - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/documents/b3a79270-02bb-4e39-9ac1-90ce8f6c84af/content\nContent-Type: application/json\n\n{\n \"visibility\":\"API_LEVEL\",\n \"sourceType\":\"FILE\",\n \"sourceUrl\":null,\n \"otherTypeName\":null,\n \"documentId\":\"daf732d3-bda2-46da-b381-2c39d901ea61\",\n \"summary\":\"This is a sample documentation pdf\",\n \"name\":\"Introduction to PhoneVerification API PDF\",\n \"type\":\"HOWTO\"\n}" - summary: Upload the content of an API document - description: | - Thid operation can be used to upload a file or add inline content to an API document. - - **IMPORTANT:** - * Either **file** or **inlineContent** form data parameters should be specified at one time. - * Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. - * Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - in: formData - name: file - description: Document to upload - type: file - required: false - - in: formData - name: inlineContent - description: Inline content of the document - type: string - required: false - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - Document updated - schema: - $ref: '#/definitions/Document' - headers: - Location: - description: | - The URL of the updated content of the document. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - ##pp -###################################################### -# The "specific mediation policy" resource APIs -###################################################### - '/apis/{apiId}/policies/mediation': - - #----------------------------------------------------------------------------------------- - # Retrieving the list of all API specific mediation sequences under a given search condition - #----------------------------------------------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc\" https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation" - x-wso2-request: "GET https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\r\nAuthorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"count\": 1,\r\n \"next\": null,\r\n \"previous\": null,\r\n \"list\": [ {\r\n \"name\": \"add_custom_header_fault\",\r\n \"id\": \"6460d7e6-4272-4e3a-9879-437228d83123\",\r\n \"type\": \"fault\"\r\n }]\r\n}" - summary: | - Get all mediation policies of an API - description: | - This operation provides you a list of available mediation policies of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - name : query - in: query - description: "-Not supported yet-" - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - Mediation Policy (Collection) - responses: - 200: - description: | - OK. - List of qualifying APIs is returned. - schema: - $ref: '#/definitions/mediationList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#---------------------------------------------------------------------------- -# Upload an API specific mediation policy -#---------------------------------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer 6cea3696-0151-3282-bf79-a0c4db6f308a\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\r\nContent-Type: application/json\r\nAuthorization: Bearer 6cea3696-0151-3282-bf79-a0c4db6f308a\r\n\r\n{\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: https://localhost:9443/api/am/publisher/v0.12/registry/resource/_system/governance/apimgt/applicationdata/provider/admin/hello/1.0.0/fault/add_custom_header_fault.xml\r\nContent-Type: application/json\r\n\r\n{ \r\n \"id\":\"624b9f7d-bfaf-484b-94cc-e84491f5d725\",\r\n \"name\":\"add_custom_header_fault\",\r\n \"type\":\"fault\",\r\n \"config\":\"\\n \\n\\n\"\r\n}" - summary: Add an API specific mediation policy - description: | - This operation can be used to add an API specifc mediation policy. - parameters: - - in: body - name: body - description: mediation policy to upload - required: true - schema: - $ref: '#/definitions/Mediation' - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Mediation Policy (Collection) - responses: - 200: - description: | - OK. - mediation policy uploaded - schema: - $ref : '#/definitions/Mediation' - headers: - Location: - description: | - The URL of the uploaded thumbnail image of the API. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual API specific mediation sequence" resource -###################################################### - /apis/{apiId}/policies/mediation/{mediationPolicyId}: - -#----------------------------------------------------- -# Retrieve a particular API specific mediation squence -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer 5aa0acc0-0ce3-3a0b-8cc8-db5ef696ee23\" https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/624b9f7d-bfaf-484b-94cc-e84491f5d725" - x-wso2-request: "GET https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/624b9f7d-bfaf-484b-94cc-e84491f5d725\r\nAuthorization: Bearer 5aa0acc0-0ce3-3a0b-8cc8-db5ef696ee23" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"id\": \"624b9f7d-bfaf-484b-94cc-e84491f5d725\",\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - summary: Get an API specific mediation policy - description: | - This operation can be used to retrieve a particular API specific mediation policy. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/mediationPolicyId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Mediation Policy (Individual) - responses: - 200: - description: | - OK. - Mediation policy returned. - schema: - $ref: '#/definitions/Mediation' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete the mediation policy -#----------------------------------------------------- - delete: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/60f5146d-1774-405d-86b3-9b040ac266d5" - x-wso2-request: "DELETE https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/60f5146d-1774-405d-86b3-9b040ac266d5\r\nAuthorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete an API specific mediation policy - description: | - This operation can be used to delete an existing API specific mediation policy providing the Id of the API and the Id of the mediation policy. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/mediationPolicyId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Mediation Policy (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update the a mediation policy -#----------------------------------------------------- - put: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer 9e41fae2-3ada-3dd1-8f12-2077202f4285\" -H \"Content-Type: application/json\" -X PUT -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/820fdcf7-7258-42b5-809e-674b893644d1" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/820fdcf7-7258-42b5-809e-674b893644d1\r\nContent-Type: application/json\r\nAuthorization: Bearer 9e41fae2-3ada-3dd1-8f12-2077202f4285\r\n\r\n{\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"id\": \"a7365481-5b3f-463c-a646-a498895ac210\",\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - summary: Update an API specific mediation policy - description: | - This operation can be used to update an existing mediation policy of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/mediationPolicyId' - - in: body - name: body - description: | - Mediation policy object that needs to be updated - required: true - schema: - $ref: '#/definitions/Mediation' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Mediation Policy (Individual) - responses: - 200: - description: | - OK. - Successful response with updated API object - schema: - $ref: '#/definitions/Mediation' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The wsdl Resource -###################################################### - /apis/{apiId}/wsdl: - -#----------------------------------------------------- -# Retrieve the details about a certain wsdl -#----------------------------------------------------- + /apis/{apiId}/documents/{documentId}/content: get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/7f82f6b0-2667-441e-af23-c0fc44cf3a17/wsdl\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/7f82f6b0-2667-441e-af23-c0fc44cf3a17/wsdl - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"name\": \"admin--hello1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" - summary: Get the WSDL of an API - description: | - This operation can be used to retrieve the WSDL definition of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' tags: - - Wsdl (Individual) + - API Documents + summary: Get the Content of an API Document + description: | + This operation can be used to retrive the content of an API's document. + + The document can be of 3 types. In each cases responses are different. + + 1. **Inline type**: + The content of the document will be retrieved in `text/plain` content type + + _Sample cURL_ : `curl -k -H "Authorization:Bearer 579f0af4-37be-35c7-81a4-f1f1e9ee7c51" -F inlineContent=@"docs.txt" -X POST "https://localhost:9443/api/am/publisher/v2/apis/995a4972-3178-4b17-a374-756e0e19127c/documents/43c2bcce-60e7-405f-bc36-e39c0c5e189e/content` + 2. **FILE type**: + The file will be downloaded with the related content type (eg. `application/pdf`) + 3. **URL type**: + The client will recieve the URL of the document as the Location header with the response with - `303 See Other` + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. - Requested WSDL DTO object belongs to the API - schema: - $ref: '#/definitions/Wsdl' + File or inline content returned. headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string - - 304: + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/octet-stream: + schema: + type: string + 303: description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' -#----------------------------------------------------- -# Add a wsdl to the registry -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/af3f96da-9ccf-463f-8cee-13ec8530a9cd/wsdl\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/af3f96da-9ccf-463f-8cee-13ec8530a9cd/wsdl\r\nContent-Type: application/json\r\nAuthorization: Bearer 7d237cab-7011-3f81-b384-24d03e750873\r\n\r\n{\r\n \"name\": \"admin--PizzaShackAPI1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"name\": \"admin--PizzaShackAPI1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" - summary: Add a WSDL to an API - description: | - This operation can be used to add a WSDL definition to an existing API. - parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - JSON payload including WSDL definition that needs to be added - required: true - schema: - $ref: '#/definitions/Wsdl' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Wsdl (Individual) - responses: - 200: - description: | - OK. - Successful response with updated wsdl definition + See Other. + Source can be retrived from the URL specified at the Location header. headers: Location: description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - -###################################################### -# The "Individual Application" resource APIs -###################################################### - '/applications/{applicationId}': - -#----------------------------------------------------- -# Retrieve the details about a certain application -#----------------------------------------------------- - get: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"name\": \"DefaultApplication\"\n}" - summary: Get details of an application - description: | - This operation can be used to retrieve details of an individual application specifying the application id in the URI. - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Application (Individual) - responses: - 200: - description: | - OK. - Application returned. - schema: - $ref: '#/definitions/Application' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string + The Source URL of the document. + schema: + type: string + content: {} 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content"' + operationId: getAPIDocumentContentByDocumentId + + post: + tags: + - API Documents + summary: Upload the Content of an API Document + description: | + Thid operation can be used to upload a file or add inline content to an API document. + + **IMPORTANT:** + * Either **file** or **inlineContent** form data parameters should be specified at one time. + * Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. + * Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + properties: + file: + type: string + description: Document to upload + format: binary + inlineContent: + type: string + description: Inline content of the document + responses: + 200: + description: | + OK. + Document updated + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the updated content of the document. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:document_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@sample.pdf "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content"' + operationId: addAPIDocumentContent + + /apis/{apiId}/documents/validate: + post: + tags: + - API Documents + summary: Check Whether a Document with the Provided Name Exist + description: | + This operation can be used to verify the document name exists or not. + operationId: validateDocument + parameters: + - $ref: '#/components/parameters/apiId' + - name: name + in: query + description: | + The name of the document which needs to be checked for the existance. + required: true + schema: + type: string + - $ref: '#/components/parameters/If-Match' + responses: + 200: + description: | + OK. + Successful response if the document name exists. + 400: + $ref: '#/components/responses/BadRequest' 404: description: | Not Found. - Requested application does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + The specified resource does not exist. + security: + - OAuth2Security: + - apim:api_create + - apim:document_create + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/validate?name=CalculatorDoc"' + x-examples: + $ref: docs/examples/apis/apis_id_document_validate.yaml -###################################################### -# The "Subscription Collection" resource APIs -###################################################### - /subscriptions: - -#----------------------------------------------------- -# Retrieve all subscriptions of a certain API -#----------------------------------------------------- + /apis/{apiId}/mediation-policies: get: - x-scope: apim:subscription_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"previous\": \"\",\n \"list\": [\n {\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"subscriptionId\": \"7ac22c34-8745-4cfe-91e0-262c50b2f2e3\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" + tags: + - API Mediation Policies + summary: | + Get All Mediation Policies of an API + description: | + This operation provides you a list of available mediation policies of an API. + operationId: getAllAPIMediationPolicies + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - name: query + in: query + description: -Not supported yet- + schema: + type: string + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + List of qualifying APIs is returned. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/MediationList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + - apim:mediation_policy_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies"' + x-examples: + $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_get.yaml + + post: + tags: + - API Mediation Policies + summary: Add an API Specific Mediation Policy + description: | + This operation can be used to add an API specifc mediation policy. + operationId: addAPIMediationPolicy + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + required: + - type + properties: + mediationPolicyFile: + type: string + description: Mediation Policy to upload + format: binary + inlineContent: + type: string + description: Inline content of the Mediation Policy + type: + type: string + description: Type of the mediation sequence + required: true + responses: + 201: + description: | + OK. + mediation policy uploaded + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the uploaded mediation policy of the API. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Mediation' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:mediation_policy_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: multipart/form-data" -F mediationPolicyFile=@TokenExchange.xml + -F type=in "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies"' + x-examples: + $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_post.yaml + + /apis/{apiId}/mediation-policies/{mediationPolicyId}: + get: + tags: + - API Mediation Policy + summary: Get an API Specific Mediation Policy + description: | + This operation can be used to retrieve a particular API specific mediation policy. + operationId: getAPIMediationPolicyByPolicyId + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/mediationPolicyId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Mediation policy returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Mediation' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + - apim:mediation_policy_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + x-examples: + $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_get.yaml + + delete: + tags: + - API Mediation Policy + summary: Delete an API Specific Mediation Policy + description: | + This operation can be used to delete an existing API specific mediation policy providing the Id of the API and the Id of the mediation policy. + operationId: deleteAPIMediationPolicyByPolicyId + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/mediationPolicyId' + - $ref: '#/components/parameters/If-Match' + responses: + 200: + description: | + OK. + Resource successfully deleted. + content: {} + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:mediation_policy_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + x-examples: + $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_delete.yaml + + /apis/{apiId}/mediation-policies/{mediationPolicyId}/content: + get: + tags: + - API Mediation Policy + summary: Download an API Specific Mediation Policy + description: | + This operation can be used to download a particular API specific mediation policy. + operationId: getAPIMediationPolicyContentByPolicyId + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/mediationPolicyId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Mediation policy returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + - apim:mediation_policy_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a/content"' + x-examples: + $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_content_get.yaml + + put: + tags: + - API Mediation Policy + summary: Update an API Specific Mediation Policy + description: | + This operation can be used to update an existing mediation policy of an API. + operationId: updateAPIMediationPolicyContentByPolicyId + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/mediationPolicyId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + required: + - type + properties: + file: + type: string + description: Mediation Policy to upload + format: binary + inlineContent: + type: string + description: Inline content of the Mediation Policy + type: + type: string + description: Type of the mediation sequence(in/out/fault) + required: true + responses: + 200: + description: | + OK. + Successful response with updated API object + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Mediation' + 400: + $ref: '#/components/responses/BadRequest' + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + - apim:mediation_policy_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@TokenExchange.xml -F type=@type.txt "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a/content"' + x-examples: + $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_content_put.yaml + + /apis/{apiId}/wsdl-info: + get: + tags: + - APIs + summary: Get WSDL Meta Information + description: | + This operation can be used to retrieve the WSDL meta information of an API. It states whether the API is a SOAP + API. If the API is a SOAP API, it states whether it has a single WSDL or a WSDL archive. + operationId: getWSDLInfoOfAPI + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Requested WSDL meta information of the API is returned + content: + application/json: + schema: + $ref: '#/components/schemas/WSDLInfo' + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/wsdl-info"' + x-examples: + $ref: docs/examples/apis/wsdl/apiId_wsdl_info_get.yaml + + /apis/{apiId}/wsdl: + get: + tags: + - APIs + summary: Get WSDL definition + description: | + This operation can be used to retrieve the WSDL definition of an API. It can be either a single WSDL file or a WSDL archive. + + The type of the WSDL of the API is indicated at the "wsdlInfo" element of the API payload definition. + operationId: getWSDLOfAPI + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested WSDL document of the API is returned + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + content: {} + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/wsdl"' + x-examples: + $ref: docs/examples/apis/wsdl/apiId_wsdl_get.yaml + + put: + tags: + - APIs + summary: Update WSDL Definition + description: | + This operation can be used to update the WSDL definition of an existing API. WSDL to be updated can be passed as either "url" or "file". + Only one of "url" or "file" can be used at the same time. "file" can be specified as a single WSDL file or as a zip file which has a WSDL + and its dependencies (eg: XSDs) + operationId: updateWSDLOfAPI + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + properties: + file: + type: string + description: WSDL file or archive to upload + format: binary + url: + type: string + description: WSDL Definition url + responses: + 200: + description: | + OK. + Successful response with updated WSDL definition + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@api.wsdl "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/wsdl"' + x-examples: + $ref: docs/examples/apis/wsdl/apiId_wsdl_put.yaml + + /apis/{apiId}/graphql-policies/complexity: + get: + tags: + - GraphQL Policies + summary: Get the Complexity Related Details of an API + description: | + This operation can be used to retrieve complexity related details belonging to an API by providing the API id. + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Requested complexity details returned. + headers: + Content-Type: + description: | + The content of the body. + schema: + type: string + default: application/json + content: + application/json: + schema: + $ref: '#/components/schemas/GraphQLQueryComplexityInfo' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/graphql-policies/complexity"' + operationId: getGraphQLPolicyComplexityOfAPI + + + put: + tags: + - GraphQL Policies + summary: Update Complexity Related Details of an API + description: | + This operation can be used to update complexity details belonging to an API by providing the id of the API. + parameters: + - $ref: '#/components/parameters/apiId' + requestBody: + description: Role-depth mapping that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/GraphQLQueryComplexityInfo' + responses: + 200: + description: | + Created. + Complexity details created successfully. + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/graphql-policies/complexity"' + operationId: updateGraphQLPolicyComplexityOfAPI + + /apis/{apiId}/graphql-policies/complexity/types: + get: + tags: + - GraphQL Policies + summary: Retrieve Types and Fields of a GraphQL Schema + description: | + This operation can be used to retrieve all types and fields of the GraphQL Schema by providing the API id. + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + Types and fields returned successfully. + headers: + Content-Type: + description: | + The content of the body. + schema: + type: string + default: application/json + content: + application/json: + schema: + $ref: '#/components/schemas/GraphQLSchemaTypeList' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/graphql-policies/complexity/types"' + operationId: getGraphQLPolicyComplexityTypesOfAPI + + /apis/{apiId}/resource-paths: + get: + tags: + - APIs + summary: Get Resource Paths of an API + description: | + This operation can be used to retrieve resource paths defined for a specific api. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + ResourcePaths returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modified the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ResourcePathList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/resource-paths"' + operationId: getAPIResourcePaths + + /apis/{apiId}/auditapi: + get: + tags: + - API Audit + summary: Retrieve the Security Audit Report of the Audit API + description: | + Retrieve the Security Audit Report of the Audit API + parameters: + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + The Security Audit Report has been returned. + headers: + Content-Type: + description: | + The content of the body. + schema: + type: string + default: application/json + content: + application/json: + schema: + $ref: '#/components/schemas/AuditReport' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/auditapi"' + x-examples: + $ref: "docs/examples/apis/apis_id_auditapi_get.yaml" + operationId: getAuditReportOfAPI + + /apis/{apiId}/external-stores: + get: + tags: + - External Stores + summary: Get the List of External Stores to which an API is Published + description: | + This operation can be used to retrieve a list of external stores which an API is published to by providing the id of the API. + operationId: getAllPublishedExternalStoresByAPI + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + External Store list is returned. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIExternalStoreList' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/external-stores"' + x-examples: + $ref: docs/examples/external-stores/external_stores.yaml#/getPublishedExternalStoresByAPI + + /apis/{apiId}/publish-to-external-stores: + post: + tags: + - External Stores + summary: Publish an API to External Stores + description: | + This operation can be used to publish an API to a list of external stores. + operationId: publishAPIToExternalStores + parameters: + - $ref: '#/components/parameters/apiId' + - name: externalStoreIds + in: query + description: External Store Ids of stores which the API needs to be published + or updated. + required: true + schema: + type: string + - $ref: '#/components/parameters/If-Match' + responses: + 200: + description: | + OK. + API was successfully published to all the selected external stores. + headers: + ETag: + description: | + Entity Tag of the blocked subscription. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the subscription has been blocked. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIExternalStoreList' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/publish-to-external-stores?externalStoreId=Store123#"' + x-examples: + $ref: docs/examples/external-stores/external_stores.yaml#/publishToExternalStore + + /apis/export: + get: + tags: + - Import Export + summary: Export an API + description: | + This operation can be used to export the details of a particular API as a zip file. + parameters: + - name: apiId + in: query + description: UUID of the API + schema: + type: string + - name: name + in: query + description: | + API Name + schema: + type: string + - name: version + in: query + description: | + Version of the API + schema: + type: string + - name: revisionNumber + in: query + description: | + Revision number of the API artifact + schema: + type: string + - name: providerName + in: query + description: | + Provider name of the API + schema: + type: string + - name: format + in: query + description: | + Format of output documents. Can be YAML or JSON. + schema: + type: string + enum: + - JSON + - YAML + - name: preserveStatus + in: query + description: | + Preserve API Status on export + schema: + type: boolean + - name: latestRevision + in: query + description: | + Export the latest revision of the API + schema: + type: boolean + default: false + responses: + 200: + description: | + OK. + Export Successful. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/zip: + schema: + type: string + format: binary + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_create + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/export?apiId=96077508-fd01-4fae-bc64-5de0e2baf43c&name=PizzaShackAPI&version=1.0&provider=admin&format=YAML" + > exportAPI.zip' + operationId: exportAPI + + /apis/import: + post: + tags: + - Import Export + summary: Import an API + description: | + This operation can be used to import an API. + parameters: + - name: preserveProvider + in: query + description: | + Preserve Original Provider of the API. This is the user choice to keep or replace the API provider + required: false + schema: + type: boolean + - name: rotateRevision + in: query + description: | + Once the revision max limit reached, undeploy and delete the earliest revision and create a new revision + required: false + schema: + type: boolean + - name: overwrite + in: query + description: | + Whether to update the API or not. This is used when updating already existing APIs + required: false + schema: + type: boolean + requestBody: + content: + multipart/form-data: + schema: + required: + - file + properties: + file: + type: string + description: Zip archive consisting on exported api configuration + format: binary + responses: + 200: + description: | + Created. + API Imported Successfully. + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 409: + $ref: '#/components/responses/Conflict' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@admin-PizzaShackAPI-1.0.0.zip "https://127.0.0.1:9443/api/am/publisher/v2/apis/import?preserveProvider=false&overwrite=false"' + operationId: importAPI + + ###################################################### + # The "Subscription Collection" resource APIs + ###################################################### + /subscriptions: + get: + tags: + - Subscriptions summary: Get all Subscriptions description: | This operation can be used to retrieve a list of subscriptions of the user associated with the provided access token. This operation is capable of 1. Retrieving all subscriptions for the user's APIs. - `GET https://localhost:9443/api/am/publisher/v0.12/subscriptions` + `GET https://127.0.0.1:9443/api/am/publisher/v2/subscriptions` 2. Retrieving subscriptions for a specific API. - `GET https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed` + `GET https://127.0.0.1:9443/api/am/publisher/v2/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed` parameters: - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Subscription (Collection) + - $ref: '#/components/parameters/apiId-Q-Opt' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/If-None-Match' + - name: query + in: query + description: | + Keywords to filter subscriptions + schema: + type: string responses: 200: description: | OK. Subscription list returned. - schema: - $ref: '#/definitions/SubscriptionList' headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/SubscriptionList' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 406: - description: | - Not Acceptable. The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:subscription_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions?apiId=96077508-fd01-4fae-bc64-5de0e2baf43c"' + operationId: getSubscriptions -###################################################### -# The "Individual Subscription" resource APIs -###################################################### - '/subscriptions/{subscriptionId}': - -#----------------------------------------------------- -# Retrieve a certain subscription -#----------------------------------------------------- + ###################################################### + # The Individual Subscription resource APIs + ###################################################### + /subscriptions/{subscriptionId}/usage: get: - x-scope: apim:subscription_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n}" - summary: Get details of a subscription - description: | - This operation can be used to get details of a single subscription. - parameters: - - $ref: '#/parameters/subscriptionId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' tags: - - Subscription (Individual) + - API Monetization + summary: Get Details of a Pending Invoice for a Monetized Subscription with Metered Billing. + description: | + This operation can be used to get details of a pending invoice for a monetized subscription with meterd billing. + parameters: + - $ref: '#/components/parameters/subscriptionId' responses: 200: description: | OK. - Subscription returned - schema: - $ref: '#/definitions/ExtendedSubscription' + Details of a pending invoice returned. headers: + ETag: + description: Entity Tag of the response resource. Used by caches, or + in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: Date and time the resource has been modified the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string Content-Type: description: The content type of the body. - type: string - ETag: - description: 'Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future).' - type: string - Last-Modified: - description: 'Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future).' - type: string - '304': + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIMonetizationUsage' + 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - '404': + content: {} + 404: description: | Not Found. Requested Subscription does not exist. - schema: - $ref: '#/definitions/Error' + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + security: + - OAuth2Security: + - apim:subscription_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809/usage"' + operationId: getSubscriptionUsage + + /subscriptions/{subscriptionId}/subscriber-info: + get: + tags: + - Subscriber + summary: Get Details of a Subscriber + description: | + This operation can be used to get details of a user who subscribed to the API. + parameters: + - $ref: '#/components/parameters/subscriptionId' + responses: + 200: + description: | + OK. + Details of the subscriber are returned. + content: + application/json: + schema: + $ref: '#/components/schemas/SubscriberInfo' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:subscription_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809/subscriber-info"' + operationId: getSubscriberInfoBySubscriptionId -###################################################### -# The "Block Subscription" Processing Function resource API -###################################################### /subscriptions/block-subscription: - -#----------------------------------------------------- -# Block a certain subscription -#----------------------------------------------------- post: - x-scope: apim:subscription_block - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"PROD_ONLY_BLOCKED\"\n}" - summary: Block a subscription + tags: + - Subscriptions + summary: Block a Subscription description: | This operation can be used to block a subscription. Along with the request, `blockState` must be specified as a query parameter. 1. `BLOCKED` : Subscription is completely blocked for both Production and Sandbox environments. 2. `PROD_ONLY_BLOCKED` : Subscription is blocked for Production environment only. parameters: - - $ref: '#/parameters/subscriptionId-Q' + - $ref: '#/components/parameters/subscriptionId-Q' - name: blockState in: query description: | Subscription block state. - type: string required: true - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Subscription (Individual) + schema: + type: string + enum: + - BLOCKED + - PROD_ONLY_BLOCKED + - $ref: '#/components/parameters/If-Match' responses: 200: description: | @@ -1982,55 +4424,40 @@ paths: description: | Entity Tag of the blocked subscription. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the subscription has been blocked. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + content: {} 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 404: - description: | - Not Found. - Requested subscription does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:subscription_block + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED"' + operationId: blockSubscription -###################################################### -# The "Unblock Subscription" Processing Function resource API -###################################################### /subscriptions/unblock-subscription: - -#----------------------------------------------------- -# Unblock a certain subscription -#----------------------------------------------------- post: - x-scope: apim:subscription_block - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8` - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n} " + tags: + - Subscriptions summary: Unblock a Subscription - parameters: - - $ref: '#/parameters/subscriptionId-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' description: | This operation can be used to unblock a subscription specifying the subscription Id. The subscription will be fully unblocked after performing this operation. - tags: - - Subscription (Individual) + parameters: + - $ref: '#/components/parameters/subscriptionId-Q' + - $ref: '#/components/parameters/If-Match' responses: 200: description: | @@ -2041,1651 +4468,7209 @@ paths: description: | Entity Tag of the unblocked subscription. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the subscription has been unblocked. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + content: {} 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/BadRequest' 404: - description: | - Not Found. - Requested subscription does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:subscription_block + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809"' + operationId: unBlockSubscription -###################################################### -# The "Tier Collection" resource APIs -###################################################### - '/tiers/{tierLevel}': -#----------------------------------------------------- -# Retrieve the list of all available tiers -#----------------------------------------------------- + ###################################################### + # The "Thorttling Tier Collection" resource APIs + ###################################################### + /throttling-policies/{policyLevel}: get: - x-scope: apim:tier_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/tiers/api" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/tiers/api - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"next\": \"\",\n \"count\": 4\n}" - summary: Get all tiers - description: | - This operation can be used to list the available tiers for a given tier level. Tier level should be specified as a path parameter and should be one of `api`, `application` and `resource`. - parameters: - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' tags: - - Throttling Tier (Collection) + - Throttling Policies + summary: Get All Throttling Policies for the Given Type + description: | + This operation can be used to list the available policies for a given policy level. Tier level should be specified as a path parameter and should be one of `subscription` and `api`. + `subscription` is for Subscription Level policies and `api` is for Resource Level policies + operationId: getAllThrottlingPolicies + parameters: + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/policyLevel' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. - List of tiers returned. - schema: - $ref: '#/definitions/TierList' + List of policies returned. headers: - Content-Type: - description: The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ThrottlingPolicyList' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/throttling-policies/api"' -#----------------------------------------------------- -# Create a new tier -#----------------------------------------------------- - post: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/api\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/tiers/api\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\":10,\n \"b\":30\n }\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/tiers/Low\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"30\",\n \"a\": \"10\"\n }\n}" - summary: Create a Tier - description: | - This operation can be used to create a new throttling tier. The only supported tier level is `api` tiers. - `POST https://localhost:9443/api/am/publisher/v0.12/tiers/api` - - **IMPORTANT:** - * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. - parameters: - - in: body - name: body - description: | - Tier object that should to be added - required: true - schema: - $ref: '#/definitions/Tier' - - $ref: '#/parameters/tierLevel-A' - - $ref: '#/parameters/Content-Type' + ###################################################### + # The "Subscription Throttling Based on Quota Type" resource APIs + ###################################################### + /throttling-policies/streaming/subscription: + get: tags: - - Throttling Tier (Collection) + - Throttling Policies + summary: Get subscription throttling policies based on quota type + description: | + This operation can be used to list the available subscription policies for a given tenent ID based on the given quota type. + Quota Type should be provide as a query parameters and supported Quota types are "requestCount" ,"bandwidthVolume" and "eventCount" + operationId: getSubscriptionThrottlingPolicies + parameters: + - $ref: '#/components/parameters/tierQuotaType' + - $ref: '#/components/parameters/If-None-Match' responses: - 201: + 200: description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/Tier' + OK. + List of subscription policies returned. headers: - Location: - description: | - Location of the newly created tier. - type: string - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. - Used by caches, or in conditional request' - type: string - 400: + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ThrottlingPolicyList' + 304: description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/throttling-policies/subscription?tierQuotaType=RequestCountLimit"' -###################################################### -# The "Individual Tier" resource APIs -###################################################### - '/tiers/{tierLevel}/{tierName}': - -#----------------------------------------------------- -# Retrieve a certain tier -#----------------------------------------------------- + ###################################################### + # The "Individual Throttling Tier" resource APIs + ###################################################### + /throttling-policies/{policyLevel}/{policyName}: get: - x-scope: apim:tier_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/tiers/api/Bronze" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/tiers/api/Bronze - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" - summary: Get details of a tier - description: | - This operation can be used to retrieve details of a single tier by specifying the tier level and tier name. - Note that the scope of the API is mandatory while retreiving the access token with the following cURL command : `curl -k -d \"grant_type=password&username=username&password=password&scope=apim:tier_view\" -H \"Authorization: Basic \" https://localhost:8243/token`. - You will receive the access token as the response, for example `"access_token":"8644c013-7ff1-3217-b150-d7b92cae6be7"`. - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' tags: - - Throttling Tier (Individual) + - Throttling Policies + summary: Get Details of a Policy + description: | + This operation can be used to retrieve details of a single policy by specifying the policy level and policy name. + operationId: getThrottlingPolicyByName + parameters: + - $ref: '#/components/parameters/policyName' + - $ref: '#/components/parameters/policyLevel' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. Tier returned - schema: - $ref: '#/definitions/Tier' headers: - Content-Type: - description: | - The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ThrottlingPolicy' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 404: - description: | - Not Found. - Requested Tier does not exist. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotFound' 406: - description: | - Not Acceptable. - The requested media type is not supported. - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/throttling-policies/api/Platinum"' -#----------------------------------------------------- -# Update a certain tier -#----------------------------------------------------- - put: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\"" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\": \"30\",\n \"b\": \"10\",\n \"c\": \"20\"\n }\n}\n" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"10\",\n \"c\": \"20\",\n \"a\": \"30\"\n }\n}" - summary: Update a Tier - description: | - This operation can be used to update an existing tier. The only supported tier level is `api` tiers. - `PUT https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low` - - **IMPORTANT:** - * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. - parameters: - - $ref: '#/parameters/tierName' - - in: body - name: body - description: | - Tier object that needs to be modified - required: true - schema: - $ref: '#/definitions/Tier' - - $ref: '#/parameters/tierLevel-A' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Subscription updated. - schema: - $ref: '#/definitions/Tier' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a certain tier -#----------------------------------------------------- - delete: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE \"https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\"" - x-wso2-request: | - DELETE https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete a Tier - description: | - This operation can be used to delete an existing tier. The only supported tier level is `api` tiers. - `DELETE https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low` - - **IMPORTANT:** - * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel-A' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Update Permission" Processing Function resource API -###################################################### - '/tiers/update-permission': - -#----------------------------------------------------- -# Update the permission of a certain tier -#----------------------------------------------------- - post: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/update-permission?tierName=Bronze&tierLevel=api\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/tiers/update-permission?tierName=Bronze&tierLevel=api\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"permissionType\":\"deny\",\n \"roles\": [\"Internal/everyone\",\"admin\"]\n}" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Update tier permission - description: | - This operation can be used to update tier permissions which controls access for the particular tier based on the subscribers' roles. - parameters: - - $ref: '#/parameters/tierName-Q' - - $ref: '#/parameters/tierLevel-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - - in: body - name: permissions - schema: - $ref: '#/definitions/TierPermission' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Successfully updated tier permissions - schema: - type: array - items: - $ref: '#/definitions/Tier' - headers: - ETag: - description: | - Entity Tag of the modified tier. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the tier has been modified. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested tier does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - -###################################################### -# The "Environment Collection" resource API -###################################################### - /environments: - -#----------------------------------------------------- -# Retrieve the list of environments configured for a certain API -#----------------------------------------------------- + ###################################################### + # The "Mediation Policy Collection" resource APIs + ###################################################### + /mediation-policies: get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/environments\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/environments - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"list\": [ {\n \"showInApiConsole\": true,\n \"serverUrl\": \"https://localhost:9443/services/\",\n \"endpoints\": {\n \"http\": \"http://localhost:8280\",\n \"https\": \"https://localhost:8243\"\n },\n \"name\": \"Production and Sandbox\",\n \"type\": \"hybrid\"\n }],\n \"count\": 1\n}" - summary: Get all gateway environments - description: | - This operation can be used to retrieve the list of gateway environments available. - parameters: - - $ref: '#/parameters/apiId-Q' tags: - - Environment (Collection) - responses: - 200: - description: | - OK. - Environment list is returned. - schema: - $ref: '#/definitions/EnvironmentList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - /policies/mediation: - -#----------------------------------------------------------------------------------------- -# Retrieving the list of all global mediation sequences under a given search condition -#----------------------------------------------------------------------------------------- - get: - x-scope: apim:mediation_policy_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/policies/mediation" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/policies/mediation - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"count\": 10,\r\n \"next\": null,\r\n \"previous\": null,\r\n \"list\": [\r\n {\r\n \"name\": \"debug_json_fault\",\r\n \"id\": \"563de8f3-dd1d-4ec7-afc2-d158c663ed34\",\r\n \"type\": \"fault\"\r\n },\r\n {\r\n \"name\": \"json_fault\",\r\n \"id\": \"f9c36f4d-a2b6-41e7-b311-d358a47916be\",\r\n \"type\": \"fault\"\r\n },\r\n {\r\n \"name\": \"json_to_xml_in_message\",\r\n \"id\": \"3921225b-7918-4b95-a851-22c4e4e3e911\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"debug_in_flow\",\r\n \"id\": \"2bc15f93-4455-4763-89b8-83600fb9d731\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"log_in_message\",\r\n \"id\": \"4d287cca-76ab-44ca-b22e-919fc27c50e3\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"preserve_accept_header\",\r\n \"id\": \"3776b215-b3bc-40b6-bdcb-06efa7de64be\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"xml_to_json_in_message\",\r\n \"id\": \"50ac2002-769e-4f90-8549-6d0248dff7d2\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"xml_to_json_out_message\",\r\n \"id\": \"2af75853-ed75-4d25-81aa-0ebbeca691ea\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"json_to_xml_out_message\",\r\n \"id\": \"d9fa3ffc-f6b6-4171-ab97-eb44196cb66e\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"debug_out_flow\",\r\n \"id\": \"260b7701-4071-46bd-9b66-900ac6fffed6\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"apply_accept_header\",\r\n \"id\": \"15c17c2f-33e3-4c37-a262-04dfa49983a4\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"log_out_message\",\r\n \"id\": \"d37dca41-c048-492a-82cf-9a2292c6fff0\",\r\n \"type\": \"out\"\r\n }\r\n ]\r\n}" + - Global Mediation Policies summary: | Get all global level mediation policies description: | This operation provides you a list of available all global level mediation policies. + operationId: getAllGlobalMediationPolicies parameters: - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - name : query + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - name: query in: query - description: "-Not supported yet-" - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - Mediation Policy (Collection) + description: -Not supported yet- + schema: + type: string + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. List of mediation policies is returned. - schema: - $ref: '#/definitions/mediationList' headers: - Content-Type: - description: The content type of the body. - type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/MediationList' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + - apim:mediation_policy_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/mediation-policies"' + x-examples: + $ref: docs/examples/mediation-policies/mediation_policies_get.yaml - - -###################################################### -# The "Workflow approval" resource API -###################################################### - /workflows/update-workflow-status: - -#------------------------------------------------------------------- -# Resume the workflow by approving or rejecting the workflow request -#------------------------------------------------------------------- - post: - x-scope: apim:api_workflow - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/workflows/update-workflow-status?workflowReferenceId=56e3a170-a7a7-45f8-b051-7e43a58a67e1\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/workflows/update-workflow-status?workflowReferenceId=56e3a170-a7a7-45f8-b051-7e43a58a67e1\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"status\" : \"APPROVED\",\n \"attributes\" : {\n \"apiCurrentState\": \"Created\",\n \"apiLCAction\": \"Publish\",\n \"apiName\":\"APIname\",\n \"apiVersion\" : \"1.0.0\",\n \"apiProvider\" : \"admin\",\n \"invoker\": \"admin\"\n }\n}" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Update workflow status - description: | - This operation can be used to approve or reject a workflow task. - parameters: - - $ref: '#/parameters/workflowReferenceId-Q' - - in: body - name: body - description: | - Workflow event that need to be updated - required: true - schema: - $ref: '#/definitions/Workflow' + ################################################################### + # The "Individual Mediation Policy" resource + ################################################################### + /mediation-policies/{mediationPolicyId}/content: + get: tags: - - Workflows (Individual) + - Global Mediation Policy + summary: Download a Global Mediation Policy + description: | + This operation can be used to download a particular global mediation policy. + operationId: getGlobalMediationPolicyContent + parameters: + - $ref: '#/components/parameters/mediationPolicyId' + - $ref: '#/components/parameters/If-None-Match' responses: 200: description: | OK. - Workflow request information is returned. + Mediation policy returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + - apim:mediation_policy_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/mediation-policies/d48a3412-1b85-49be-99f4-b81a3722ae73/content" + > mediation.xml' + + /apis/{apiId}/client-certificates: + get: + tags: + - Client Certificates + summary: Retrieve/ Search Uploaded Client Certificates + description: | + This operation can be used to retrieve and search the uploaded client certificates. + parameters: + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - name: alias + in: query + description: Alias for the client certificate schema: - $ref: '#/definitions/Workflow' + type: string + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. Successful response with the list of matching certificate information in the body. headers: Content-Type: description: | The content type of the body. - type: string + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ClientCertificates' 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Workflow for the given reference in not found. - schema: - $ref: '#/definitions/Error' -###################################################### -# Parameters - required by some of the APIs above -###################################################### -parameters: + $ref: '#/components/responses/BadRequest' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + - apim:client_certificates_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates?alias=wso2carbon"' + operationId: getAPIClientCertificates -# API Identifier -# Specified as part of the path expression - apiId: - name: apiId - in: path - description: | - **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. - Should be formatted as **provider-name-version**. - required: true - type: string - x-encoded: true - -# API Identifier -# Specified as part of the query string - apiId-Q: - name: apiId - in: query - description: | - **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - required: true - type: string - x-encoded: true - - -# Document Identifier -# Specified as part of the path expression - documentId: - name: documentId - in: path - description: | - Document Identifier - required: true - type: string - -# Application Identifier -# Specified as part of the path expression - applicationId: - name: applicationId - in: path - description: | - **Application Identifier** consisting of the UUID of the Application. - required: true - type: string - -# Subscription Identifier -# Specified as part of the path expression - subscriptionId: - name: subscriptionId - in: path - description: | - Subscription Id - required: true - type: string - -# Mediation policy identifier -# Specified as part of the path expression - mediationPolicyId: - name: mediationPolicyId - in: path - description: | - Mediation policy Id - required: true - type: string - - - -# Subscription Identifier -# Specified as part of the query string - subscriptionId-Q: - name: subscriptionId - in: query - description: | - Subscription Id - required: true - type: string - -# Tier Name -# Specified as part of the path expression - tierName: - name: tierName - in: path - description: | - Tier name - required: true - type: string - -# Tier Name -# Specified as part of the query string - tierName-Q: - name: tierName - in: query - description: | - Name of the tier - required: true - type: string - -# Tier Type -# Specified as part of the path expression - tierLevel: - name: tierLevel - in: path - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - - application - - resource - required: true - -# Tier Type -# Specified as part of the path expression - tierLevel-A: - name: tierLevel - in: path - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - required: true - -# Tier Type -# Specified as part of the query string - tierLevel-Q: - name: tierLevel - in: query - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - - application - - resource - required: true - -# Used for pagination: -# The maximum number of resoures to be returned by a GET - limit: - name: limit - in: query - description: | - Maximum length of resource array to return. - default: 25 - type: integer - -# Used for pagination: -# The order number of an instance in a qualified set of resoures -# at which to start to return the next batch of qualified resources - offset: - name: offset - in: query - description: | - Starting point within the complete list of items qualified. - default: 0 - type: integer - -# The HTTP Accept header - Accept: - name: Accept - in: header - description: | - Media types acceptable for the response. Default is application/json. - default: application/json - type: string - -# The HTTP Content-Type header - Content-Type: - name: Content-Type - in: header - description: | - Media type of the entity in the body. Default is application/json. - default: application/json - required: true - type : string - -# The HTTP Authorization header - Authorization: - name: Authorization - in: header - description: | - Holds the bearer token for apis that require authentication. - required: true - type : string - -# The HTTP If-None-Match header -# Used to avoid retrieving data that are already cached - If-None-Match: - name: If-None-Match - in: header - description: | - Validator for conditional requests; based on the ETag of the formerly retrieved - variant of the resource (Will be supported in future). - type : string - -# The HTTP If-Modified-Since header -# Used to avoid retrieving data that are already cached - If-Modified-Since: - name: If-Modified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header of the - formerly retrieved variant of the resource (Will be supported in future). - type: string - -# The HTTP If-Match header -# Used to avoid concurrent updates - If-Match: - name: If-Match - in: header - description: | - Validator for conditional requests; based on ETag (Will be supported in future). - type: string - -# The HTTP If-Unmodified-Since header -# Used to avoid concurrent updates - If-Unmodified-Since: - name: If-Unmodified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header (Will be supported in future). - type: string - - -# Workflow reference ID -# Specified as part of the path expression - workflowReferenceId-Q: - name: workflowReferenceId - in: query - description: | - Workflow reference id - required: true - type: string - -###################################################### -# The resources used by some of the APIs above within the message body -###################################################### -definitions: - -#----------------------------------------------------- -# The API List resource -#----------------------------------------------------- - APIList: - title: API List - properties: - count: - type: integer - description: | - Number of APIs returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis?limit=1&offset=2&query=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis?limit=1&offset=0&query=" - list: - type: array - items: - $ref: '#/definitions/APIInfo' - pagination: - properties: - offset: - type: integer - example: 12 - limit: - type: integer - example: 25 - total: - type: integer - example: 1290 - -#----------------------------------------------------- -# The API Info resource -#----------------------------------------------------- - APIInfo: - title: API Info object with basic API details. - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - type: string - example: admin - status: - type: string - example: CREATED - thumbnailUri: - type: string - example: /apis/01234567-0123-0123-0123-012345678901/thumbnail - -#----------------------------------------------------- -# The API resource -#----------------------------------------------------- - API: - title: API object - required: - - name - - context - - version - - tiers - - isDefaultVersion - - transport - - endpointConfig - - visibility - - type - properties: - id: - type: string - description: | - UUID of the api registry artifact - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - description: Name of the API - example: CalculatorAPI - description: - type: string - description: A brief description about the API - example: A calculator API that supports basic operations - context: - type: string - description: A string that represents the context of the user's request - example: CalculatorAPI - version: - type: string - description: The version of the API - example: 1.0.0 - provider: - description: | - If the provider value is not given user invoking the api will be used as the provider. - type: string - example: admin - apiDefinition: - description: | - Swagger definition of the API which contains details about URI templates and scopes - type: string - example: "{\"paths\":{\"/substract\":{\"get\":{\"x-auth-type\":\"Application & Application User\",\"x-throttling-tier\":\"Unlimited\",\"parameters\":[{\"name\":\"x\",\"required\":true,\"type\":\"string\",\"in\":\"query\"},{\"name\":\"y\",\"required\":true,\"type\":\"string\",\"in\":\"query\"}],\"responses\":{\"200\":{}}}},\"/add\":{\"get\":{\"x-auth-type\":\"Application & Application User\",\"x-throttling-tier\":\"Unlimited\",\"parameters\":[{\"name\":\"x\",\"required\":true,\"type\":\"string\",\"in\":\"query\"},{\"name\":\"y\",\"required\":true,\"type\":\"string\",\"in\":\"query\"}],\"responses\":{\"200\":{}}}}},\"swagger\":\"2.0\",\"info\":{\"title\":\"CalculatorAPI\",\"version\":\"1.0.0\"}}" - wsdlUri: - description: | - WSDL URL if the API is based on a WSDL endpoint - type: string - example: "http://www.webservicex.com/globalweather.asmx?wsdl" - status: - type: string - description: This describes in which status of the lifecycle the API is - example: CREATED - responseCaching: - type: string - example: Disabled - cacheTimeout: - type: integer - example: 300 - destinationStatsEnabled: - type: string - example: Disabled - isDefaultVersion: - type: boolean - example: false - type: - type: string - description: The transport to be set. Accepted values are HTTP, WS - enum: - - HTTP - - WS - example: HTTP - default: HTTP - transport: - description: | - Supported transports for the API (http and/or https). - type: array - items: - type: string - example: ["http","https"] + post: tags: - type: array - description: Search keywords related to the API - items: - type: string - example: ["substract","add"] - tiers: - type: array - description: The subscription tiers selected for the particular API - items: - type: string - example: ["Unlimited"] - apiLevelPolicy: - description: The policy selected for the particular API - type: string - example: "Unlimited" - maxTps: - properties: - production: - type: integer - format: int64 - example: 1000 - sandbox: - type: integer - format: int64 - example: 1000 - thumbnailUri: - type: string - example: "/apis/01234567-0123-0123-0123-012345678901/thumbnail" - visibility: - type: string - description: The visibility level of the API. Accepts one of the following. PUBLIC, PRIVATE, RESTRICTED OR CONTROLLED. - enum: - - PUBLIC - - PRIVATE - - RESTRICTED - - CONTROLLED - example: PUBLIC - visibleRoles: - type: array - description: The user roles that are able to access the API - items: - type: string - example: [] - endpointConfig: - type: string - example: "{\"production_endpoints\":{\"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/\",\"config\":{\"suspendErrorCode\":\"101000\",\"suspendDuration\":\"2000\",\"suspendMaxDuration\":\"3\",\"factor\":\"2\",\"retryErroCode\":\"101000\",\"retryTimeOut\":\"4\",\"retryDelay\":\"1000\",\"actionSelect\":\"fault\",\"actionDuration\":\"3000\"}},\"sandbox_endpoints\":{\"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/\",\"config\":null},\"endpoint_type\":\"http\"}" - endpointSecurity: - properties: - type: + - Client Certificates + summary: Upload a New Certificate + description: | + This operation can be used to upload a new certificate for an endpoint. + parameters: + - $ref: '#/components/parameters/apiId' + requestBody: + content: + multipart/form-data: + schema: + required: + - alias + - certificate + - tier + properties: + certificate: + type: string + description: The certificate that needs to be uploaded. + format: binary + alias: + maxLength: 30 + minLength: 1 + type: string + description: Alias for the certificate + tier: + type: string + description: api tier to which the certificate should be applied. + required: true + responses: + 200: + description: | + OK. + The Certificate added successfully. + headers: + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ClientCertMetadata' + 400: + $ref: '#/components/responses/BadRequest' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:client_certificates_add + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: multipart/form-data" -F certificate=@test.crt -F alias=wso2carbon + -F apiId=fea749dd-d548-4a8b-b308-34903b39a34b -F tier=Gold "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates"' + operationId: addAPIClientCertificate + + /apis/{apiId}/client-certificates/{alias}: + get: + tags: + - Client Certificates + summary: Get the Certificate Information + description: | + This operation can be used to get the information about a certificate. + parameters: + - name: alias + in: path + required: true + schema: + type: string + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/CertificateInfo' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + - apim:client_certificates_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon"' + operationId: getAPIClientCertificateByAlias + + put: + tags: + - Client Certificates + summary: Update a Certificate + description: | + This operation can be used to update an uploaded certificate. + parameters: + - name: alias + in: path + description: Alias for the certificate + required: true + schema: + maxLength: 30 + minLength: 1 + type: string + - $ref: '#/components/parameters/apiId' + requestBody: + content: + multipart/form-data: + schema: + properties: + certificate: + type: string + description: The certificate that needs to be uploaded. + format: binary + tier: + type: string + description: The tier of the certificate + responses: + 200: + description: | + OK. + The Certificate updated successfully. + headers: + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ClientCertMetadata' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:client_certificates_update + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: multipart/form-data" -F certificate=@test.crt -F alias=wso2carbon + -F apiId=fea749dd-d548-4a8b-b308-34903b39a34b -F tier=Gold "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon"' + operationId: updateAPIClientCertificateByAlias + + delete: + tags: + - Client Certificates + summary: Delete a Certificate + description: | + This operation can be used to delete an uploaded certificate. + parameters: + - name: alias + in: path + description: | + The alias of the certificate that should be deleted. + required: true + schema: + type: string + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. + The Certificate deleted successfully. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:client_certificates_update + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon"' + operationId: deleteAPIClientCertificateByAlias + + /apis/{apiId}/client-certificates/{alias}/content: + get: + tags: + - Client Certificates + summary: Download a Certificate + description: | + This operation can be used to download a certificate which matches the given alias. + parameters: + - $ref: '#/components/parameters/apiId' + - name: alias + in: path + required: true + schema: + type: string + responses: + 200: + description: | + OK. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + - apim:client_certificates_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon/content"' + operationId: getAPIClientCertificateContentByAlias + + ###################################################### + # The "Certificate Management" resource APIs + ###################################################### + /endpoint-certificates: + get: + tags: + - Endpoint Certificates + summary: Retrieve/Search Uploaded Certificates + description: | + This operation can be used to retrieve and search the uploaded certificates. + parameters: + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - name: alias + in: query + description: Alias for the certificate + schema: + maxLength: 30 + type: string + - name: endpoint + in: query + description: Endpoint of which the certificate is uploaded + schema: + type: string + responses: + 200: + description: | + OK. Successful response with the list of matching certificate information in the body. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Certificates' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + - apim:ep_certificates_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates?alias=wso2carbon&endpoint=www.abc.com"' + operationId: getEndpointCertificates + + post: + tags: + - Endpoint Certificates + summary: Upload a new Certificate. + description: | + This operation can be used to upload a new certificate for an endpoint. + requestBody: + content: + multipart/form-data: + schema: + required: + - alias + - certificate + - endpoint + properties: + certificate: + type: string + description: The certificate that needs to be uploaded. + format: binary + alias: + maxLength: 30 + minLength: 1 + type: string + description: Alias for the certificate + endpoint: + type: string + description: Endpoint to which the certificate should be applied. + required: true + responses: + 200: + description: | + OK. + The Certificate added successfully. + headers: + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/CertMetadata' + 400: + $ref: '#/components/responses/BadRequest' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:ep_certificates_add + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: multipart/form-data" -F certificate=@test.crt -F alias=alias + -F "endpoint=endpoint=https://www.abc.com" "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/endpoint-certificates"' + operationId: addEndpointCertificate + + /endpoint-certificates/{alias}: + get: + tags: + - Endpoint Certificates + summary: Get the Certificate Information + description: | + This operation can be used to get the information about a certificate. + parameters: + - name: alias + in: path + required: true + schema: + type: string + responses: + 200: + description: | + OK. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/CertificateInfo' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + - apim:ep_certificates_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates/wso2carbon"' + operationId: getEndpointCertificateByAlias + + put: + tags: + - Endpoint Certificates + summary: Update a certificate. + description: | + This operation can be used to update an uploaded certificate. + parameters: + - name: alias + in: path + description: Alias for the certificate + required: true + schema: + maxLength: 30 + minLength: 1 + type: string + requestBody: + content: + multipart/form-data: + schema: + required: + - certificate + properties: + certificate: + type: string + description: The certificate that needs to be uploaded. + format: binary + required: true + responses: + 200: + description: | + OK. + The Certificate updated successfully. + headers: + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/CertMetadata' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:ep_certificates_update + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: multipart/form-data" -F certificate=@test.crt "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/endpoint-certificates/wso2carbon"' + operationId: updateEndpointCertificateByAlias + + delete: + tags: + - Endpoint Certificates + summary: Delete a certificate. + description: | + This operation can be used to delete an uploaded certificate. + parameters: + - name: alias + in: path + description: | + The alias of the certificate that should be deleted. + required: true + schema: + type: string + responses: + 200: + description: | + OK. + The Certificate deleted successfully. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:ep_certificates_update + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates/wso2carbon"' + operationId: deleteEndpointCertificateByAlias + + /endpoint-certificates/{alias}/content: + get: + tags: + - Endpoint Certificates + summary: Download a Certificate + description: | + This operation can be used to download a certificate which matches the given alias. + parameters: + - name: alias + in: path + required: true + schema: + type: string + responses: + 200: + description: | + OK. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + - apim:ep_certificates_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates/wso2carbon/content"' + operationId: getEndpointCertificateContentByAlias + + ###################################################### + # The "Content Search Results" resource APIs + ###################################################### + /search: + get: + tags: + - Unified Search + summary: | + Retrieve/Search APIs and API Documents by Content + description: | + This operation provides you a list of available APIs and API Documents qualifying the given keyword match. + parameters: + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - name: query + in: query + description: | + **Search**. + + You can search by proving a keyword. + schema: + type: string + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + List of qualifying APIs and API documents is returned. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/SearchResultList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + - apim:api_import_export + - apim:api_product_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/search?query=pizza"' + x-examples: + $ref: docs/examples/apis/search_get.yaml + operationId: search + + ###################################################### + # The "API Product Collection" resource APIs + ###################################################### + /api-products: + get: + tags: + - API Products + summary: | + Retrieve/Search API Products + description: | + This operation provides you a list of available API Products qualifying under a given search condition. + + Each retrieved API Product is represented with a minimal amount of attributes. If you want to get complete details of an API Product, you need to use **Get details of an API Product** operation. + parameters: + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - name: query + in: query + schema: + type: string + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + List of qualifying API Products is returned. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIProductList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products?query=PizzaAPIProduct"' + operationId: getAllAPIProducts + + post: + tags: + - API Products + summary: Create a New API Product + description: | + This operation can be used to create a new API Product specifying the details of the API Product in the payload. + requestBody: + description: API object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/APIProduct' + required: true + responses: + 201: + description: | + 'Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity.' + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIProduct' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products"' + operationId: createAPIProduct + + ################################################################ + # The "Individual API Product" resource APIs + ################################################################ + /api-products/{apiProductId}: + get: + tags: + - API Products + summary: Get Details of an API Product + description: | + Using this operation, you can retrieve complete details of a single API Product. You need to provide the Id of the API to retrive it. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested API Product is returned + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIProduct' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33"' + operationId: getAPIProduct + + put: + tags: + - API Products + summary: Update an API Product + description: | + This operation can be used to update an existing API product. + But the properties `name`, `provider` and `version` cannot be changed. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/If-Match' + requestBody: + description: API object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/APIProduct' + required: true + responses: + 200: + description: | + OK. + Successful response with updated API product object + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIProduct' + 400: + $ref: '#/components/responses/BadRequest' + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33"' + operationId: updateAPIProduct + + + delete: + tags: + - API Products + summary: Delete an API Product + description: | + This operation can be used to delete an existing API Product proving the Id of the API Product. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/If-Match' + responses: + 200: + description: | + OK. + Resource successfully deleted. + content: {} + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_product_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33"' + operationId: deleteAPIProduct + + /api-products/{apiProductId}/thumbnail: + get: + tags: + - API Products + summary: Get Thumbnail Image + description: | + This operation can be used to download a thumbnail image of an API product. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Thumbnail image returned + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/thumbnail" + > image.jpeg' + operationId: getAPIProductThumbnail + + put: + tags: + - API Products + summary: Upload a Thumbnail Image + description: | + This operation can be used to upload a thumbnail image of an API Product. The thumbnail to be uploaded should be given as a form data parameter `file`. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + required: + - file + properties: + file: + type: string + description: Image to upload + format: binary + required: true + responses: + 200: + description: | + OK. + Image updated + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the uploaded thumbnail image of the API Product. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/FileInfo' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: multipart/form-data" -F file=@image.jpeg "https://127.0.0.1:9443/api/am/publisher/v2/api-products/d48a3412-1b85-49be-99f4-b81a3722ae73/thumbnail"' + operationId: updateAPIProductThumbnail + + /api-products/{apiProductId}/swagger: + get: + tags: + - API Products + summary: Get Swagger Definition + description: | + This operation can be used to retrieve the swagger definition of an API. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested swagger document of the API is returned + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/swagger"' + operationId: getAPIProductSwagger + + /api-products/{apiProductId}/is-outdated: + get: + tags: + - API Products + summary: Check Whether API Product is Outdated + description: | + This operation can be used to retrieve the status indicating if an API Product is outdated due to updating of dependent APIs (This resource is not supported at the moment) + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested swagger document of the API is returned + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIProductOutdatedStatus' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + operationId: getIsAPIProductOutdated + + /api-products/{apiProductId}/documents: + get: + tags: + - API Product Documents + summary: Get a List of Documents of an API Product + description: | + This operation can be used to retrive a list of documents belonging to an API Product by providing the id of the API Product. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Document list is returned. + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/DocumentList' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents"' + operationId: getAPIProductDocuments + + post: + tags: + - API Product Documents + summary: Add a New Document to an API Product + description: | + This operation can be used to add a new documentation to an API Product. This operation only adds the metadata of a document. To add the actual content we need to use **Upload the content of an API Product document ** API once we obtain a document Id by this operation. + parameters: + - $ref: '#/components/parameters/apiProductId' + requestBody: + description: Document object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + required: true + responses: + 201: + description: | + Created. + Successful response with the newly created Document object as entity in the body. + Location header contains URL of newly added document. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + Location to the newly created Document. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents"' + operationId: addAPIProductDocument + + /api-products/{apiProductId}/documents/{documentId}: + get: + tags: + - API Product Documents + summary: Get a Document of an API Product + description: | + This operation can be used to retrieve a particular document's metadata associated with an API. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Document returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3"' + operationId: getAPIProductDocument + + put: + tags: + - API Product Documents + summary: Update a Document of an API Product + description: | + This operation can be used to update metadata of an API's document. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-Match' + requestBody: + description: Document object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + required: true + responses: + 200: + description: | + OK. + Document updated + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the updated document. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3"' + operationId: updateAPIProductDocument + + delete: + tags: + - API Product Documents + summary: Delete a Document of an API Product + description: | + This operation can be used to delete a document associated with an API Product. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-Match' + responses: + 200: + description: | + OK. + Resource successfully deleted. + content: {} + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3"' + operationId: deleteAPIProductDocument + + /api-products/{apiProductId}/documents/{documentId}/content: + get: + tags: + - API Product Documents + summary: Get the Content of an API Product Document + description: | + This operation can be used to retrive the content of an API's document. + + The document can be of 3 types. In each cases responses are different. + + 1. **Inline type**: + The content of the document will be retrieved in `text/plain` content type + + _Sample cURL_ : `curl -k -H "Authorization:Bearer 579f0af4-37be-35c7-81a4-f1f1e9ee7c51" -F inlineContent=@"docs.txt" -X POST "https://localhost:9443/api/am/publisher/v2/apis/995a4972-3178-4b17-a374-756e0e19127c/documents/43c2bcce-60e7-405f-bc36-e39c0c5e189e/content` + 2. **FILE type**: + The file will be downloaded with the related content type (eg. `application/pdf`) + 3. **URL type**: + The client will recieve the URL of the document as the Location header with the response with - `303 See Other` + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/Accept' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + File or inline content returned. + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 303: + description: | + See Other. + Source can be retrived from the URL specified at the Location header. + headers: + Location: + description: | + The Source URL of the document. + schema: + type: string + content: {} + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: {} + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3/content"' + operationId: getAPIProductDocumentContent + + post: + tags: + - API Product Documents + summary: Upload the Content of an API Product Document + description: | + Thid operation can be used to upload a file or add inline content to an API Product document. + + **IMPORTANT:** + * Either **file** or **inlineContent** form data parameters should be specified at one time. + * Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. + * Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/documentId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + properties: + file: + type: string + description: Document to upload + format: binary + inlineContent: + type: string + description: Inline content of the document + responses: + 200: + description: | + OK. + Document updated + headers: + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the updated content of the document. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: multipart/form-data" -F file=@sample.pdf "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3/content"' + operationId: addAPIProductDocumentContent + + ###################################################### + # The "API Product Revisions" resource API + ###################################################### + /api-products/{apiProductId}/revisions: + + #-------------------------------------------- + # List available revisions of an API Product + #-------------------------------------------- + get: + tags: + - API Product Revisions + summary: List available revisions of an API Product + description: | + List available revisions of an API Product + operationId: getAPIProductRevisions + parameters: + - $ref: '#/components/parameters/apiProductId' + - name: query + in: query + schema: + type: string + responses: + 200: + description: | + OK. + List of API Product revisions are returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevisionList' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_product_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions?query=deployed:true"' + + #-------------------------------------------- + # Create a new API Product revision + #-------------------------------------------- + post: + tags: + - API Product Revisions + summary: Create a new API Product revision + description: | + Create a new API Product revision + operationId: createAPIProductRevision + parameters: + - $ref: '#/components/parameters/apiProductId' + requestBody: + description: API Product object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevision' + responses: + 201: + description: | + Created. + Successful response with the newly created APIRevision object as the entity in the body. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevision' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions"' + + ###################################################### + # The "API Revisions" individual resource API Product + ###################################################### + /api-products/{apiProductId}/revisions/{revisionId}: + + #-------------------------------------------- + # Get a revision + #-------------------------------------------- + get: + tags: + - API Product Revisions + summary: Retrieve a revision of an API Product + description: | + Retrieve a revision of an API Product + operationId: getAPIProductRevision + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/revisionId' + responses: + 200: + description: | + OK. + An API revision is returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevision' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' + + #-------------------------------------------- + # Delete a revision + #-------------------------------------------- + delete: + tags: + - API Product Revisions + summary: Delete a revision of an API Product + description: | + Delete a revision of an API Product + operationId: deleteAPIProductRevision + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/revisionId' + responses: + 200: + description: | + OK. + List of remaining API revisions are returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevisionList' + 204: + description: | + No Content. + Successfully deleted the revision + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /api-products/{apiProductId}/deploy-revision: + + #-------------------------------------------- + # List available deployed revision deployment details of an API Product + #-------------------------------------------- + get: + tags: + - API Product Revisions + summary: List available deployed revision deployment details of an API Product + description: | + List available deployed revision deployment details of an API Product + operationId: getAPIProductRevisionDeployments + parameters: + - $ref: '#/components/parameters/apiProductId' + responses: + 200: + description: | + OK. + List of deployed revision deployment details are returned. + content: + application/json: + schema: + $ref: '#/components/schemas/APIRevisionDeploymentList' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision"' + + #-------------------------------------------- + # Deploy a revision + #-------------------------------------------- + post: + tags: + - API Product Revisions + summary: Deploy a revision + description: | + Deploy a revision + operationId: deployAPIProductRevision + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/revisionId-Q' + requestBody: + description: Deployment object that needs to be added + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + responses: + 200: + description: | + OK. + 201: + description: | + Created. + Successful response with the newly deployed APIRevisionDeployment List object as the entity in the body. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /api-products/{apiProductId}/undeploy-revision: + #-------------------------------------------- + # Un-Deploy a revision from deployed gateway + #-------------------------------------------- + post: + tags: + - API Product Revisions + summary: Un-Deploy a revision + description: | + Un-Deploy a revision + operationId: undeployAPIProductRevision + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/revisionId-Q' + - $ref: '#/components/parameters/revisionNum-Q' + - name: allEnvironments + in: query + schema: + type: boolean + default: false + requestBody: + description: Deployment object that needs to be added + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + responses: + 200: + description: | + OK. + 201: + description: | + Created. + Successful response with the newly undeployed APIRevisionDeploymentList object as the entity in the body. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + - apim:api_product_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/undeploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /api-products/{apiProductId}/restore-revision: + + #-------------------------------------------------------- + # Restore a revision to the working copy of the API Product + #-------------------------------------------------------- + post: + tags: + - API Product Revisions + summary: Restore a revision + description: | + Restore a revision to the working copy of the API Product + operationId: restoreAPIProductRevision + parameters: + - $ref: '#/components/parameters/apiProductId' + - $ref: '#/components/parameters/revisionId-Q' + responses: + 201: + description: | + Restored. + Successful response with the newly restored API Product object as the entity in the body. + content: + application/json: + schema: + $ref: '#/components/schemas/APIProduct' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/restore-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' + + /api-products/export: + get: + tags: + - Import Export + summary: Export an API Product + description: | + This operation can be used to export the details of a particular API Product as a zip file. + parameters: + - name: name + in: query + description: | + API Product Name + schema: + type: string + - name: version + in: query + description: | + Version of the API Product + schema: + type: string + - name: providerName + in: query + description: | + Provider name of the API Product + schema: + type: string + - name: revisionNumber + in: query + description: | + Revision number of the API Product + schema: + type: string + - name: format + in: query + description: | + Format of output documents. Can be YAML or JSON. + schema: type: string - example: basic - description: Accepts one of the following, basic or digest. enum: - - basic - - digest - username: - type: string - example: admin - password: - type: string - example: password - gatewayEnvironments: - description: | - Comma separated list of gateway environments. - type: string - example: Production and Sandbox - sequences: - type: array - items: - $ref: '#/definitions/Sequence' - example: [] - subscriptionAvailability: - type: string - description: The subscription availability. Accepts one of the following. current_tenant, all_tenants or specific_tenants. - enum: - - current_tenant - - all_tenants - - specific_tenants - example: current_tenant - subscriptionAvailableTenants: - type: array - items: - type: string - example: ["tenant1", "tenant2"] - additionalProperties: - type: object - description : Map of custom properties of API - accessControl: - type: string - description: | - Is the API is restricted to certain set of publishers or creators or is it visible to all the - publishers and creators. If the accessControl restriction is none, this API can be modified by all the - publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, - based on the restriction. enum: - - NONE - - RESTRICTED - accessControlRoles: - type: array - description: The user roles that are able to view/modify as API publisher or creator. - items: - type: string - example: [admin] - businessInformation: - properties: - businessOwner: - type: string - example: businessowner - businessOwnerEmail: - type: string - example: businessowner@wso2.com - technicalOwner: - type: string - example: technicalowner - technicalOwnerEmail: - type: string - example: technicalowner@wso2.com - corsConfiguration: - description: | - CORS configuration for the API - properties: - corsConfigurationEnabled: + - JSON + - YAML + - name: preserveStatus + in: query + description: | + Preserve API Product Status on export + schema: + type: boolean + - name: latestRevision + in: query + description: | + Export the latest revision of the API Product + schema: type: boolean default: false - accessControlAllowOrigins: - type: array - items: - type: string - accessControlAllowCredentials: - type: boolean - default: false - accessControlAllowHeaders: - type: array - items: - type: string - accessControlAllowMethods: - type: array - items: - type: string + responses: + 200: + description: | + OK. + Export Successful. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/zip: + schema: + type: string + format: binary + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-products/export?name=LeasingAPIProduct&version=1.0.0&revisionNumber=2&provider=admin&format=YAML" + > exportAPIProduct.zip' + operationId: exportAPIProduct -#----------------------------------------------------- -# The Application resource -#----------------------------------------------------- - Application: - title: Application - required: - - name - - throttlingTier - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - type: string - example: admin - throttlingTier: - type: string - example: Unlimited + /api-products/import: + post: + tags: + - Import Export + summary: Import an API Product + description: | + This operation can be used to import an API Product. + parameters: + - name: preserveProvider + in: query + description: | + Preserve Original Provider of the API Product. This is the user choice to keep or replace the API Product provider + required: false + schema: + type: boolean + - name: rotateRevision + in: query + description: | + Once the revision max limit reached, undeploy and delete the earliest revision and create a new revision + required: false + schema: + type: boolean + - name: importAPIs + in: query + description: | + Whether to import the dependent APIs or not. + schema: + type: boolean + - name: overwriteAPIProduct + in: query + description: | + Whether to update the API Product or not. This is used when updating already existing API Products. + schema: + type: boolean + - name: overwriteAPIs + in: query + description: | + Whether to update the dependent APIs or not. This is used when updating already existing dependent APIs of an API Product. + schema: + type: boolean + requestBody: + content: + multipart/form-data: + schema: + required: + - file + properties: + file: + type: string + description: | + Zip archive consisting on exported API Product configuration + format: binary + responses: + 200: + description: | + Created. + API Product Imported Successfully. + content: {} + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 409: + $ref: '#/components/responses/Conflict' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_product_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -F file=@admin-PizzaShackAPIProduct.zip "https://127.0.0.1:9443/api/am/admin/v2/api-products/importt?preserveProvider=false&overwriteAPIProduct=false&overwriteAPIs=false&importAPIs=false"' + operationId: importAPIProduct + + ###################################################### + # Roles resource APIs + ###################################################### + /roles/{roleId}: + head: + tags: + - Roles + summary: Check Whether Given Role Name already Exist + description: | + Using this operation, user can check a given role name exists or not. + operationId: validateSystemRole + parameters: + - $ref: '#/components/parameters/roleId' + responses: + 200: + description: OK. Requested role name exists. + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/roles/SW50ZXJuYWwvcHVibGlzaGVyCQ"' + + /me/roles/{roleId}: + head: + tags: + - Roles + summary: Validate Whether the Logged-in User has the Given Role + description: | + Using this operation, logged-in user can check whether he has given role. + operationId: validateUserRole + parameters: + - $ref: '#/components/parameters/roleId' + responses: + 200: + description: OK. Requested user has the role. + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/me/roles/SW50ZXJuYWwvcHVibGlzaGVyCQ"' + + ###################################################### + # The "ExternalStore Collection" resource APIs + ###################################################### + /external-stores: + get: + tags: + - External Stores + summary: Retrieve External Stores List to Publish an API + description: | + Retrieve external stores list configured to publish an API + operationId: getAllExternalStores + responses: + 200: + description: | + OK. + External Stores list returned + content: + application/json: + schema: + $ref: '#/components/schemas/ExternalStore' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/external-stores"' + + ###################################################### + # The Publisher settings resource APIs + ###################################################### + /settings: + get: + tags: + - Settings + summary: Retreive Publisher Settings + description: | + Retreive publisher settings + responses: + 200: + description: | + OK. + Settings returned + content: + application/json: + schema: + $ref: '#/components/schemas/Settings' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:publisher_settings + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/settings"' + operationId: getSettings + + ###################################################### + # The tenant resource APIs + ###################################################### + /tenants: + get: + tags: + - Tenants + summary: | + Get Tenants by State + description: | + This operation is to get tenants by state + operationId: getTenantsByState + parameters: + - name: state + in: query + description: | + The state represents the current state of the tenant + + Supported states are [active, inactive] + schema: + type: string + default: active + enum: + - active + - inactive + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + responses: + 200: + description: | + OK. + Tenant names returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/TenantList' + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/tenants?state=active"' + + /tenants/{tenantDomain}: + head: + tags: + - Tenants + summary: Check Whether the Given Tenant already Exists + description: | + Using this operation, user can check whether a given tenant exists or not. + operationId: getTenantExistence + parameters: + - $ref: '#/components/parameters/tenantDomain' + responses: + 200: + description: OK. Requested tenant exists. + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/tenants/wso2.com"' + x-examples: + $ref: docs/examples/tenants/tenants.yaml + + #################################################### + # Publisher Alerts management REST API + #################################################### + /alert-types: + get: + tags: + - Alerts + summary: | + Get the list of API Publisher alert types. + description: | + This operation is used to get the list of supportd alert types for the 'publisher' agent. + operationId: getPublisherAlertTypes + responses: + 200: + description: | + OK. + The list of publisher alert types are returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/AlertTypesList' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:pub_alert_manage + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/alert-types"' + x-examples: + $ref: docs/examples/alerts/alerts.yaml#/get + + /alert-subscriptions: + get: + tags: + - Alert Subscriptions + summary: | + Get the List of API Publisher Alert Types Subscribed by the User + description: | + This operation is used to get the list of subscribed alert types by the user. + operationId: getSubscribedAlertTypes + responses: + 200: + description: | + OK. + The list of subscribed alert types are returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/AlertsInfo' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:pub_alert_manage + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/alert-subscriptions"' + x-examples: + $ref: docs/examples/alerts/alerts_subscriptions.yaml#/get + + put: + tags: + - Alert Subscriptions + summary: | + Subscribe to the Selected Tlert types by the User + description: | + This operation is used to get the list of subscribed alert types by the user. + operationId: subscribeToAlerts + requestBody: + description: The alerts list and the email list to subscribe. + content: + application/json: + schema: + $ref: '#/components/schemas/AlertsInfo' + required: true + responses: + 201: + description: | + OK. + Successful response with the newly subscribed alerts. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/AlertsInfoResponse' + 400: + $ref: '#/components/responses/BadRequest' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:pub_alert_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/alert-subscriptions"' + x-examples: + $ref: docs/examples/alerts/alerts_subscriptions.yaml#/put + + delete: + tags: + - Alert Subscriptions + summary: | + Unsubscribe User from All the Alert Types + description: | + This operation is used to unsubscribe the respective user from all the alert types. + operationId: unsubscribeAllAlerts + responses: + 200: + description: | + OK. + The user is unsubscribed from the alerts successfully. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: {} + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:pub_alert_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/alert-subscriptions"' + x-examples: + $ref: docs/examples/alerts/alerts_subscriptions.yaml#/delete + + /alerts/{alertType}/configurations: + get: + tags: + - Alert Configuration + summary: | + Get All AbnormalRequestsPerMin Alert Configurations + description: | + This operation is used to get all configurations of the AbnormalRequestsPerMin alert type. + operationId: getAllAlertConfigs + parameters: + - $ref: '#/components/parameters/alertType' + responses: + 200: + description: | + OK. + The Developer Portal alert configuration. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/AlertConfigList' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:pub_alert_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/alerts/{alertType}/configurations"' + x-examples: + $ref: docs/examples/alerts/alerts_config.yaml#/get + + /alerts/{alertType}/configurations/{configurationId}: + put: + tags: + - Alert Configuration + summary: | + Add AbnormalRequestsPerMin Alert Configurations. + description: | + This operation is used to add configuration for the AbnormalRequestsPerMin alert type. + operationId: addAlertConfig + parameters: + - $ref: '#/components/parameters/alertType' + - $ref: '#/components/parameters/configurationId' + requestBody: + description: Configuration for AbnormalRequestCount alert type + content: + application/json: + schema: + $ref: '#/components/schemas/AlertConfigInfo' + required: true + responses: + 201: + description: | + Created. + Successful response with newly created object as entity. + Location header contains URL of newly created entity. + headers: + Location: + description: | + The location of the newly created entity. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/AlertConfig' + 400: + $ref: '#/components/responses/BadRequest' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:pub_alert_manage + x-examples: + $ref: docs/examples/alerts/alerts_config.yaml#/put + + delete: + tags: + - Alert Configuration + summary: | + Delete the Selected Configuration from AbnormalRequestsPerMin Alert Type. + description: | + This operation is used to delete configuration from the AbnormalRequestsPerMin alert type. + operationId: deleteAlertConfig + parameters: + - $ref: '#/components/parameters/alertType' + - $ref: '#/components/parameters/configurationId' + responses: + 200: + description: | + OK. + The alert config is deleted successfully. + content: {} + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:pub_alert_manage + x-examples: + $ref: docs/examples/alerts/alerts_config.yaml#/delete + + ###################################################### + # The "Label Collection" resource API + ###################################################### + /labels: + get: + tags: + - Label Collection + summary: Get all Registered Labels + description: | + Get all registered Labels + responses: + 200: + description: | + OK. + Labels returned + content: + application/json: + schema: + $ref: '#/components/schemas/LabelList' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/labels"' + operationId: getLabels + + ###################################################### + # The "API Category Collection" resource API + ###################################################### + /api-categories: + get: + tags: + - API Category (Collection) + summary: Get all API categories + description: | + Get all API categories + responses: + 200: + description: | + OK. + Categories returned + content: + application/json: + schema: + $ref: '#/components/schemas/APICategoryList' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/api-categories"' + operationId: getAllAPICategories + + ###################################################### + # The "Scopes" resource APIs + ###################################################### + /scopes: + get: + tags: + - Scopes + summary: Get All Available Shared Scopes + description: | + This operation can be used to get all the available Shared Scopes. + operationId: getSharedScopes + parameters: + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + responses: + 200: + description: | + OK. + Shared Scope list is returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/ScopeList' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/scopes"' + + post: + tags: + - Scopes + summary: Add a New Shared Scope + description: | + This operation can be used to add a new Shared Scope. + operationId: addSharedScope + requestBody: + description: Scope object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/Scope' + required: true + responses: + 201: + description: | + Created. + Successful response with the newly created Scope object as an entity in the body. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Scope' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:shared_scope_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/scopes"' + + /scopes/{scopeId}: + get: + tags: + - Scopes + summary: Get a Shared Scope by Scope Id + description: | + This operation can be used to retrieve details of a Shared Scope by a given scope Id. + operationId: getSharedScope + parameters: + - $ref: '#/components/parameters/scopeId' + responses: + 200: + description: | + OK. + Requested Shared Scope is returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Scope' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901"' + + put: + tags: + - Scopes + summary: Update a Shared Scope + description: | + This operation can be used to update a Shared Scope by a given scope Id. + operationId: updateSharedScope + parameters: + - $ref: '#/components/parameters/scopeId' + requestBody: + description: Scope object that needs to be updated + content: + application/json: + schema: + $ref: '#/components/schemas/Scope' + required: true + responses: + 200: + description: | + OK. + Successful response with updated Scope object + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/Scope' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:shared_scope_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901"' + + delete: + tags: + - Scopes + summary: Delete a Shared Scope + description: | + This operation can be used to delete a Shared Scope proving the Id of the scope. + operationId: deleteSharedScope + parameters: + - $ref: '#/components/parameters/scopeId' + responses: + 200: + description: | + OK. + Resource successfully deleted. + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:shared_scope_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901"' + + head: + tags: + - Scopes + summary: Check Given Scope Name already Exists + description: | + Using this operation, user can check a given scope name exists or not. + operationId: validateScope + parameters: + - $ref: '#/components/parameters/scopeName' + responses: + 200: + description: OK. Requested scope name exists. + content: {} + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create + - apim:api_publish + x-code-samples: + - lang: Curl + source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/scopes/YXBpbTphcGlfdmlldw"' + + /scopes/{scopeId}/usage: + get: + tags: + - Scopes + summary: Get usages of a Shared Scope by Scope Id + description: | + This operation can be used to retrieve usages of a Shared Scope by a given scope Id. + operationId: getSharedScopeUsages + parameters: + - $ref: '#/components/parameters/scopeId' + responses: + 200: + description: | + OK. + Usages of the shared scope is returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/SharedScopeUsage' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901/usage"' + + ###################################################### + # The "Key Managers Collection" resource API + ###################################################### + /key-managers: + get: + tags: + - Key Managers (Collection) + summary: Get All Key Managers + description: | + Get all Key managers + responses: + 200: + description: | + OK. + Categories returned + content: + application/json: + schema: + $ref: '#/components/schemas/KeyManagerList' + security: + - OAuth2Security: + - apim:api_create + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/key-managers"' + operationId: getAllKeyManagers + + ###################################################### + # The "Deployments" resource APIs + ###################################################### + /deployments: + get: + tags: + - Deployments + summary: Retrieve Deployment Environments Details + description: | + This operation can be used to retrieve cloud clusters information defines in tenant-conf.json file. + + With that you can deploy an API to selected cloud environments. + operationId: deploymentsGet + responses: + 200: + description: | + OK. Successful response with the list of deployment environments information in the body. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentList' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/deployments"' + + /apis/{apiId}/deployments: + get: + tags: + - DeploymentStatus + summary: Retrieve Deployment Status Details + description: | + This operation can be used to retrieve the status of deployments in cloud clusters. + + With that you can get the status of the deployed APIs in cloud environments. + operationId: deploymentsGetStatus + parameters: + - $ref: '#/components/parameters/apiId' + responses: + 200: + description: | + OK. Successful response with the list of deployment environments information in the body. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentStatusList' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v2/apis/92bc1330-1848-4fe8-b992-c792186c212e/deployments/"' + + /apis/validate-asyncapi: + post: + tags: + - Validation + summary: Validate an AsyncAPI Specification description: - type: string - example: Sample calculator application - groupId: - type: string - example: "" + This operation can be used to validate and AsyncAPI Specification and retrieve a summary. Provide either 'url' + or 'file' to specify the definition. + operationId: validateAsyncAPISpecification + parameters: + - name: returnContent + in: query + description: + Specify whether to return the full content of the AsyncAPI specification in the response. This is only + applicable when using url based validation + schema: + type: boolean + default: false + requestBody: + content: + multipart/form-data: + schema: + properties: + url: + type: string + description: AsyncAPI definition url + file: + type: string + description: AsyncAPI definition as a file + format: binary + responses: + 200: + description: + OK. + API definition validation information is returned + headers: + Content-Type: + description: + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/AsyncAPISpecificationValidationResponse' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_create -#----------------------------------------------------- -# The Document List resource -#----------------------------------------------------- - DocumentList: - title: Document List - properties: - count: - type: integer - description: | - Number of Documents returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Document' + /apis/import-asyncapi: + post: + tags: + - APIs + summary: import an AsyncAPI Specification + description: + This operation can be used to create and API from the AsyncAPI Specification. Provide either 'url' or 'file' + to specify the definition. -#----------------------------------------------------- -# The Document resource -#----------------------------------------------------- - Document: - title: Document - required: + Specify additionalProperties with **at least** API's name, version, context and endpointConfig. + operationId: importAsyncAPISpecification + requestBody: + content: + multipart/form-data: + schema: + properties: + file: + type: string + description: Definition to upload as a file + format: binary + url: + type: string + description: Definition url + additionalProperties: + type: string + description: Additional attributes specified as a stringified JSON with API's schema + responses: + 201: + description: + Created. Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + headers: + Etag: + description: + Entity Tag of the respons resource. Used by caches, or in conditional requests (Will be supported in the future). + schema: + type: string + Location: + description: + The URL of the newly created resource. + schema: + type: string + Content-type: + description: + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/API' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_create + + /apis/{apiId}/asyncapi: + get: + tags: + - APIs + summary: Get AsyncAPI definition + description: | + This operation can be used to retrieve the AsyncAPI definition of an API. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-None-Match' + responses: + 200: + description: | + OK. + Requested AsyncAPI definition of the API is returned + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Willl= be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has beed modified the last time. + Used by caches, or in conditional request (Will be supported in future). + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + type: string + example: "" + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + content: { } + 404: + $ref: '#/components/responses/NotFound' + 406: + $ref: '#/components/responses/NotAcceptable' + security: + - OAuth2Security: + - apim:api_view + + put: + tags: + - APIs + summary: Update AsyncAPI definition + description: | + This operation can be used to update the AsyncAPI definition of an existing API. AsyncAPI definition to be updated is passed as a form data parameter 'apiDefinition'. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/If-Match' + requestBody: + content: + multipart/form-data: + schema: + properties: + apiDefinition: + type: string + description: AsyncAPI definition of the API + url: + type: string + description: AsyncAPI definition URL of the API + file: + type: string + description: AsyncAPI definition as a file + format: binary + responses: + 200: + description: | + OK. + Successful response with updated AsyncAPI definition + headers: + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Last-Modified: + description: | + Date and time the resource has beed modified the last time. + Use =d by caches, or in conditional requests (Will be supported in future). + schema: + type: string + Location: + description: | + The URL of the newly created resource. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + type: string + example: "" + 400: + $ref: '#/components/responses/BadRequest' + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' + security: + - OAuth2Security: + - apim:api_create + +components: + schemas: + Comment: + title: Comment + required: + - content + type: object + properties: + id: + type: string + readOnly: true + example: 943d3002-000c-42d3-a1b9-d6559f8a4d49 + content: + maxLength: 512 + type: string + example: This is a comment + createdTime: + type: string + readOnly: true + example : 2021-02-11-09:57:25 + createdBy: + type: string + readOnly: true + example: admin + updatedTime: + type: string + readOnly: true + example : 2021-02-12-19:57:25 + category: + type: string + default: general + parentCommentId: + type: string + example: 6f38aea2-f41e-4ac9-b3f2-a9493d00ba97 + entryPoint: + type: string + enum: [devPortal, publisher] + commenterInfo: + $ref: '#/components/schemas/CommenterInfo' + replies: + $ref: '#/components/schemas/CommentList' + CommentList: + title: Comments List + type: object + properties: + count: + type: integer + description: | + Number of Comments returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Comment' + pagination: + $ref: '#/components/schemas/Pagination' + CommenterInfo: + type: object + properties: + firstName: + type: string + example: John + lastName: + type: string + example: David + fullName: + type: string + example: John David + APIList: + title: API List + type: object + properties: + count: + type: integer + description: | + Number of APIs returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/APIInfo' + pagination: + $ref: '#/components/schemas/Pagination' + APIListExpanded: + title: API List + type: object + properties: + count: + type: integer + description: | + Number of APIs returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/API' + pagination: + $ref: '#/components/schemas/Pagination' + + APIInfo: + title: API Info object with basic API details. + type: object + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorAPI + description: + type: string + example: A calculator API that supports basic operations + context: + type: string + example: CalculatorAPI + version: + type: string + example: 1.0.0 + provider: + type: string + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + example: admin + type: + type: string + example: HTTP + lifeCycleStatus: + type: string + example: CREATED + workflowStatus: + type: string + example: APPROVED + hasThumbnail: + type: boolean + example: true + securityScheme: + type: array + items: + type: string + + Topic: + title: Topic object + required: - name - - type - - sourceType - - visibility - properties: - documentId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorDoc - type: - type: string - enum: - - HOWTO - - SAMPLES - - PUBLIC_FORUM - - SUPPORT_FORUM - - API_MESSAGE_FORMAT - - SWAGGER_DOC - - OTHER - example: HOWTO - summary: - type: string - example: "Summary of Calculator Documentation" - sourceType: - type: string - enum: - - INLINE - - URL - - FILE - example: INLINE - sourceUrl: - type: string - example: "" - otherTypeName: - type: string - example: "" - visibility: - type: string - enum: - - OWNER_ONLY - - PRIVATE - - API_LEVEL - example: API_LEVEL + - mode + - description + type: object + properties: + id: + type: string + description: id + readOnly: true + example: 1222344 + name: + maxLength: 50 + minLength: 1 + pattern: '(^[^~!@#;:%^*()+={}|\\<>"'',&$\s+]*$)' + type: string + example: PizzaShackAPI + mode: + maxLength: 32766 + type: string + example: This is a simple API for Pizza Shack online pizza delivery store. + description: + maxLength: 32766 + type: string + example: This is a simple API for Pizza Shack online pizza delivery store. + TopicList: + title: Topic List + type: object + properties: + count: + type: integer + description: | + Number of Topics returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Topic' + pagination: + $ref: '#/components/schemas/Pagination' + API: + title: API object + required: + - context + - name + - version + type: object + properties: + id: + type: string + description: | + UUID of the api registry artifact + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + name: + maxLength: 50 + minLength: 1 + pattern: '(^[^~!@#;:%^*()+={}|\\<>"'',&$\s+]*$)' + type: string + example: PizzaShackAPI + description: + maxLength: 32766 + type: string + example: This is a simple API for Pizza Shack online pizza delivery store. + context: + maxLength: 82 + minLength: 1 + type: string + example: pizza + version: + maxLength: 30 + minLength: 1 + type: string + pattern: '^[^~!@#;:%^*()+={}|\\<>"'',&/$]+$' + example: 1.0.0 + provider: + maxLength: 50 + type: string + description: | + If the provider value is not given user invoking the api will be used as the provider. + example: admin + lifeCycleStatus: + type: string + example: CREATED + x-otherScopes: + - apim:api_publish + wsdlInfo: + $ref: '#/components/schemas/WSDLInfo' + wsdlUrl: + type: string + readOnly: true + example: /apimgt/applicationdata/wsdls/admin--soap1.wsdl + testKey: + type: string + readOnly: true + example: 8swdwj9080edejhj + responseCachingEnabled: + type: boolean + example: true + cacheTimeout: + type: integer + example: 300 + destinationStatsEnabled: + type: string + example: Disabled + hasThumbnail: + type: boolean + example: false + isDefaultVersion: + type: boolean + example: false + isRevision: + type: boolean + example: false + revisionedApiId: + type: string + description: | + UUID of the api registry artifact + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + revisionId: + type: integer + example: 1 + enableSchemaValidation: + type: boolean + example: false + enableStore: + type: boolean + example: true + x-otherScopes: + - apim:api_publish + type: + type: string + description: The api creation type to be used. Accepted values are HTTP, + WS, SOAPTOREST, GRAPHQL, WEBSUB, SSE + example: HTTP + default: HTTP + enum: + - HTTP + - WS + - SOAPTOREST + - SOAP + - GRAPHQL + - WEBSUB + - SSE + transport: + type: array + description: | + Supported transports for the API (http and/or https). + example: + - http + - https + items: + type: string + tags: + type: array + example: + - pizza + - food + items: + type: string + x-otherScopes: + - apim:api_publish + policies: + type: array + example: + - Unlimited + items: + type: string + x-otherScopes: + - apim:api_publish + apiThrottlingPolicy: + type: string + description: The API level throttling policy selected for the particular + API + example: Unlimited + x-otherScopes: + - apim:api_publish + authorizationHeader: + type: string + description: | + Name of the Authorization header used for invoking the API. If it is not set, Authorization header name specified + in tenant or system level will be used. + example: Authorization + securityScheme: + type: array + description: | + Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If + it is not set OAuth2 will be set as the security for the current API. + example: + - oauth2 + items: + type: string + maxTps: + $ref: '#/components/schemas/APIMaxTps' + visibility: + type: string + description: The visibility level of the API. Accepts one of the following. + PUBLIC, PRIVATE, RESTRICTED. + example: PUBLIC + default: PUBLIC + enum: + - PUBLIC + - PRIVATE + - RESTRICTED + x-otherScopes: + - apim:api_publish + visibleRoles: + type: array + description: The user roles that are able to access the API in Developer Portal + example: [] + items: + type: string + x-otherScopes: + - apim:api_publish + visibleTenants: + type: array + example: [] + items: + type: string + endpointSecurity: + $ref: '#/components/schemas/APIEndpointSecurity' + gatewayEnvironments: + type: array + description: | + List of gateway environments the API is available + example: + - Production and Sandbox + items: + type: string + x-otherScopes: + - apim:api_publish + deploymentEnvironments: + type: array + description: | + List of selected deployment environments and clusters + items: + $ref: '#/components/schemas/DeploymentEnvironments' + x-otherScopes: + - apim:api_publish + labels: + type: array + description: | + Labels of micro-gateway environments attached to the API. + example: [] + items: + type: string + mediationPolicies: + type: array + example: + - name: json_to_xml_in_message + type: in + - name: xml_to_json_out_message + type: out + - name: json_fault + type: fault + items: + $ref: '#/components/schemas/MediationPolicy' + subscriptionAvailability: + type: string + description: The subscription availability. Accepts one of the following. + CURRENT_TENANT, ALL_TENANTS or SPECIFIC_TENANTS. + example: CURRENT_TENANT + default: CURRENT_TENANT + enum: + - CURRENT_TENANT + - ALL_TENANTS + - SPECIFIC_TENANTS + x-otherScopes: + - apim:api_publish + subscriptionAvailableTenants: + type: array + example: [] + items: + type: string + additionalProperties: + type: object + additionalProperties: + type: string + description: Map of custom properties of API + x-otherScopes: + - apim:api_publish + monetization: + $ref: '#/components/schemas/APIMonetizationInfo' + accessControl: + type: string + description: | + Is the API is restricted to certain set of publishers or creators or is it visible to all the + publishers and creators. If the accessControl restriction is none, this API can be modified by all the + publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, + based on the restriction. + default: NONE + enum: + - NONE + - RESTRICTED + accessControlRoles: + type: array + description: The user roles that are able to view/modify as API publisher + or creator. + example: [] + items: + type: string + businessInformation: + $ref: '#/components/schemas/APIBusinessInformation' + x-otherScopes: + - apim:api_publish + corsConfiguration: + $ref: '#/components/schemas/APICorsConfiguration' + websubSubscriptionConfiguration: + $ref: '#/components/schemas/WebsubSubscriptionConfiguration' + workflowStatus: + type: string + example: APPROVED + createdTime: + type: string + lastUpdatedTime: + type: string + x-otherScopes: + - apim:api_publish + endpointConfig: + type: object + properties: {} + description: | + Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. -#----------------------------------------------------- -# The Mediation List resource -#----------------------------------------------------- - mediationList: - title: Mediation List - properties: - count: - type: integer - description: | - Number of mediation sequences returned. - example: 1 - next: - type: string - description: | - Link to the next subset of sequences qualified. - Empty if no more sequences are to be returned. - example: "" - previous: - type: string - description: | - Link to the previous subset of sequences qualified. - Empty if current subset is the first subset returned. - example: "" - list: - type: array - items: - $ref: '#/definitions/MediationInfo' + `Simple REST Endpoint` + { + "endpoint_type": "http", + "sandbox_endpoints": { + "url": "https://localhost:9443/am/sample/pizzashack/v1/api/" + }, + "production_endpoints": { + "url": "https://localhost:9443/am/sample/pizzashack/v1/api/" + } + } -#----------------------------------------------------- -# The MediationInfo resource -#----------------------------------------------------- - MediationInfo: - title: MediationInfo - required: - - name - - type - - id - properties: - name: - type: string - example: json_fault.xml - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - type: - type: string - enum: - - in - - out - - fault - example: in -#----------------------------------------------------- -# The Mediation resource -#----------------------------------------------------- - Mediation: - title: Mediation - required: - - name - - type - - config - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: json_fault.xml - type: - type: string - enum: - - in - - out - - fault - example: in - config: - type: string - example: ' - - - - ' + `Loadbalanced Endpoint` -#----------------------------------------------------- -# The MediationInfo resource -#----------------------------------------------------- - Wsdl: - title: Wsdl + { + "endpoint_type": "load_balance", + "algoCombo": "org.apache.synapse.endpoints.algorithms.RoundRobin", + "sessionManagement": "", + "sandbox_endpoints": [ + { + "url": "https://localhost:9443/am/sample/pizzashack/v1/api/1" + }, + { + "endpoint_type": "http", + "template_not_supported": false, + "url": "https://localhost:9443/am/sample/pizzashack/v1/api/2" + } + ], + "production_endpoints": [ + { + "url": "https://localhost:9443/am/sample/pizzashack/v1/api/3" + }, + { + "endpoint_type": "http", + "template_not_supported": false, + "url": "https://localhost:9443/am/sample/pizzashack/v1/api/4" + } + ], + "sessionTimeOut": "", + "algoClassName": "org.apache.synapse.endpoints.algorithms.RoundRobin" + } + + `Failover Endpoint` + + { + "production_failovers":[ + { + "endpoint_type":"http", + "template_not_supported":false, + "url":"https://localhost:9443/am/sample/pizzashack/v1/api/1" + } + ], + "endpoint_type":"failover", + "sandbox_endpoints":{ + "url":"https://localhost:9443/am/sample/pizzashack/v1/api/2" + }, + "production_endpoints":{ + "url":"https://localhost:9443/am/sample/pizzashack/v1/api/3" + }, + "sandbox_failovers":[ + { + "endpoint_type":"http", + "template_not_supported":false, + "url":"https://localhost:9443/am/sample/pizzashack/v1/api/4" + } + ] + } + + `Default Endpoint` + + { + "endpoint_type":"default", + "sandbox_endpoints":{ + "url":"default" + }, + "production_endpoints":{ + "url":"default" + } + } + + `Endpoint from Endpoint Registry` + { + "endpoint_type": "Registry", + "endpoint_id": "{registry-name:entry-name:version}", + } + example: + endpoint_type: http + sandbox_endpoints: + url: https://localhost:9443/am/sample/pizzashack/v1/api/ + production_endpoints: + url: https://localhost:9443/am/sample/pizzashack/v1/api/ + endpointImplementationType: + type: string + example: INLINE + default: ENDPOINT + enum: + - INLINE + - ENDPOINT + scopes: + type: array + items: + $ref: '#/components/schemas/APIScope' + operations: + type: array + example: + - target: /order/{orderId} + verb: POST + authType: Application & Application User + throttlingPolicy: Unlimited + - target: /menu + verb: GET + authType: Application & Application User + throttlingPolicy: Unlimited + items: + $ref: '#/components/schemas/APIOperations' + threatProtectionPolicies: + type: object + properties: + list: + type: array + items: + type: object + properties: + policyId: + type: string + priority: + type: integer + categories: + type: array + description: | + API categories + items: + type: string + example: "" + x-otherScopes: + - apim:api_publish + keyManagers: + type: object + properties: {} + description: | + API Key Managers + readOnly: true + serviceInfo: + type: object + properties: + key: + type: string + example: PetStore-1.0.0 + name: + type: string + example: PetStore + version: + type: string + example: 1.0.0 + outdated: + type: boolean + example: false + x-scopes: + - apim:api_create + - apim:api_import_export + + #----------------------------------------------------- + # The API Revision resource + #----------------------------------------------------- + APIRevision: + title: API Info object with basic API details + properties: + displayName: + type: string + example: REVISION 1 + id: + type: string + example: c26b2b9b-4632-4ca4-b6f3-521c8863990c + description: + type: string + example: removed a post resource + createdTime: + type: string + format: date-time + apiInfo: + $ref: '#/components/schemas/APIRevisionAPIInfo' + deploymentInfo: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + + #----------------------------------------------------- + # The API Revision - API Info resource + #----------------------------------------------------- + APIRevisionAPIInfo: + title: API Info object with basic Revisioned API details + readOnly: true + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + + #----------------------------------------------------- + # The API Revision List resource + #----------------------------------------------------- + APIRevisionList: + title: API Revisions List + properties: + count: + type: integer + description: | + Number of API revisions returned + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/APIRevision' + #----------------------------------------------------- + # The API Revision Deployment List resource + #----------------------------------------------------- + APIRevisionDeploymentList: + title: API Revision to Deployment mapped object with basic API deployment details + properties: + list: + type: array + items: + $ref: '#/components/schemas/APIRevisionDeployment' + #----------------------------------------------------- + # The API Revision Deployment resource + #----------------------------------------------------- + APIRevisionDeployment: + title: APIRevisionDeployment Info object with basic API deployment details + properties: + revisionUuid: + type: string + example: c26b2b9b-4632-4ca4-b6f3-521c8863990c + name: + type: string + example: default + vhost: + maxLength: 255 + minLength: 1 + # hostname regex as per RFC 1123 (http://tools.ietf.org/html/rfc1123) and appended * + pattern: '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' + type: string + example: mg.wso2.com + displayOnDevportal: + type: boolean + example: true + deployedTime: + type: string + format: date-time + + AuditReport: + title: Resource for Audit Report + type: object + properties: + report: + type: string + description: | + The API Security Audit Report + grade: + type: string + description: | + The overall grade of the Security Audit + example: "27.95" + numErrors: + type: integer + description: | + The number of errors in the API Definition + example: 20 + externalApiId: + type: string + description: | + The External API ID + example: fd21f9f7-3674-49cf-8a83-dca401f635de + APIProductList: + title: API Product List + type: object + properties: + count: + type: integer + description: | + Number of API Products returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/APIProductInfo' + pagination: + $ref: '#/components/schemas/Pagination' + APIProductInfo: + title: API Info object with basic API details. + type: object + properties: + id: + type: string + description: | + UUID of the api product + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + description: Name of the API Product + example: PizzaShackAPIProduct + context: + type: string + example: pizzaproduct + description: + type: string + description: A brief description about the API + example: This is a simple API for Pizza Shack online pizza delivery store + provider: + type: string + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + example: admin + hasThumbnail: + type: boolean + example: true + state: + type: string + description: | + State of the API product. Only published api products are visible on the Developer Portal + enum: + - CREATED + - PUBLISHED + securityScheme: + type: array + description: | + Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If + it is not set OAuth2 will be set as the security for the current API. + example: + - oauth2 + items: + type: string + APIProduct: + title: API Product object required: - name + type: object + properties: + id: + type: string + description: | + UUID of the api product + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + name: + maxLength: 50 + minLength: 1 + type: string + description: Name of the API Product + example: PizzaShackAPIProduct + context: + maxLength: 60 + minLength: 1 + type: string + example: pizzaproduct + description: + type: string + description: A brief description about the API + example: This is a simple API for Pizza Shack online pizza delivery store + provider: + maxLength: 50 + type: string + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + example: admin + hasThumbnail: + type: boolean + example: false + state: + type: string + description: | + State of the API product. Only published api products are visible on the Developer Portal + enum: + - CREATED + - PUBLISHED + enableSchemaValidation: + type: boolean + example: false + enableStore: + type: boolean + example: true + testKey: + type: string + readOnly: true + example: 8swdwj9080edejhj + isRevision: + type: boolean + example: false + revisionedApiProductId: + type: string + description: | + UUID of the api product registry artifact + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + revisionId: + type: integer + example: 1 + responseCachingEnabled: + type: boolean + example: true + cacheTimeout: + type: integer + example: 300 + visibility: + type: string + description: The visibility level of the API. Accepts one of the following. + PUBLIC, PRIVATE, RESTRICTED. + example: PUBLIC + default: PUBLIC + enum: + - PUBLIC + - PRIVATE + - RESTRICTED + visibleRoles: + type: array + description: The user roles that are able to access the API + example: [] + items: + type: string + visibleTenants: + type: array + example: [] + items: + type: string + accessControl: + type: string + description: | + Defines whether the API Product is restricted to certain set of publishers or creators or is it visible to all the + publishers and creators. If the accessControl restriction is none, this API Product can be modified by all the + publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, + based on the restriction. + default: NONE + enum: + - NONE + - RESTRICTED + accessControlRoles: + type: array + description: The user roles that are able to view/modify as API Product + publisher or creator. + example: [] + items: + type: string + gatewayEnvironments: + type: array + description: | + List of gateway environments the API Product is available + example: + - Production and Sandbox + items: + type: string + apiType: + type: string + description: The API type to be used. Accepted values are API, APIPRODUCT + example: APIPRODUCT + enum: + - API + - APIPRODUCT + transport: + type: array + description: | + Supported transports for the API (http and/or https). + example: + - http + - https + items: + type: string + tags: + type: array + example: + - pizza + - food + items: + type: string + policies: + type: array + example: + - Unlimited + items: + type: string + apiThrottlingPolicy: + type: string + description: The API level throttling policy selected for the particular + API Product + example: Unlimited + authorizationHeader: + type: string + description: | + Name of the Authorization header used for invoking the API. If it is not set, Authorization header name specified + in tenant or system level will be used. + example: Authorization + securityScheme: + type: array + description: | + Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If + it is not set OAuth2 will be set as the security for the current API. + example: + - oauth2 + items: + type: string + subscriptionAvailability: + type: string + description: The subscription availability. Accepts one of the following. + CURRENT_TENANT, ALL_TENANTS or SPECIFIC_TENANTS. + example: CURRENT_TENANT + default: ALL_TENANTS + enum: + - CURRENT_TENANT + - ALL_TENANTS + - SPECIFIC_TENANTS + subscriptionAvailableTenants: + type: array + example: [] + items: + type: string + x-otherScopes: + - apim:api_publish + additionalProperties: + type: object + additionalProperties: + type: string + description: Map of custom properties of API + monetization: + $ref: '#/components/schemas/APIMonetizationInfo' + businessInformation: + $ref: '#/components/schemas/APIProductBusinessInformation' + corsConfiguration: + $ref: '#/components/schemas/APICorsConfiguration' + createdTime: + type: string + lastUpdatedTime: + type: string + apis: + type: array + description: | + APIs and resources in the API Product. + example: + - name: PizzaShackAPI + apiId: 01234567-0123-0123-0123-012345678901 + version: "1.0" + operations: + - target: /order/{orderId} + verb: POST + authType: Application & Application User + throttlingPolicy: Unlimited + - target: /menu + verb: GET + authType: Application & Application User + throttlingPolicy: Unlimited + items: + $ref: '#/components/schemas/ProductAPI' + scopes: + type: array + example: [] + items: + $ref: '#/components/schemas/APIScope' + categories: + type: array + description: | + API categories + example: [] + items: + type: string + ProductAPI: + title: ProductAPI + required: + - apiId + type: object properties: name: type: string - example: admin--calculatorAPI2.0.wsdl - wsdlDefinition: + example: PizzaShackAPI + apiId: type: string + example: 01234567-0123-0123-0123-012345678901 + version: + type: string + example: "1.0" + operations: + type: array + items: + $ref: '#/components/schemas/APIOperations' + ResourcePath: + title: ResourcePath + required: + - id + type: object + properties: + id: + type: integer + example: 1 + resourcePath: + type: string + example: /menu + httpVerb: + type: string + example: GET + ResourcePathList: + title: ResourcePath List + type: object + properties: + count: + type: integer + description: | + Number of API Resource Paths returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/ResourcePath' + pagination: + $ref: '#/components/schemas/Pagination' + APIProductOutdatedStatus: + title: APIProduct is outdated status + type: object + properties: + isOutdated: + type: boolean + description: | + Indicates if an API Product is outdated + example: true + APIProductBusinessInformation: + type: object + properties: + businessOwner: + maxLength: 120 + type: string + example: businessowner + businessOwnerEmail: + type: string + example: businessowner@wso2.com + technicalOwner: + maxLength: 120 + type: string + example: technicalowner + technicalOwnerEmail: + type: string + example: technicalowner@wso2.com + Claim: + title: Claim + type: object + properties: + name: + type: string + example: email + URI: + type: string + example: http://wso2.org/claims/emailaddress + value: + type: string + example: admin@wso2.com + SubscriberInfo: + title: SubscriberInfo + type: object + properties: + name: + type: string + example: admin + claims: + type: array + items: + $ref: '#/components/schemas/Claim' + Application: + title: Application + required: + - name + - throttlingTier + type: object + properties: + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorApp + subscriber: + type: string + example: admin + throttlingTier: + type: string + example: Unlimited + description: + type: string + example: Sample calculator application + groupId: + type: string + example: "" + ApplicationInfo: + title: Application info object with basic application details + type: object + properties: + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorApp + subscriber: + type: string + example: admin + description: + type: string + example: Sample calculator application + subscriptionCount: + type: integer + DocumentList: + title: Document List + type: object + properties: + count: + type: integer + description: | + Number of Documents returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Document' + pagination: + $ref: '#/components/schemas/Pagination' + Document: + title: Document + required: + - name + - sourceType + - type + - visibility + type: object + properties: + documentId: + type: string + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + name: + maxLength: 60 + minLength: 1 + type: string + example: PizzaShackDoc + type: + type: string + example: HOWTO + enum: + - HOWTO + - SAMPLES + - PUBLIC_FORUM + - SUPPORT_FORUM + - API_MESSAGE_FORMAT + - SWAGGER_DOC + - OTHER + summary: + maxLength: 32766 + minLength: 1 + type: string + example: Summary of PizzaShackAPI Documentation + sourceType: + type: string + example: INLINE + enum: + - INLINE + - MARKDOWN + - URL + - FILE + sourceUrl: + type: string + readOnly: true + example: "" + fileName: + type: string + readOnly: true + example: "" + inlineContent: + type: string + example: This is doc content. This can have many lines. + otherTypeName: + type: string + readOnly: true + example: "" + visibility: + type: string + example: API_LEVEL + enum: + - OWNER_ONLY + - PRIVATE + - API_LEVEL + createdTime: + type: string + readOnly: true + createdBy: + type: string + example: admin + lastUpdatedTime: + type: string + readOnly: true + lastUpdatedBy: + type: string + readOnly: true + example: admin + GraphQLSchema: + title: GraphQL Schema + required: + - name + type: object + properties: + name: + type: string + example: admin--HackerNewsAPI.graphql + schemaDefinition: + type: string + GraphQLQueryComplexityInfo: + title: GraphQL Query Complexity Info + type: object + properties: + list: + type: array + items: + $ref: '#/components/schemas/GraphQLCustomComplexityInfo' + GraphQLCustomComplexityInfo: + title: GraphQL Custom Complexity Info + required: + - complexityValue + - field + - type + type: object + properties: + type: + type: string + description: | + The type found within the schema of the API + example: Country + field: + type: string + description: | + The field which is found under the type within the schema of the API + example: name + complexityValue: + type: integer + description: | + The complexity value allocated for the associated field under the specified type + example: 1 + GraphQLSchemaTypeList: + title: List of types and corresponding fields of the GraphQL Schema + type: object + properties: + typeList: + type: array + items: + $ref: '#/components/schemas/GraphQLSchemaType' + GraphQLSchemaType: + title: Single type and corresponding fields found within the GraphQL Schema + type: object + properties: + type: + type: string + description: | + Type found within the GraphQL Schema + example: Country + fieldList: + type: array + description: | + Array of fields under current type + example: + - code + - name + items: + type: string + MediationList: + title: Mediation List + type: object + properties: + count: + type: integer + description: | + Number of mediation sequences returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/MediationInfo' + pagination: + $ref: '#/components/schemas/Pagination' + MediationInfo: + title: MediationInfo + required: + - id + - name + - type + type: object + properties: + name: + type: string + example: json_fault.xml + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + type: + type: string + example: in + enum: + - in + - out + - fault + Mediation: + title: Mediation + required: + - name + - type + type: object + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: json_fault.xml + type: + type: string + example: in + enum: + - in + - out + - fault + ThrottlingPolicyList: + title: Throttling policy list + type: object + properties: + count: + type: integer + description: | + Number of Tiers returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/ThrottlingPolicy' + pagination: + $ref: '#/components/schemas/Pagination' + ThrottlingPolicy: + title: Tier + required: + - name + - requestCount + - stopOnQuotaReach + - tierPlan + - unitTime + type: object + properties: + name: + type: string + example: Platinum + description: + type: string + example: Allows 50 request(s) per minute. + policyLevel: + type: string + example: api + enum: + - subscription + - api + displayName: + type: string + example: Platinum + attributes: + type: object + additionalProperties: + type: string + description: | + Custom attributes added to the policy policy + example: {} + requestCount: + type: integer + description: | + Maximum number of requests which can be sent within a provided unit time + format: int64 + example: 50 + dataUnit: + description: | + Unit of data allowed to be transfered. Allowed values are "KB", "MB" and "GB" + type: string + example: KB + unitTime: + type: integer + format: int64 + example: 60000 + timeUnit: + type: string + example: min + rateLimitCount: + type: integer + default: 0 + description: Burst control request count + example: 10 + rateLimitTimeUnit: + type: string + description: Burst control time unit + example: min + quotaPolicyType: + type: string + description: Default quota limit type + enum: + - REQUESTCOUNT + - BANDWIDTHVOLUME + example: REQUESTCOUNT + tierPlan: + type: string + description: | + This attribute declares whether this policy is available under commercial or free + example: FREE + enum: + - FREE + - COMMERCIAL + stopOnQuotaReach: + type: boolean + description: | + By making this attribute to false, you are capabale of sending requests + even if the request count exceeded within a unit time + example: true + monetizationProperties: + type: object + additionalProperties: + type: string + description: Properties of a tier plan which are related to monetization + example: {} + SubscriptionList: + title: Subscription List + type: object + properties: + count: + type: integer + description: | + Number of Subscriptions returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Subscription' + pagination: + $ref: '#/components/schemas/Pagination' + Subscription: + title: Subscription + required: + - applicationInfo + - subscriptionId + - subscriptionStatus + - throttlingPolicy + type: object + properties: + subscriptionId: + type: string + example: 01234567-0123-0123-0123-012345678901 + applicationInfo: + $ref: '#/components/schemas/ApplicationInfo' + throttlingPolicy: + type: string + example: Unlimited + subscriptionStatus: + type: string + example: BLOCKED + enum: + - BLOCKED + - PROD_ONLY_BLOCKED + - UNBLOCKED + - ON_HOLD + - REJECTED + - TIER_UPDATE_PENDING + APIMonetizationUsage: + title: API monetization usage object + type: object + properties: + properties: + type: object + additionalProperties: + type: string + description: Map of custom properties related to monetization usage + APIRevenue: + title: API revenue data object + type: object + properties: + properties: + type: object + additionalProperties: + type: string + description: Map of custom properties related to API revenue + MediationPolicy: + title: Mediation Policy + required: + - name + type: object + properties: + id: + type: string + example: 69ea3fa6-55c6-472e-896d-e449dd34a824 + name: + type: string + example: log_in_message + type: + type: string + example: in + shared: + type: boolean + example: true + Error: + title: Error object returned with 4XX HTTP Status + required: + - code + - message + type: object + properties: + code: + type: integer + format: int64 + message: + type: string + description: Error message. + description: + type: string + description: | + A detail description about the error message. + moreInfo: + type: string + description: | + Preferably an url with more details about the error. + error: + type: array + description: | + If there are more than one error list them out. + For example, list out validation errors by each field. + items: + $ref: '#/components/schemas/ErrorListItem' + ErrorListItem: + title: Description of individual errors that may have occurred during a request. + required: + - code + - message + type: object + properties: + code: + type: string + message: + type: string + description: | + Description about individual errors occurred + description: + type: string + description: | + A detail description about the error message. + Environment: + title: Environment + required: + - endpoints + - name + - serverUrl + - showInApiConsole + - type + type: object + properties: + name: + type: string + example: default + displayName: + type: string + example: Default + type: + type: string + example: hybrid + serverUrl: + type: string + example: https://localhost:9443/services/ + showInApiConsole: + type: boolean + example: true + endpoints: + $ref: '#/components/schemas/EnvironmentEndpoints' + vhosts: + type: array + items: + $ref: '#/components/schemas/VHost' + EnvironmentList: + title: Environment List + type: object + properties: + count: + type: integer + description: | + Number of Environments returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Environment' + EnvironmentEndpoints: + title: Environment Endpoints + type: object + properties: + http: + type: string + description: HTTP environment URL + example: http://localhost:8280 + https: + type: string + description: HTTPS environment URL + example: https://localhost:8243 + ws: + type: string + description: WS environment URL + example: http://localhost:9099 + wss: + type: string + description: WSS environment URL + example: https://localhost:8099 + VHost: + title: Virtual Host + type: object + properties: + host: + type: string + example: mg.wso2.com + httpContext: + type: string + example: pets + httpPort: + type: integer + example: 80 + httpsPort: + type: integer + example: 443 + wsPort: + type: integer + example: 9099 + wssPort: + type: integer + example: 8099 + FileInfo: + title: File Information including meta data + type: object + properties: + relativePath: + type: string + description: relative location of the file (excluding the base context and + host of the Publisher API) + example: apis/01234567-0123-0123-0123-012345678901/thumbnail + mediaType: + type: string + description: media-type of the file + example: image/jpeg + APIMaxTps: + type: object + properties: + production: + type: integer + format: int64 + example: 1000 + sandbox: + type: integer + format: int64 + example: 1000 + APIEndpointSecurity: + type: object + properties: + type: + type: string + description: Accepts one of the following, basic or digest. + example: BASIC + enum: + - BASIC + - DIGEST + username: + type: string + example: admin + password: + type: string + example: password + APIBusinessInformation: + type: object + properties: + businessOwner: + maxLength: 120 + type: string + example: businessowner + businessOwnerEmail: + type: string + example: businessowner@wso2.com + pattern: '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$' + technicalOwner: + maxLength: 120 + type: string + example: technicalowner + technicalOwnerEmail: + type: string + example: technicalowner@wso2.com + WebsubSubscriptionConfiguration: + type: object + properties: + secret: + type: string + description: Secret key to be used for subscription + signingAlgorithm: + type: string + description: The algorithm used for signing + signatureHeader: + type: string + description: The header uses to send the signature -# The Tier List resource -#----------------------------------------------------- - TierList: - title: Tier List - properties: - count: + APICorsConfiguration: + type: object + properties: + corsConfigurationEnabled: + type: boolean + default: false + accessControlAllowOrigins: + type: array + items: + type: string + accessControlAllowCredentials: + type: boolean + default: false + accessControlAllowHeaders: + type: array + items: + type: string + accessControlAllowMethods: + type: array + items: + type: string + description: | + CORS configuration for the API + Endpoint: + title: Endpoints + type: object + properties: + id: + type: string + description: | + UUID of the Endpoint entry + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + description: | + name of the Endpoint entry + example: Endpoint 1 + endpointConfig: + type: object + properties: + endpointType: + type: string + example: FAIL_OVER + enum: + - SINGLE + - LOAD_BALANCED + - FAIL_OVER + list: + type: array + items: + $ref: '#/components/schemas/EndpointConfig' + endpointSecurity: + type: object + properties: + enabled: + type: boolean + example: false + type: + type: string + example: basic + username: + type: string + example: basic + password: + type: string + example: basic + maxTps: + type: integer + description: Endpoint max tps + format: int64 + example: 1000 + type: + type: string + example: http + EndpointConfig: + title: Endpoint Configuration + type: object + properties: + url: + type: string + description: | + Service url of the endpoint + example: http://localhost:8280 + timeout: + type: string + description: | + Time out of the endpoint + example: "1000" + attributes: + type: array + items: + type: object + properties: + name: + type: string + example: Suspension time + value: + type: string + example: 2s + EndpointList: + title: Endpoint List + type: object + properties: + count: + type: integer + description: | + Number of Endpoints returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Endpoint' + Scope: + title: Scope + required: + - name + type: object + properties: + id: + type: string + description: | + UUID of the Scope. Valid only for shared scopes. + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + name: + maxLength: 255 + minLength: 1 + type: string + description: | + name of Scope + example: apim:api_view + displayName: + maxLength: 255 + type: string + description: | + display name of Scope + example: api_view + description: + maxLength: 512 + type: string + description: | + description of Scope + example: This Scope can used to view Apis + bindings: + type: array + description: | + role bindings list of the Scope + example: + - admin + - Internal/creator + - Internal/publisher + items: + type: string + usageCount: + type: integer + description: | + usage count of Scope + readOnly: true + example: 3 + SharedScopeUsage: + title: SharedScopeUsage + required: + - id + - name + type: object + properties: + id: + type: string + description: | + UUID of the Scope. Valid only for shared scopes. + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + description: | + name of Scope + example: apim:api_view + usedApiList: + type: array + description: | + API list which have used the shared scope + items: + $ref: '#/components/schemas/SharedScopeUsedAPIInfo' + SharedScopeUsedAPIInfo: + title: API object using shared scope + required: + - context + - name + - version + type: object + properties: + name: + type: string + example: CalculatorAPI + context: + type: string + example: CalculatorAPI + version: + type: string + example: 1.0.0 + provider: + type: string + description: | + If the provider value is not given user invoking the api will be used as the provider. + example: admin + usedResourceList: + type: array + description: | + Resource list which have used the shared scope within this API + items: + $ref: '#/components/schemas/SharedScopeUsedAPIResourceInfo' + SharedScopeUsedAPIResourceInfo: + title: API resource object using shared scope + type: object + properties: + target: + type: string + example: /add + verb: + type: string + example: POST + APIScope: + title: APIScope + required: + - scope + type: object + properties: + scope: + $ref: '#/components/schemas/Scope' + shared: + type: boolean + description: | + States whether scope is shared. This will not be honored when updating/adding scopes to APIs or when + adding/updating Shared Scopes. + example: true + APIOperations: + title: Operation + type: object + properties: + id: + type: string + example: postapiresource + target: + type: string + example: /order/{orderId} + verb: + type: string + example: POST + authType: + type: string + example: Application & Application User + default: Any + throttlingPolicy: + type: string + example: Unlimited + scopes: + type: array + example: [] + items: + type: string + usedProductIds: + type: array + example: [] + items: + type: string + amznResourceName: + type: string + example: "" + amznResourceTimeout: + type: integer + payloadSchema: + type: string + example: "" + uriMapping: + type: string + example: "" + ScopeList: + title: Scope List + type: object + properties: + count: + type: integer + description: | + Number of Scopes returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Scope' + pagination: + $ref: '#/components/schemas/Pagination' + ExternalStore: + title: External Store + type: object + properties: + id: + type: string + description: | + The external store identifier, which is a unique value. + example: Store123# + displayName: + type: string + description: | + The name of the external API Store that is displayed in the Publisher UI. + example: UKStore + type: + type: string + description: | + The type of the Store. This can be a WSO2-specific API Store or an external one. + example: wso2 + endpoint: + type: string + description: | + The endpoint URL of the external store + example: http://localhost:9764/store + APIExternalStore: + title: API External Store + type: object + properties: + id: + type: string + description: | + The external store identifier, which is a unique value. + example: Store123# + lastUpdatedTime: + type: string + description: | + The recent timestamp which a given API is updated in the external store. + example: 2019-09-09T13:57:16.229 + APIExternalStoreList: + title: API External Store List + type: object + properties: + count: + type: integer + description: | + Number of external stores returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/APIExternalStore' + ExternalStoreList: + title: External Store List + type: object + properties: + count: + type: integer + description: | + Number of external stores returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/ExternalStore' + Certificates: + title: Certificates + type: object + properties: + count: + type: integer + example: 1 + certificates: + type: array + items: + $ref: '#/components/schemas/CertMetadata' + pagination: + $ref: '#/components/schemas/Pagination' + description: Representation of a list of certificates + CertMetadata: + title: Certificate + type: object + properties: + alias: + type: string + example: wso2carbon + endpoint: + type: string + example: www.abc.com + description: Representation of the details of a certificate + CertificateInfo: + title: Certificate information + type: object + properties: + status: + type: string + example: Active + validity: + $ref: '#/components/schemas/CertificateValidity' + version: + type: string + example: V3 + subject: + type: string + example: CN=wso2.com, OU=wso2, O=wso2, L=Colombo, ST=Western, C=LK + CertificateValidity: + title: Certificate Valid period + type: object + properties: + from: + type: string + example: 12-12-2017 + to: + type: string + example: 01-01-2019 + ClientCertificates: + title: Client Certificates + type: object + properties: + count: + type: integer + example: 1 + certificates: + type: array + items: + $ref: '#/components/schemas/ClientCertMetadata' + pagination: + $ref: '#/components/schemas/Pagination' + description: Representation of a list of client certificates + ClientCertMetadata: + title: Client certificate meta data + type: object + properties: + alias: + type: string + example: wso2carbon + apiId: + type: string + example: 64eca60b-2e55-4c38-8603-e9e6bad7d809 + tier: + type: string + example: Gold + description: Meta data of certificate + Label: + title: Label + required: + - name + type: object + properties: + name: + type: string + example: marketing_store + description: + type: string + example: Public microgateway for marketing + access_urls: + type: array + example: https://localhost:9095 + items: + type: string + LabelList: + title: Label List + type: object + properties: + count: + type: integer + description: | + Number of Labels returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Label' + pagination: + $ref: '#/components/schemas/Pagination' + LifecycleState: + title: Lifecycle State + type: object + properties: + state: + type: string + example: Created + checkItems: + type: array + items: + type: object + properties: + name: + type: string + example: Deprecate old versions after publishing the API + value: + type: boolean + example: false + requiredStates: + type: array + example: [] + items: + type: string + availableTransitions: + type: array + items: + type: object + properties: + event: + type: string + example: Publish + targetState: + type: string + example: Published + LifecycleHistory: + title: Lifecycle history item list + type: object + properties: + count: + type: integer + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/LifecycleHistoryItem' + LifecycleHistoryItem: + title: Lifecycle history item + type: object + properties: + previousState: + type: string + example: Created + postState: + type: string + example: Published + user: + type: string + example: admin + updatedTime: + type: string + format: dateTime + example: 2019-02-31T23:59:60Z + WorkflowResponse: + title: workflow Response + required: + - workflowStatus + type: object + properties: + workflowStatus: + type: string + description: | + This attribute declares whether this workflow task is approved or rejected. + example: APPROVED + enum: + - CREATED + - APPROVED + - REJECTED + - REGISTERED + jsonPayload: + type: string + description: | + Attributes that returned after the workflow execution + example: null + lifecycleState: + $ref: '#/components/schemas/LifecycleState' + OpenAPIDefinitionValidationResponse: + title: OpenAPI Definition Validation Response + required: + - isValid + type: object + properties: + isValid: + type: boolean + description: | + This attribute declares whether this definition is valid or not. + example: true + content: + type: string + description: | + OpenAPI definition content. + info: + type: object + properties: + name: + type: string + example: PetStore + version: + type: string + example: 1.0.0 + context: + type: string + example: /petstore + description: + type: string + example: A sample API that uses a petstore as an example to demonstrate + swagger-2.0 specification + openAPIVersion: + type: string + example: 3.0.0 + endpoints: + type: array + description: | + contains host/servers specified in the OpenAPI file/URL + items: + type: string + example: https://localhost:9443/am/sample/pizzashack/v1/api/ + description: | + API definition information + errors: + type: array + description: | + If there are more than one error list them out. + For example, list out validation errors by each field. + items: + $ref: '#/components/schemas/ErrorListItem' + WSDLValidationResponse: + title: WSDL Definition Validation Response + required: + - isValid + type: object + properties: + isValid: + type: boolean + description: | + This attribute declares whether this definition is valid or not. + example: true + errors: + type: array + description: | + If there are more than one error list them out. + For example, list out validation errors by each field. + items: + $ref: '#/components/schemas/ErrorListItem' + wsdlInfo: + type: object + properties: + version: + type: string + description: | + WSDL version + example: "1.1" + endpoints: + type: array + description: | + A list of endpoints the service exposes + items: + type: object + properties: + name: + type: string + description: Name of the endpoint + example: StockQuoteSoap + location: + type: string + description: Endpoint URL + example: http://www.webservicex.net/stockquote.asmx + description: Summary of the WSDL including the basic information + GraphQLValidationResponse: + title: GraphQL API definition validation Response + required: + - errorMessage + - isValid + type: object + properties: + isValid: + type: boolean + description: | + This attribute declares whether this definition is valid or not. + example: true + errorMessage: + type: string + description: | + This attribute declares the validation error message + graphQLInfo: + type: object + properties: + operations: + type: array + items: + $ref: '#/components/schemas/APIOperations' + graphQLSchema: + $ref: '#/components/schemas/GraphQLSchema' + description: Summary of the GraphQL including the basic information + ApiEndpointValidationResponse: + title: API Endpoint url validation response + required: + - statusCode + - statusMessage + type: object + properties: + statusCode: + type: integer + description: HTTP status code + example: 200 + statusMessage: + type: string + description: string + example: OK + error: + type: string + description: | + If an error occurs, the error message will be set to this property. + If not, this will remain null. + example: null + ThreatProtectionPolicyList: + title: Threat Protection Policy List + type: object + properties: + list: + type: array + items: + $ref: '#/components/schemas/ThreatProtectionPolicy' + ThreatProtectionPolicy: + title: Threat Protection Policy Schema + required: + - name + - policy + - type + type: object + properties: + uuid: + type: string + description: Policy ID + name: + type: string + description: Name of the policy + type: + type: string + description: Type of the policy + policy: + type: string + description: policy as a json string + SearchResultList: + title: Unified Search Result List + type: object + properties: + count: + type: integer + description: | + Number of results returned. + example: 1 + list: + type: array + items: + type: object + pagination: + $ref: '#/components/schemas/Pagination' + SearchResult: + title: Search Result + required: + - name + type: object + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: TestAPI + type: + type: string + example: API + enum: + - DOC + - API + - APIProduct + transportType: + type: string + description: Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL + discriminator: + propertyName: name + APISearchResult: + title: API Result + allOf: + - $ref: '#/components/schemas/SearchResult' + - type: object + properties: + description: + type: string + description: A brief description about the API + example: A calculator API that supports basic operations + context: + type: string + description: A string that represents the context of the user's request + example: CalculatorAPI + version: + type: string + description: The version of the API + example: 1.0.0 + provider: + type: string + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + example: admin + status: + type: string + description: This describes in which status of the lifecycle the API is + example: CREATED + thumbnailUri: + type: string + example: /apis/01234567-0123-0123-0123-012345678901/thumbnail + APIProductSearchResult: + title: API Result + allOf: + - $ref: '#/components/schemas/SearchResult' + - type: object + properties: + description: + type: string + description: A brief description about the API + example: A calculator API that supports basic operations + context: + type: string + description: A string that represents the context of the user's request + example: CalculatorAPI + version: + type: string + description: The version of the API Product + example: 1.0.0 + provider: + type: string + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + example: admin + status: + type: string + description: This describes in which status of the lifecycle the APIPRODUCT + is + example: PUBLISHED + thumbnailUri: + type: string + example: /apis/01234567-0123-0123-0123-012345678901/thumbnail + APIMonetizationInfo: + title: API monetization object + required: + - enabled + type: object + properties: + enabled: + type: boolean + description: Flag to indicate the monetization status + example: true + properties: + type: object + additionalProperties: + type: string + description: Map of custom properties related to monetization + DocumentSearchResult: + title: Document Result + allOf: + - $ref: '#/components/schemas/SearchResult' + - type: object + properties: + docType: + type: string + example: HOWTO + enum: + - HOWTO + - SAMPLES + - PUBLIC_FORUM + - SUPPORT_FORUM + - API_MESSAGE_FORMAT + - SWAGGER_DOC + - OTHER + summary: + type: string + example: Summary of Calculator Documentation + sourceType: + type: string + example: INLINE + enum: + - INLINE + - URL + - FILE + sourceUrl: + type: string + example: "" + otherTypeName: + type: string + example: "" + visibility: + type: string + example: API_LEVEL + enum: + - OWNER_ONLY + - PRIVATE + - API_LEVEL + apiName: + type: string + description: The name of the associated API + example: TestAPI + apiVersion: + type: string + description: The version of the associated API + example: 1.0.0 + apiProvider: + type: string + example: admin + apiUUID: + type: string + associatedType: + type: string + MockResponsePayloadList: + title: Mock Response Payload list + type: object + properties: + list: + type: array + items: + $ref: '#/components/schemas/MockResponsePayloadInfo' + MockResponsePayloadInfo: + title: Mock Response Payload info object + type: object + properties: + path: + type: string + description: path of the resource + example: /menu + content: + type: string + description: new modified code + example: "var accept = \"\\\"\"+mc.getProperty('AcceptHeader')+\"\\\"\"\ + ;\nvar responseCode = mc.getProperty('query.param.responseCode');\nvar\ + \ responseCodeStr = \"\\\"\"+responseCode+\"\\\"\";\nvar responses = [];\n\ + \nif (!responses[200]) {\n responses [200] = [];\n}\nresponses[200][\"\ + application/json\"] = \n[ {\n \"price\" : \"string\",\n \"description\"\ + \ : \"string\",\n \"name\" : \"string\",\n \"image\" : \"string\"\n\ + } ]\n\n/*if (!responses[304]) {\n responses[304] = [];\n}\nresponses[304][\"\ + application/(json or xml)\"] = {}/<>*/\n\nif (!responses[406]) {\n responses\ + \ [406] = [];\n}\nresponses[406][\"application/json\"] = \n{\n \"message\"\ + \ : \"string\",\n \"error\" : [ {\n \"message\" : \"string\",\n \ + \ \"code\" : 0\n } ],\n \"description\" : \"string\",\n \"code\" :\ + \ 0,\n \"moreInfo\" : \"string\"\n}\n\nresponses[501] = [];\nresponses[501][\"\ + application/json\"] = {\n\"code\" : 501,\n\"description\" : \"Not Implemented\"\ + }\nresponses[501][\"application/xml\"] = 501Not\ + \ Implemented;\n\nif (!responses[responseCode])\ + \ {\n responseCode = 501;\n}\n\nif (responseCode == null) {\n responseCode\ + \ = 200;\n responseCodeStr = \"200\";\n}\n\nif (accept == null || !responses[responseCode][accept])\ + \ {\n accept = \"application/json\";\n}\n\nif (accept === \"application/json\"\ + ) {\n mc.setProperty('CONTENT_TYPE', 'application/json');\n mc.setProperty('HTTP_SC',\ + \ responseCodeStr);\n mc.setPayloadJSON(responses[responseCode][\"application/json\"\ + ]);\n} else if (accept === \"application/xml\") {\n mc.setProperty('CONTENT_TYPE',\ + \ 'application/xml');\n mc.setProperty('HTTP_SC', responseCodeStr);\n\ + \ mc.setPayloadXML(responses[responseCode][\"application/xml\"]);\n}" + verb: + type: string + example: POST + ResourcePolicyList: + title: Resource policy List + type: object + properties: + list: + type: array + items: + $ref: '#/components/schemas/ResourcePolicyInfo' + count: + type: integer + description: | + Number of policy resources returned. + example: 1 + ResourcePolicyInfo: + title: Resource policy Info object with conversion policy resource details. + type: object + properties: + id: + type: string + description: | + UUID of the resource policy registry artifact + readOnly: true + example: 01234567-0123-0123-0123-012345678901 + httpVerb: + type: string + description: HTTP verb used for the resource path + example: get + resourcePath: + type: string + description: A string that represents the resource path of the api for the + related resource policy + example: checkPhoneNumber + content: + type: string + description: The resource policy content + example:
+ Settings: + title: SettingsDTO + type: object + properties: + devportalUrl: + type: string + description: The Developer Portal URL + example: https://localhost:9443/devportal + environment: + type: array + items: + $ref: '#/components/schemas/Environment' + scopes: + type: array + example: + - apim:api_create + - apim:api_publish + items: + type: string + monetizationAttributes: + type: array + example: [] + items: + $ref: '#/components/schemas/MonetizationAttribute' + securityAuditProperties: + type: object + properties: {} + externalStoresEnabled: + type: boolean + description: | + Is External Stores configuration enabled + example: true + docVisibilityEnabled: + type: boolean + description: | + Is Document Visibility configuration enabled + example: false + crossTenantSubscriptionEnabled: + type: boolean + description: | + Is Cross Tenant Subscriptions Enabled + example: false + default: false + deployments: + type: array + items: + $ref: '#/components/schemas/Deployments' + SecurityAuditAttribute: + title: SecurityAuditAttributeDTO + type: object + properties: + isGlobal: + type: boolean + example: false + overrideGlobal: + type: boolean + example: false + apiToken: + type: string + example: b1267ytf-b7gc-4aee-924d-ece81241efec + collectionId: + type: string + example: 456ef957-5a79-449f-83y3-9027945d3c60 + baseUrl: + type: string + WSDLInfo: + title: WSDL information of the API. This is only available if the API is a SOAP + API. + type: object + properties: + type: + type: string + description: Indicates whether the WSDL is a single WSDL or an archive in + ZIP format + enum: + - WSDL + - ZIP + Pagination: + title: Pagination + type: object + properties: + offset: + type: integer + example: 0 + limit: + type: integer + example: 1 + total: + type: integer + example: 10 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + MonetizationAttribute: + title: Monetization attribute object + type: object + properties: + required: + type: boolean + description: | + Is attribute required + example: true + name: + type: string + description: | + Name of the attribute + displayName: + type: string + description: | + Display name of the attribute + description: + type: string + description: | + Description of the attribute + hidden: + type: boolean + description: | + Is attribute hidden + default: + type: string + description: | + Default value of the attribute + Tenant: + title: Tenant + type: object + properties: + domain: + type: string + description: tenant domain + example: wso2.com + status: + type: string + description: current status of the tenant active/inactive + example: active + TenantList: + title: Tenant list + type: object + properties: + count: + type: integer + description: | + Number of tenants returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Tenant' + pagination: + $ref: '#/components/schemas/Pagination' + AlertTypesList: + title: Alert Types List + type: object + properties: + count: + type: integer + description: The number of alerts + example: 3 + alerts: + type: array + items: + $ref: '#/components/schemas/AlertType' + AlertType: + title: Alert Type + type: object + properties: + id: + type: integer + description: The alert Id + example: 1 + name: + type: string + description: The name of the alert. + example: AbnormalRequestTime + requireConfiguration: + type: boolean + description: Whether the alert type require additional configurations. + example: true + Alert: + title: Alert + type: object + properties: + id: + type: integer + description: The alert Id + example: 1 + name: + type: string + description: The name of the alert. + example: AbnormalRequestsPerMin + configuration: + type: array + items: + $ref: '#/components/schemas/AlertConfig' + AlertsInfo: + title: Alerts Info + type: object + properties: + alerts: + type: array + items: + $ref: '#/components/schemas/Alert' + emailList: + type: array + items: + type: string + AlertsInfoResponse: + title: Alerts Info Response + type: object + properties: + alerts: + type: array + items: + $ref: '#/components/schemas/Alert' + emailList: + type: array + items: + type: string + failedConfigurations: + type: array + items: + $ref: '#/components/schemas/AlertConfig' + AlertConfigList: + title: Alert Configuration List + type: object + properties: + count: + type: integer + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/AlertConfig' + AlertConfig: + title: Alert Configuration + type: object + properties: + configurationId: + type: string + description: The alert config subscription id. + example: UGl6emFTaGFja0FQSSsxLjAuMCtEZWZhdWx0QXBwbGljYXRpb24K + configuration: + type: object + additionalProperties: + type: string + description: The config parameters. + example: + apiName: PizzaShackAPI + apiVersion: 1.0.0 + applicationName: DefaultApplication + requestConunt: "12" + AlertConfigInfo: + title: Alert Configuration Info + type: object + additionalProperties: + type: string + description: The config parameters. + example: + apiName: PizzaShackAPI + apiVersion: 1.0.0 + applicationName: DefaultApplication + requestConunt: "12" + APICategory: + title: API Category + required: + - name + type: object + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: Finance + description: + type: string + example: Finance related APIs + APICategoryList: + title: API Category List + type: object + properties: + count: + type: integer + description: | + Number of API categories returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/APICategory' + KeyManagerInfo: + title: Key Manager Info + required: + - name + - type + type: object + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: WSO2 IS + displayName: + type: string + description: | + display name of Keymanager + example: Keymanager1 + type: + type: string + example: IS + description: + type: string + example: This is a key manager for Developers + enabled: + type: boolean + example: true + additionalProperties: + type: array + items: + type: object + properties: {} + KeyManagerList: + title: Key Manager List + type: object + properties: + count: + type: integer + description: | + Number of Key managers returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/KeyManagerInfo' + DeploymentList: + title: Deployment List + type: object + properties: + count: + type: integer + description: | + Number of deployment clusters returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/Deployments' + Deployments: + title: Deployments + required: + - clusters + - name + type: object + properties: + name: + type: string + example: Kubernetes + clusters: + type: array + items: + $ref: '#/components/schemas/DeploymentClusterInfo' + DeploymentClusterInfo: + title: DeploymentClusterInfo + required: + - accessURL + - clusterName + - displayName + - properties + type: object + properties: + clusterName: + type: string + example: minikube + accessURL: + type: string + example: https://api.com + displayName: + type: string + example: kubernetes-minikube + properties: + type: object + additionalProperties: + type: string + DeploymentStatusList: + title: DeploymentStatus List + type: object + properties: + count: + type: integer + description: | + Status of the deployments returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/DeploymentStatus' + DeploymentStatus: + title: DeploymentStatus + required: + - clusters + - type + type: object + properties: + type: + type: string + example: Kubernetes + clusters: + type: array + items: + $ref: '#/components/schemas/DeploymentClusterStatus' + DeploymentClusterStatus: + title: DeploymentClusterStatus + required: + - clusterName + - healthStatus + - podsRunning + type: object + properties: + clusterName: + type: string + example: Minikube + podsRunning: + type: integer + healthStatus: + type: array + items: + $ref: '#/components/schemas/PodStatus' + DeploymentEnvironments: + title: DeploymentEnvironments + required: + - clusterName + - type + type: object + properties: + type: + type: string + example: Kubernetes + clusterName: + type: array + example: + - minikube + items: + type: string + PodStatus: + title: PodStatus + required: + - name + - ready + - status + type: object + properties: + name: + type: string + example: petStore-677bb7cc65-shb2f + ready: + type: string + example: 1/1 + status: + type: string + example: running + creationTimestamp: + type: string + example: 2020-05-12T06:12:00Z + AsyncAPISpecificationValidationResponse: + title: AsyncAPI Specification Validation Response + required: + - isValid + type: object + properties: + isValid: + type: boolean + description: + This attribute declares whether this definition is valid or not. + example: true + content: + type: string + description: + AsyncAPI specification content + info: + type: object + properties: + name: + type: string + example: Streetlights + version: + type: string + example: 1.0.0 + context: + type: string + example: /streetlights + description: + type: string + example: A sample API that uses a streetlights as an example to demonstrate AsyncAPI specifications + asyncAPIVersion: + type: string + example: 2.0 + endpoints: + type: array + description: + contains host/servers specified in the AsyncAPI file/URL + items: + type: string + example: "https://localhost:9443/am/sample/pizzashack/v1/api/" + description: + API definition information + errors: + type: array + description: + If there are more than one error list them out. + For example, list out validation error by each field. + items: + $ref: '#/components/schemas/ErrorListItem' + responses: + BadRequest: + description: Bad Request. Invalid request or validation error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + moreInfo: "" + error: [] + Conflict: + description: Conflict. Specified resource already exists. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 409 + message: Conflict + description: Specified resource already exists + moreInfo: "" + error: [] + Forbidden: + description: Forbidden. The request must be conditional but no condition has + been specified. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 403 + message: Forbidden + description: The request must be conditional but no condition has been + specified + moreInfo: "" + error: [] + InternalServerError: + description: Internal Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 500 + message: Internal Server Error + description: The server encountered an internal error. Please contact + administrator. + moreInfo: "" + error: [] + NotAcceptable: + description: Not Acceptable. The requested media type is not supported. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 406 + message: Not Acceptable + description: The requested media type is not supported + moreInfo: "" + error: [] + NotFound: + description: Not Found. The specified resource does not exist. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: "" + error: [] + PreconditionFailed: + description: Precondition Failed. The request has not been performed because + one of the preconditions is not met. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 412 + message: Precondition Failed + description: The request has not been performed because one of the preconditions + is not met + moreInfo: "" + error: [] + Unauthorized: + description: Unauthorized. The user is not authorized. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 401 + message: Unauthorized + description: The user is not authorized + moreInfo: "" + error: [] + UnsupportedMediaType: + description: Unsupported Media Type. The entity of the request was not in a + supported format. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 415 + message: Unsupported media type + description: The entity of the request was not in a supported format + moreInfo: "" + error: [] + parameters: + replyLimit: + name: replyLimit + in: query + description: | + Maximum size of replies array to return. + schema: type: integer - description: | - Number of Tiers returned. - example: 1 - next: + default: 25 + replyOffset: + name: replyOffset + in: query + description: | + Starting point within the complete list of replies. + schema: + type: integer + default: 0 + commentId: + name: commentId + in: path + description: | + Comment Id + required: true + schema: type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/tiers/api?limit=1&offset=2" - previous: + parentCommentID: + name: replyTo + in: query + description: | + ID of the perent comment. + schema: + type: string + includeCommenterInfo: + name: includeCommenterInfo + in: query + description: | + Whether we need to display commentor details. + schema: + type: boolean + default : false + apiId: + name: apiId + in: path + description: | + **API ID** consisting of the **UUID** of the API. + required: true + schema: + type: string + endpointId: + name: endpointId + in: path + description: | + **Endpoint ID** consisting of the **UUID** of the Endpoint**. + required: true + schema: + type: string + apiId-Q: + name: apiId + in: query + description: | + **API ID** consisting of the **UUID** of the API. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. + Should be formatted as **provider-name-version**. + required: true + schema: + type: string + apiId-Q-Opt: + name: apiId + in: query + description: | + **API ID** consisting of the **UUID** of the API. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. + Should be formatted as **provider-name-version**. + schema: + type: string + labelType-Q: + name: labelType + in: query + description: | + **API ID** consisting of the **UUID** of the API. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. + Should be formatted as **provider-name-version**. + schema: + type: string + name: + name: name + in: path + description: | + Name of the API + required: true + schema: + type: string + version: + name: version + in: path + description: | + Version of the API + required: true + schema: + type: string + apiName-Q: + name: name + in: query + description: | + Name of the API + schema: + type: string + apiVersion-Q: + name: version + in: query + description: | + Version of the API + schema: + type: string + apiProvider-Q: + name: providerName + in: query + description: | + Provider name of the API + schema: + type: string + documentId: + name: documentId + in: path + description: | + Document Identifier + required: true + schema: + type: string + applicationId: + name: applicationId + in: path + description: | + **Application Identifier** consisting of the UUID of the Application. + required: true + schema: + type: string + subscriptionId: + name: subscriptionId + in: path + description: | + Subscription Id + required: true + schema: + type: string + mediationPolicyId: + name: mediationPolicyId + in: path + description: | + Mediation policy Id + required: true + schema: + type: string + resourcePolicyId: + name: resourcePolicyId + in: path + description: | + registry resource Id + required: true + schema: + type: string + subscriptionId-Q: + name: subscriptionId + in: query + description: | + Subscription Id + required: true + schema: type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/tiers/api?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Tier' -#----------------------------------------------------- -# The Tier resource -#----------------------------------------------------- - Tier: - title: Tier - required: - - name - - tierPlan - - requestCount - - unitTime - - stopOnQuotaReach - properties: - name: + # API Revision Identifier + # Specified as part of the path expression + revisionId: + name: revisionId + in: path + description: | + Revision ID of an API + required: true + schema: type: string - example: Platinum - description: + + # API Revision Identifier + # Specified as part of the query string + revisionId-Q: + name: revisionId + in: query + description: | + Revision ID of an API + schema: type: string - example: "Allows 50 request(s) per minute." - tierLevel: + revisionNum-Q: + name: revisionNumber + in: query + description: | + Revision Number of an API + schema: + type: string + policyName: + name: policyName + in: path + description: | + Tier name + required: true + schema: + type: string + policyName-Q: + name: policyName + in: query + description: | + Name of the policy + required: true + schema: + type: string + policyLevel: + name: policyLevel + in: path + description: | + List API or Application or Resource type policies. + required: true + schema: type: string enum: - api - - application - - resource - example: api - attributes: - description: | - Custom attributes added to the tier policy - type: object - additionalProperties: - type: string - example: {} - requestCount: - description: | - Maximum number of requests which can be sent within a provided unit time - type: integer - format: int64 - example: 50 - unitTime: - type: integer - format: int64 - example: 60000 - timeUnit: - type: string - example: "min" - tierPlan: - description: | - This attribute declares whether this tier is available under commercial or free + - subcription + policyLevel-Q: + name: policyLevel + in: query + description: | + List API or Application or Resource type policies. + required: true + schema: type: string enum: - - FREE - - COMMERCIAL - example: FREE - stopOnQuotaReach: - description: | - By making this attribute to false, you are capabale of sending requests - even if the request count exceeded within a unit time + - api + - subcription + limit: + name: limit + in: query + description: | + Maximum size of resource array to return. + schema: + type: integer + default: 25 + Accept: + name: Accept + in: header + description: | + Media types acceptable for the response. Default is application/json. + schema: + type: string + default: application/json + offset: + name: offset + in: query + description: | + Starting point within the complete list of items qualified. + schema: + type: integer + default: 0 + If-None-Match: + name: If-None-Match + in: header + description: | + Validator for conditional requests; based on the ETag of the formerly retrieved + variant of the resource. + schema: + type: string + If-Match: + name: If-Match + in: header + description: | + Validator for conditional requests; based on ETag. + schema: + type: string + scopeName: + name: scopeId + in: path + description: | + Scope name + required: true + schema: + type: string + scopeId: + name: scopeId + in: path + description: | + Scope Id consisting the UUID of the shared scope + required: true + schema: + type: string + expand: + name: expand + in: query + description: | + Defines whether the returned response should contain full details of API + schema: type: boolean - example: true - -#----------------------------------------------------- -# The Tier Permission resource -#----------------------------------------------------- - TierPermission: - title: tierPermission - required: - - permissionType - - roles - properties: - permissionType: + threatProtectionPolicyId: + name: policyId + in: path + description: | + The UUID of a Policy + required: true + schema: type: string - enum: - - allow - - deny - example: deny - roles: - type: array - items: - type: string - example: ["Internal/everyone"] - -#----------------------------------------------------- -# The Subscription List resource -#----------------------------------------------------- - SubscriptionList: - title: Subscription List - properties: - count: - type: integer - description: | - Number of Subscriptions returned. - example: 1 - next: + roleId: + name: roleId + in: path + description: | + The Base 64 URL encoded role name with domain. If the given role is in secondary user-store, role ID should be + derived as Base64URLEncode({user-store-name}/{role-name}). If the given role is in PRIMARY user-store, role ID + can be derived as Base64URLEncode(role-name) + required: true + schema: type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" - previous: + requestedTenant: + name: X-WSO2-Tenant + in: header + description: | + For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be + retirieved from. + schema: type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" - list: - type: array - items: - $ref: '#/definitions/Subscription' - -#----------------------------------------------------- -# The Subscription resource -#----------------------------------------------------- - Subscription: - title: Subscription - required: - - applicationId - - apiIdentifier - - tier - properties: - subscriptionId: + apiProductId: + name: apiProductId + in: path + description: | + **API Product ID** consisting of the **UUID** of the API Product. Using the **UUID** in the API call is recommended. + required: true + schema: type: string - example: 01234567-0123-0123-0123-012345678901 - applicationId: + x-encoded: true + x-encoded: true + tenantDomain: + name: tenantDomain + in: path + description: | + The domain of a specific tenant + required: true + schema: type: string - example: 01234567-0123-0123-0123-012345678901 - apiIdentifier: + alertType: + name: alertType + in: path + description: The alert type. + required: true + schema: type: string - example: 01234567-0123-0123-0123-012345678901 - tier: + configurationId: + name: configurationId + in: path + description: The alert configuration id. + required: true + schema: type: string - example: Unlimited - status: + tierQuotaType: + name: tierQuotaType + description: Filter the subscription base on tier quota type + in: query + schema: type: string - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - UNBLOCKED - - ON_HOLD - - REJECTED - example: UNBLOCKED - -#----------------------------------------------------- -# The Extended Subscription resource -#----------------------------------------------------- - ExtendedSubscription: - title: Subscription with Ext. Workflow Reference - required: - - workflowId - allOf: - - $ref: '#/definitions/Subscription' - - properties: - workflowId: - type: string - example: 01234567-0123-0123-0123-012345678901 - -#----------------------------------------------------- -# The Sequence resource -#----------------------------------------------------- - Sequence: - title: Sequence - required: - - name - properties: - name: - type: string - example: log_in_message - type: - type: string - example: in - id: - type: string - example: 69ea3fa6-55c6-472e-896d-e449dd34a824 - shared: - type: boolean - example: true - -#----------------------------------------------------- -# The Error resource -#----------------------------------------------------- - Error: - title: Error object returned with 4XX HTTP status - required: - - code - - message - properties: - code: - type: integer - format: int64 - message: - type: string - description: Error message. - description: - type: string - description: | - A detail description about the error message. - moreInfo: - type: string - description: | - Preferably an url with more details about the error. - error: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/definitions/ErrorListItem' - -#----------------------------------------------------- -# The Error List Item resource -#----------------------------------------------------- - ErrorListItem: - title: Description of individual errors that may have occurred during a request. - required: - - code - - message - properties: - code: - type: string - message: - type: string - description: | - Description about individual errors occurred - -#----------------------------------------------------- -# The Environment resource -#----------------------------------------------------- - Environment: - title: Environment - required: - - name - - type - - serverUrl - - endpoints - - showInApiConsole - properties: - name: - type: string - example: Production and Sandbox - type: - type: string - example: hybrid - serverUrl: - type: string - example: "https://localhost:9443/services/" - showInApiConsole: - type: boolean - example: true - endpoints: - $ref: '#/definitions/EnvironmentEndpoints' - -#----------------------------------------------------- -# The Environment List resource -#----------------------------------------------------- - EnvironmentList: - title: Environment List - properties: - count: - type: integer - description: | - Number of Environments returned. - example: 1 - list: - type: array - items: - $ref: '#/definitions/Environment' - - -#----------------------------------------------------- -# The Environment Endpoint resource -#----------------------------------------------------- - EnvironmentEndpoints : - title: Environment Endpoints - properties: - http: - type: string - description: HTTP environment URL - example: "http://localhost:8280" - https: - type: string - description: HTTPS environment URL - example: "https://localhost:8243" - -#----------------------------------------------------- -# The File Information resource -#----------------------------------------------------- - FileInfo : - title: File Information including meta data - properties: - relativePath: - type: string - description: relative location of the file (excluding the base context and host of the Publisher API) - example: "apis/01234567-0123-0123-0123-012345678901/thumbnail" - mediaType: - type: string - description: media-type of the file - example: "image/jpeg" - - -#----------------------------------------------------- -# The workflow response resource -#----------------------------------------------------- - Workflow: - title: workflow - required: - - status - properties: - status: - description: | - This attribute declares whether this workflow task is approved or rejected. - type: string - enum: - - APPROVED - - REJECTED - example: APPROVED - attributes: - description: | - Custom attributes to complete the workflow task - type: object - additionalProperties: - type: string - example: {} - description: - type: string - example: "Approve workflow request." \ No newline at end of file + requestBodies: + threatProtectionPolicy: + description: | + Threat protection policy request parameter + content: + application/json: + schema: + $ref: '#/components/schemas/ThreatProtectionPolicy' + required: true + securitySchemes: + OAuth2Security: + type: oauth2 + flows: + password: + tokenUrl: https://localhost:9443/oauth2/token + scopes: + openid: Authorize access to user details + apim:api_view: View API + apim:api_create: Create API + apim:api_delete: Delete API + apim:api_publish: Publish API + apim:subscription_view: View Subscription + apim:subscription_block: Block Subscription + apim:external_services_discover: Discover External Services + apim:threat_protection_policy_create: Create threat protection policies + apim:threat_protection_policy_manage: Update and delete threat protection policies + apim:document_create: Create API documents + apim:document_manage: Update and delete API documents + apim:mediation_policy_view: View mediation policies + apim:mediation_policy_create: Create mediation policies + apim:mediation_policy_manage: Update and delete mediation policies + apim:client_certificates_view: View client certificates + apim:client_certificates_add: Add client certificates + apim:client_certificates_update: Update and delete client certificates + apim:ep_certificates_view: View backend endpoint certificates + apim:ep_certificates_add: Add backend endpoint certificates + apim:ep_certificates_update: Update and delete backend endpoint certificates + apim:publisher_settings: Retrieve store settings + apim:pub_alert_manage: Get/ subscribe/ configure publisher alerts + apim:shared_scope_manage: Manage shared scopes + apim:app_import_export: Import and export applications related operations + apim:api_import_export: Import and export APIs related operations + apim:api_product_import_export: Import and export API Products related operations diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index f033de1d89..ce938982e9 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -43,10 +43,22 @@ org.eclipse.osgi org.eclipse.osgi + + + javax.ws.rs + javax.ws.rs + + org.eclipse.osgi org.eclipse.osgi.services + + + javax.ws.rs + javax.ws.rs + + org.testng @@ -55,62 +67,166 @@ org.wso2.tomcat tomcat + + + javax.ws.rs + javax.ws.rs + + org.wso2.tomcat tomcat-servlet-api + + + javax.ws.rs + javax.ws.rs + + org.wso2.carbon org.wso2.carbon.core + + + javax.ws.rs + javax.ws.rs + + org.wso2.carbon org.wso2.carbon.logging + + + javax.ws.rs + javax.ws.rs + + org.wso2.carbon org.wso2.carbon.utils + + + javax.ws.rs + javax.ws.rs + + org.apache.axis2.wso2 axis2 + + + javax.ws.rs + javax.ws.rs + + com.google.code.gson gson + + + javax.ws.rs + javax.ws.rs + + org.wso2.orbit.org.scannotation scannotation + + + javax.ws.rs + javax.ws.rs + + javax.ws.rs jsr311-api + + + javax.ws.rs + javax.ws.rs + + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations + + + javax.ws.rs + javax.ws.rs + + org.wso2.carbon.governance org.wso2.carbon.governance.api + + + javax.ws.rs + javax.ws.rs + + org.wso2.carbon.governance org.wso2.carbon.governance.lcm + + + javax.ws.rs + javax.ws.rs + + javax.ws.rs javax.ws.rs-api + + + javax.ws.rs + javax.ws.rs + + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common + + + javax.ws.rs + javax.ws.rs + + - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.integration.client + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + provided + 9.0.5 + + + javax.ws.rs + javax.ws.rs + + + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.impl + 9.0.5 + provided + + + javax.ws.rs + javax.ws.rs + + com.h2database.wso2 @@ -144,70 +260,62 @@ org.wso2.carbon.apimgt.webapp.publisher.* - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.servlet, - javax.xml.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - com.google.gson.*, - org.apache.catalina, - org.apache.catalina.core, - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.wso2.carbon.core, - org.apache.commons.lang, - org.wso2.carbon.utils, - org.wso2.carbon.apimgt.annotations.*, - org.wso2.carbon.governance.lcm.util.*, - org.wso2.carbon.registry.core.*, - io.swagger.annotations, - javax.net.ssl, - org.scannotation, - org.scannotation.archiveiterator, - org.w3c.dom, - org.wso2.carbon.apimgt.integration.client.*, - org.wso2.carbon.context, - org.wso2.carbon.core.util, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.*, - org.wso2.carbon.utils.multitenancy, - org.wso2.carbon.apimgt.integration.generated.client.publisher.api, - org.wso2.carbon.apimgt.integration.generated.client.publisher.model + com.google.gson;version="2.3",com.google.gson.reflect; + version="2.3",io.swagger.annotations,javax.servlet;version="2.6",javax.xml,javax.xml.bind,javax.xml.bind.annotat + ion,javax.xml.parsers,org.apache.catalina;version="9.0",org.apache.ca + talina.core;version="9.0",org.apache.commons.logging;version="1.2",org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}",org.scannotation;version="1.0",org.scannotation.archiveiterator;ve + rsion="1.0",org.w3c.dom,org.wso2.carbon.apimgt.annotations.api,org.ws + o2.carbon.apimgt.api,org.wso2.carbon.apimgt.api.model,org.wso2.carbon + .apimgt.impl,org.wso2.carbon.apimgt.webapp.publisher,org.wso2.carbon. + apimgt.webapp.publisher.config,org.wso2.carbon.apimgt.webapp.publishe + r.dto,org.wso2.carbon.apimgt.webapp.publisher.exception,org.wso2.carb + on.apimgt.webapp.publisher.lifecycle.listener,org.wso2.carbon.apimgt. + webapp.publisher.lifecycle.util,org.wso2.carbon.base;version="1.0",or + g.wso2.carbon.context;version="4.6",org.wso2.carbon.core;version="4.6 + ",org.wso2.carbon.core.util;version="4.6",org.wso2.carbon.registry.co + re.service;version="1.0",org.wso2.carbon.user.api;version="1.0",org.w + so2.carbon.user.core.service;version="4.6",org.wso2.carbon.user.core. + tenant;version="4.6",org.wso2.carbon.utils;version="4.6",org.wso2.car + bon.utils.multitenancy;version="4.6" - javax.ws.rs-api, - scribe;scope=compile|runtime;inline=false; + + jsr311-api;scope=compile|runtime;inline=false + - * + - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 2fe35e472b..a6b98ad438 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -18,15 +18,34 @@ */ package org.wso2.carbon.apimgt.webapp.publisher; -import feign.FeignException; -import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*; -import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; +import org.wso2.carbon.apimgt.api.APIManagementException; +import org.wso2.carbon.apimgt.api.APIProvider; +import org.wso2.carbon.apimgt.api.FaultGatewaysException; +import org.wso2.carbon.apimgt.api.model.API; +import org.wso2.carbon.apimgt.api.model.APIIdentifier; +import org.wso2.carbon.apimgt.api.model.APIRevision; +import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment; +import org.wso2.carbon.apimgt.api.model.CORSConfiguration; +import org.wso2.carbon.apimgt.api.model.Scope; +import org.wso2.carbon.apimgt.api.model.Tier; +import org.wso2.carbon.apimgt.api.model.URITemplate; +import org.wso2.carbon.apimgt.impl.APIConstants; +import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; +import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiUriTemplate; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; -import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.util.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +//import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*; +//import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; /** * This class represents the concrete implementation of the APIPublisherService that corresponds to providing all @@ -39,6 +58,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { private static final String PUBLISHED_STATUS = "PUBLISHED"; private static final String CREATED_STATUS = "CREATED"; private static final String PUBLISH_ACTION = "Publish"; + public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); @Override public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException { @@ -47,99 +67,127 @@ public class APIPublisherServiceImpl implements APIPublisherService { PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner()); try { - PublisherClient publisherClient = APIPublisherDataHolder.getInstance().getIntegrationClientService() - .getPublisherClient(); + APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(apiConfig.getOwner()); API api = getAPI(apiConfig); - APIList apiList = publisherClient.getApis().apisGet(100, 0, "name:" + api.getName(), CONTENT_TYPE, null); - if (!isExist(api, apiList)) { - api = publisherClient.getApi().apisPost(api, CONTENT_TYPE, null); - if (CREATED_STATUS.equals(api.getStatus())) { - publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null); + if (!apiProvider.isAPIAvailable(api.getId())) { + API createdAPI = apiProvider.addAPI(api); + if (CREATED_STATUS.equals(createdAPI.getStatus())) { + apiProvider.changeLifeCycleStatus(tenantDomain, createdAPI.getUuid(), PUBLISH_ACTION, null); + APIRevision apiRevision = new APIRevision(); + apiRevision.setApiUUID(createdAPI.getUuid()); + apiRevision.setDescription("Initial Revision"); + String apiRevisionId = apiProvider.addAPIRevision(apiRevision, tenantDomain); + APIRevisionDeployment apiRevisionDeployment = new APIRevisionDeployment(); + apiRevisionDeployment.setDeployment(API_PUBLISH_ENVIRONMENT); + apiRevisionDeployment.setVhost("localhost"); + apiRevisionDeployment.setDisplayOnDevportal(true); + + List apiRevisionDeploymentList = new ArrayList<>(); + apiRevisionDeploymentList.add(apiRevisionDeployment); + apiProvider.deployAPIRevision(createdAPI.getUuid(), apiRevisionId, apiRevisionDeploymentList); + } } else { if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { - for (APIInfo apiInfo : apiList.getList()) { - if (api.getName().equals(apiInfo.getName()) && api.getVersion().equals(apiInfo.getVersion())) { - api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, null); - if (api != null && CREATED_STATUS.equals(api.getStatus())) { - publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, - null); - } + API existingAPI = apiProvider.getAPI(api.getId()); + api.setStatus(existingAPI.getStatus()); + apiProvider.updateAPI(api); + if (api.getId().getName().equals(existingAPI.getId().getName()) && + api.getId().getVersion().equals(existingAPI.getId().getVersion())) { + if (CREATED_STATUS.equals(existingAPI.getStatus())) { + apiProvider.changeLifeCycleStatus(tenantDomain, existingAPI.getUuid(), PUBLISH_ACTION, null); } - } } } - } catch (FeignException e) { + + + } catch (FaultGatewaysException | APIManagementException e) { throw new APIManagerPublisherException(e); } finally { PrivilegedCarbonContext.endTenantFlow(); } } - private boolean isExist(API api, APIList apiList) { - if (apiList == null || apiList.getList() == null || apiList.getList().size() == 0) { - return false; - } - for (APIInfo existingApi : apiList.getList()) { - if (existingApi.getName() != null && existingApi.getName().equals(api. - getName()) && existingApi.getVersion() != null && - existingApi.getVersion().equals(api.getVersion())) { - return true; - } - } - return false; - } - private API getAPI(APIConfig config) { - API api = new API(); - api.setName(config.getName()); + APIIdentifier apiIdentifier = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion()); + API api = new API(apiIdentifier); api.setDescription(""); - String context = config.getContext(); context = context.startsWith("/") ? context : ("/" + context); - api.setContext(context); - api.setVersion(config.getVersion()); - api.setProvider(config.getOwner()); - api.setApiDefinition(APIPublisherUtil.getSwaggerDefinition(config)); - api.setWsdlUri(null); - api.setStatus(PUBLISHED_STATUS); - api.setResponseCaching("DISABLED"); - api.setDestinationStatsEnabled("false"); - api.isDefaultVersion(config.isDefault()); - List transport = new ArrayList<>(); - transport.add("https"); - transport.add("http"); - api.transport(transport); - api.setTags(Arrays.asList(config.getTags())); - api.addTiersItem(UNLIMITED_TIER); - api.setGatewayEnvironments(API_PUBLISH_ENVIRONMENT); - if (config.isSharedWithAllTenants()) { - api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.all_tenants); - api.setVisibility(API.VisibilityEnum.PUBLIC); - } else { - api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.current_tenant); - api.setVisibility(API.VisibilityEnum.PRIVATE); - } - String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() + - "\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}"; + api.setContext(context + "/" + config.getVersion()); +// api.setContext(context); + api.setStatus(CREATED_STATUS); + api.setWsdlUrl(null); + api.setResponseCache("Disabled"); + api.setContextTemplate(context + "/{version}" ); + api.setSwaggerDefinition(APIPublisherUtil.getSwaggerDefinition(config)); + api.setType("HTTP"); + Set uriTemplates = new HashSet<>(); + Iterator iterator; + for (iterator = config.getUriTemplates().iterator(); iterator.hasNext(); ) { + ApiUriTemplate apiUriTemplate = iterator.next(); + URITemplate uriTemplate = new URITemplate(); + uriTemplate.setAuthType(apiUriTemplate.getAuthType()); + uriTemplate.setHTTPVerb(apiUriTemplate.getHttpVerb()); + uriTemplate.setResourceURI(apiUriTemplate.getResourceURI()); + uriTemplate.setUriTemplate(apiUriTemplate.getUriTemplate()); + Scope scope = new Scope(); + if (apiUriTemplate.getScope() != null) { + scope.setName(apiUriTemplate.getScope().getName()); + scope.setDescription(apiUriTemplate.getScope().getDescription()); + scope.setKey(apiUriTemplate.getScope().getKey()); + scope.setRoles(apiUriTemplate.getScope().getRoles()); + uriTemplate.setScope(scope); + } + uriTemplates.add(uriTemplate); + } + api.setUriTemplates(uriTemplates); + + api.setApiOwner(config.getOwner()); + + + api.setDefaultVersion(config.isDefault()); + api.setTransports("https,http"); + + Set tags = new HashSet<>(); + tags.addAll(Arrays.asList(config.getTags())); + api.setTags(tags); + + Set availableTiers = new HashSet<>(); + availableTiers.add(new Tier(UNLIMITED_TIER)); + api.setAvailableTiers(availableTiers); + + Set environments = new HashSet<>(); + environments.add(API_PUBLISH_ENVIRONMENT); + api.setEnvironments(environments); + + if (config.isSharedWithAllTenants()) { + api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_ALL_TENANTS); + api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY); + } else { + api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_CURRENT_TENANT); + api.setVisibility(APIConstants.API_PRIVATE_VISIBILITY); + } + // String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() + + // "\",\"config\":null},\"endpoint_type\":\"http\"}"; + String endpointConfig = "{ \"endpoint_type\": \"http\", \"sandbox_endpoints\": { \"url\": \" " + + config.getEndpoint() + "\" }, \"production_endpoints\": { \"url\": \" "+ config.getEndpoint()+"\" } }"; api.setEndpointConfig(endpointConfig); - APICorsConfiguration apiCorsConfiguration = new APICorsConfiguration(); List accessControlAllowOrigins = new ArrayList<>(); accessControlAllowOrigins.add("*"); - apiCorsConfiguration.setAccessControlAllowOrigins(accessControlAllowOrigins); List accessControlAllowHeaders = new ArrayList<>(); accessControlAllowHeaders.add("authorization"); accessControlAllowHeaders.add("Access-Control-Allow-Origin"); accessControlAllowHeaders.add("Content-Type"); accessControlAllowHeaders.add("SOAPAction"); - apiCorsConfiguration.setAccessControlAllowHeaders(accessControlAllowHeaders); - + accessControlAllowHeaders.add("apikey"); + accessControlAllowHeaders.add("testKey"); List accessControlAllowMethods = new ArrayList<>(); accessControlAllowMethods.add("GET"); accessControlAllowMethods.add("PUT"); @@ -147,10 +195,16 @@ public class APIPublisherServiceImpl implements APIPublisherService { accessControlAllowMethods.add("POST"); accessControlAllowMethods.add("PATCH"); accessControlAllowMethods.add("OPTIONS"); - apiCorsConfiguration.setAccessControlAllowMethods(accessControlAllowMethods); - apiCorsConfiguration.setAccessControlAllowCredentials(false); - apiCorsConfiguration.corsConfigurationEnabled(false); - api.setCorsConfiguration(apiCorsConfiguration); + CORSConfiguration corsConfiguration = new CORSConfiguration(false, accessControlAllowOrigins, false, + accessControlAllowHeaders, accessControlAllowMethods); + api.setCorsConfiguration(corsConfiguration); + + api.setAuthorizationHeader("Authorization"); + List keyManagers = new ArrayList<>(); + keyManagers.add("all"); + api.setKeyManagers(keyManagers); + api.setEnableStore(true); + return api; } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index 639c2fe217..9acc17232f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -18,7 +18,7 @@ */ package org.wso2.carbon.apimgt.webapp.publisher.internal; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.apimgt.webapp.publisher.APIConfig; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.registry.core.service.RegistryService; @@ -37,7 +37,7 @@ public class APIPublisherDataHolder { private RegistryService registryService; private boolean isServerStarted; private Stack unpublishedApis = new Stack<>(); - private IntegrationClientService integrationClientService; + // private IntegrationClientService integrationClientService; private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder(); @@ -117,12 +117,12 @@ public class APIPublisherDataHolder { this.unpublishedApis = unpublishedApis; } - public IntegrationClientService getIntegrationClientService() { - return integrationClientService; - } + // public IntegrationClientService getIntegrationClientService() { + // return integrationClientService; + // } - public void setIntegrationClientService( - IntegrationClientService integrationClientService) { - this.integrationClientService = integrationClientService; - } + // public void setIntegrationClientService( + // IntegrationClientService integrationClientService) { + // this.integrationClientService = integrationClientService; + // } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java index dd5736570c..a714d97aa8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler; @@ -45,11 +45,7 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRegistryService" * unbind="unsetRegistryService" - * interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService" - * cardinality="1..1" - * policy="dynamic" - * bind="setIntegrationClientService" - * unbind="unsetIntegrationClientService" + */ public class APIPublisherServiceComponent { @@ -120,14 +116,14 @@ public class APIPublisherServiceComponent { APIPublisherDataHolder.getInstance().setRegistryService(null); } - protected void setIntegrationClientService(IntegrationClientService integrationClientService) { - if (integrationClientService != null && log.isDebugEnabled()) { - log.debug("integrationClientService initialized"); - } - APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService); - } - - protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { - APIPublisherDataHolder.getInstance().setIntegrationClientService(null); - } + // protected void setIntegrationClientService(IntegrationClientService integrationClientService) { + // if (integrationClientService != null && log.isDebugEnabled()) { + // log.debug("integrationClientService initialized"); + // } + // APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService); + // } + // + // protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { + // APIPublisherDataHolder.getInstance().setIntegrationClientService(null); + // } } diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 41507f9fa9..fca4d2100a 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -34,13 +34,13 @@ http://wso2.org - org.wso2.carbon.apimgt.integration.generated.client - org.wso2.carbon.apimgt.integration.client + + org.wso2.carbon.apimgt.webapp.publisher org.wso2.carbon.apimgt.application.extension org.wso2.carbon.apimgt.application.extension.api org.wso2.carbon.apimgt.annotations - org.wso2.carbon.apimgt.handlers + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml index e195e08097..9f50930c4f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml index 876c0ab594..9ebaecc139 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml @@ -56,7 +56,7 @@ io.swagger.annotations.*;resolution:=optional, com.fasterxml.jackson.annotation, javax.validation.constraints, - javax.xml.bind.annotation.*, + javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", org.wso2.carbon.device.application.mgt.common.* diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index 82d75d4687..f861513e29 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -51,8 +51,66 @@ Application Management Core Bundle org.wso2.carbon.device.application.mgt.core.internal - org.osgi.framework, - org.osgi.service.component, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, org.wso2.carbon.context.*, @@ -62,8 +120,8 @@ javax.sql, com.google.gson.*, javax.naming, - javax.xml.bind.annotation, - javax.xml.bind, + javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", + javax.xml.bind; version="${javax.xml.bind.imp.pkg.version}", org.wso2.carbon.device.application.mgt.common.*, org.wso2.carbon.device.mgt.core.*, org.wso2.carbon.device.mgt.common.*, @@ -348,6 +406,14 @@ + + org.wso2.carbon.devicemgt + org.wso2.carbon.identity.jwt.client.extension + + + + + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/OAuthUtils.java index b57ffebeb7..33a9d0706f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/OAuthUtils.java @@ -63,7 +63,7 @@ public class OAuthUtils { apiApplicationKeyInfo = apiManagementProviderService. generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, - registrationProfile.getApplicationName(), registrationProfile.isAllowedToAllDomains(), + null, registrationProfile.isAllowedToAllDomains(), Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD); } finally { PrivilegedCarbonContext.endTenantFlow(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/webapp-classloading.xml index da8baef61f..7a71395445 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/META-INF/webapp-classloading.xml index da8baef61f..7a71395445 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index fa191390be..888eda3b79 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -133,10 +133,22 @@ + + + + + + + org.springframework + spring-web + provided + org.apache.cxf - cxf-rt-frontend-jaxws + cxf-bundle-jaxrs + provided + commons-codec.wso2 commons-codec @@ -147,24 +159,26 @@ - - org.apache.cxf - cxf-rt-frontend-jaxrs - - - org.apache.cxf - cxf-rt-transports-http - + + + + + + + + + + junit junit test - - javax.ws.rs - jsr311-api - provided - + + + + + org.wso2.carbon org.wso2.carbon.logging @@ -207,11 +221,11 @@ - - javax.servlet - javax.servlet-api - provided - + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml index ed2ed21624..60db8782e9 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index cbe533dd6d..94d2a8fec1 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -133,10 +133,26 @@ + + + + + + org.springframework + spring-web + provided + org.apache.cxf - cxf-rt-frontend-jaxws + cxf-bundle-jaxrs + provided + + + + + + commons-codec.wso2 commons-codec @@ -147,14 +163,10 @@ - - org.apache.cxf - cxf-rt-frontend-jaxrs - - - org.apache.cxf - cxf-rt-transports-http - + + + + junit junit @@ -204,11 +216,11 @@ - - javax.servlet - javax.servlet-api - provided - + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/webapp-classloading.xml index ed2ed21624..60db8782e9 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 6942c86d84..898f828dc5 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -72,8 +72,8 @@ org.wso2.carbon.certificate.mgt.core.util - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, org.apache.commons.collections.map, javax.security.auth.x500, diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 6c47262ab0..698bba5d44 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -140,8 +140,8 @@ org.apache.axis2.deployment.*, org.apache.commons.lang;version="${commons-lang.wso2.osgi.version.range}", org.apache.commons.logging, - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.w3c.dom, org.wso2.carbon.context, org.wso2.carbon.device.mgt.common.*, diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index 14a9d8c308..e8f93ec911 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -82,8 +82,8 @@ org.wso2.carbon.device.mgt.extensions.pull.notification.* - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.core.service diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index b102c68e13..a40a895622 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -135,7 +135,8 @@ com.google.gson, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.push.notification, org.apache.commons.logging, diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index 447951938b..994f41bfe5 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -126,13 +126,13 @@ org.apache.commons.logging, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.context, org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.push.notification, org.wso2.carbon.device.mgt.common, org.wso2.carbon.device.mgt.core.service, - org.osgi.framework, org.wso2.carbon.device.mgt.core.operation.mgt, org.wso2.carbon.core, com.google.gson, diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index a59a3728a5..5b6766bb66 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -148,7 +148,8 @@ org.apache.commons.logging, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.context, org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.push.notification, @@ -157,7 +158,6 @@ org.wso2.carbon.device.mgt.core.service, org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core.exception, - org.osgi.framework, org.wso2.carbon.device.mgt.core.operation.mgt, org.wso2.carbon.core, org.wso2.carbon.device.application.mgt.common.*, diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 1a6e1a58ab..81ac96adc5 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -135,14 +135,14 @@ org.apache.commons.logging, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.context, org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.push.notification, org.wso2.carbon.device.mgt.core.service, org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core.exception, - org.osgi.framework, org.wso2.carbon.core, org.wso2.carbon.device.mgt.common.* diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index bd43c8b626..4eada72d20 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -146,15 +146,26 @@ - org.apache.cxf - cxf-rt-frontend-jaxrs + org.springframework + spring-web provided org.apache.cxf - cxf-rt-transports-http + cxf-bundle-jaxrs provided + + + + + + + + + + + javax.ws.rs jsr311-api diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java index 9ccbecda3d..f9ee5e913d 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java @@ -200,8 +200,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); KeyManagerConfigurations kmConfig = deviceManagementConfig.getKeyManagerConfigurations(); AppRegistrationCredentials credentials = DeviceManagerUtil.getApplicationRegistrationCredentials( - System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HOST), - System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HTTPS_PORT), + System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HOST), + System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HTTPS_PORT), kmConfig.getAdminUsername(), kmConfig.getAdminPassword()); AccessTokenInfo accessTokenForAdmin = DeviceManagerUtil.getAccessTokenForDeviceOwner( diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/META-INF/webapp-classloading.xml index 01aceabde5..a16c0a9cbf 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index 7e7060e5b2..d4849aceef 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -107,8 +107,8 @@ org.wso2.carbon.device.mgt.analytics.data.publisher.*;version="${carbon.device.mgt.version}" - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging.*, org.wso2.carbon.utils.multitenancy, org.wso2.carbon.context;version="${carbon.kernel.version.range}", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index d2992949d2..86b7e6e035 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -146,30 +146,41 @@ - org.apache.cxf - cxf-rt-frontend-jaxws + org.springframework + spring-web provided org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http + cxf-bundle-jaxrs provided + + + + + + + + + + + + + + + + commons-httpclient.wso2 commons-httpclient provided - - javax.ws.rs - jsr311-api - provided - + + + + + org.wso2.carbon org.wso2.carbon.utils @@ -200,11 +211,11 @@ org.wso2.carbon.device.mgt.common provided - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics.data.publisher - provided - + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.extensions @@ -351,11 +362,11 @@ org.wso2.carbon.analytics.api provided - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.datasource.commons - provided - + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension @@ -402,11 +413,11 @@ org.wso2.carbon.event.stream.persistence.stub provided - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.integration.client - provided - + + + + + org.powermock powermock-module-testng diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java index 9eddd91aeb..fc0ce9c794 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java @@ -67,64 +67,64 @@ import javax.ws.rs.core.Response; @Consumes(MediaType.APPLICATION_JSON) public interface DeviceEventManagementService { - @POST - @Path("/{type}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Adding the Event Type Definition", - notes = "Add the event definition for a device.", - tags = "Device Event Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully added the event defintion.", - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = - "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - } - ), - @ApiResponse( - code = 400, - message = - "Bad Request. \n"), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the " + - "list of supported device types.", - response = ErrorResponse.class) - } - ) - Response deployDeviceTypeEventDefinition( - @ApiParam(name = "type", value = "The device type, such as android, ios, and windows.") - @PathParam("type")String deviceType, - @ApiParam(name = "skipPersist", value = "Is it required to persist the data or not") - @QueryParam("skipPersist") boolean skipPersist, - @ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants") - @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants, - @ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.", - required = true) - @Valid DeviceTypeEvent deviceTypeEvent); +// @POST +// @Path("/{type}") +// @ApiOperation( +// produces = MediaType.APPLICATION_JSON, +// httpMethod = "POST", +// value = "Adding the Event Type Definition", +// notes = "Add the event definition for a device.", +// tags = "Device Event Management", +// extensions = { +// @Extension(properties = { +// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events") +// }) +// } +// ) +// @ApiResponses( +// value = { +// @ApiResponse( +// code = 200, +// message = "OK. \n Successfully added the event defintion.", +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "ETag", +// description = "Entity Tag of the response resource.\n" + +// "Used by caches, or in conditional requests."), +// @ResponseHeader( +// name = "Last-Modified", +// description = +// "Date and time the resource was last modified.\n" + +// "Used by caches, or in conditional requests."), +// } +// ), +// @ApiResponse( +// code = 400, +// message = +// "Bad Request. \n"), +// @ApiResponse( +// code = 406, +// message = "Not Acceptable.\n The requested media type is not supported"), +// @ApiResponse( +// code = 500, +// message = "Internal Server Error. \n Server error occurred while fetching the " + +// "list of supported device types.", +// response = ErrorResponse.class) +// } +// ) +// Response deployDeviceTypeEventDefinition( +// @ApiParam(name = "type", value = "The device type, such as android, ios, and windows.") +// @PathParam("type")String deviceType, +// @ApiParam(name = "skipPersist", value = "Is it required to persist the data or not") +// @QueryParam("skipPersist") boolean skipPersist, +// @ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants") +// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants, +// @ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.", +// required = true) +// @Valid DeviceTypeEvent deviceTypeEvent); @DELETE @Path("/{type}") @@ -178,183 +178,183 @@ public interface DeviceEventManagementService { "ios, and windows.", required = false) @PathParam("type")String deviceType); - @GET - @Path("/{type}/{deviceId}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting Device Events", - notes = "Get the events for the device.", - tags = "Device Event Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the event definition.", - response = EventRecords.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = - "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - } - ), - @ApiResponse( - code = 400, - message = - "Bad Request. \n"), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the " + - "list of supported device types.", - response = ErrorResponse.class) - } - ) - Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false) - @PathParam("deviceId") String deviceId, - @ApiParam(name = "from", value = "unix timestamp to retrieve", required = false) - @QueryParam("from") long from, - @ApiParam(name = "to", value = "unix time to retrieve", required = false) - @QueryParam("to") long to, - @ApiParam(name = "type", value = "name of the device type", required = false) - @PathParam("type") String deviceType, - @ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false) - @QueryParam("offset") int offset, - @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) - @QueryParam("limit") int limit); +// @GET +// @Path("/{type}/{deviceId}") +// @ApiOperation( +// produces = MediaType.APPLICATION_JSON, +// httpMethod = "GET", +// value = "Getting Device Events", +// notes = "Get the events for the device.", +// tags = "Device Event Management", +// extensions = { +// @Extension(properties = { +// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") +// }) +// } +// ) +// @ApiResponses( +// value = { +// @ApiResponse( +// code = 200, +// message = "OK. \n Successfully fetched the event definition.", +// response = EventRecords.class, +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "ETag", +// description = "Entity Tag of the response resource.\n" + +// "Used by caches, or in conditional requests."), +// @ResponseHeader( +// name = "Last-Modified", +// description = +// "Date and time the resource was last modified.\n" + +// "Used by caches, or in conditional requests."), +// } +// ), +// @ApiResponse( +// code = 400, +// message = +// "Bad Request. \n"), +// @ApiResponse( +// code = 406, +// message = "Not Acceptable.\n The requested media type is not supported"), +// @ApiResponse( +// code = 500, +// message = "Internal Server Error. \n Server error occurred while fetching the " + +// "list of supported device types.", +// response = ErrorResponse.class) +// } +// ) +// Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false) +// @PathParam("deviceId") String deviceId, +// @ApiParam(name = "from", value = "unix timestamp to retrieve", required = false) +// @QueryParam("from") long from, +// @ApiParam(name = "to", value = "unix time to retrieve", required = false) +// @QueryParam("to") long to, +// @ApiParam(name = "type", value = "name of the device type", required = false) +// @PathParam("type") String deviceType, +// @ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false) +// @QueryParam("offset") int offset, +// @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) +// @QueryParam("limit") int limit); - @GET - @Path("last-known/{type}/{deviceId}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting Last Known Device Events", - notes = "Get the last known events for the device.", - tags = "Device Event Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the event.", - response = EventRecords.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = - "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - } - ), - @ApiResponse( - code = 400, - message = - "Bad Request. \n"), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the " + - "list of supported device types.", - response = ErrorResponse.class) - } - ) - Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true) - @PathParam("deviceId") String deviceId, - @ApiParam(name = "type", value = "name of the device type", required = true) - @PathParam("type") String deviceType, - @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) - @QueryParam("limit") int limit); +// @GET +// @Path("last-known/{type}/{deviceId}") +// @ApiOperation( +// produces = MediaType.APPLICATION_JSON, +// httpMethod = "GET", +// value = "Getting Last Known Device Events", +// notes = "Get the last known events for the device.", +// tags = "Device Event Management", +// extensions = { +// @Extension(properties = { +// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") +// }) +// } +// ) +// @ApiResponses( +// value = { +// @ApiResponse( +// code = 200, +// message = "OK. \n Successfully fetched the event.", +// response = EventRecords.class, +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "ETag", +// description = "Entity Tag of the response resource.\n" + +// "Used by caches, or in conditional requests."), +// @ResponseHeader( +// name = "Last-Modified", +// description = +// "Date and time the resource was last modified.\n" + +// "Used by caches, or in conditional requests."), +// } +// ), +// @ApiResponse( +// code = 400, +// message = +// "Bad Request. \n"), +// @ApiResponse( +// code = 406, +// message = "Not Acceptable.\n The requested media type is not supported"), +// @ApiResponse( +// code = 500, +// message = "Internal Server Error. \n Server error occurred while fetching the " + +// "list of supported device types.", +// response = ErrorResponse.class) +// } +// ) +// Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true) +// @PathParam("deviceId") String deviceId, +// @ApiParam(name = "type", value = "name of the device type", required = true) +// @PathParam("type") String deviceType, +// @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) +// @QueryParam("limit") int limit); - @GET - @Path("filter/{type}/{parameter}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting the filtered devices", - notes = "Get the list of devices based on the filter parameter", - tags = "Device Event Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the event.", - response = EventRecords.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = - "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - } - ), - @ApiResponse( - code = 400, - message = - "Bad Request. \n"), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the " + - "list of supported device types.", - response = ErrorResponse.class) - } - ) - Response getFilteredDevices( - @ApiParam(name = "type", value = "name of the device type", required = true) - @PathParam("type") String deviceType, - @ApiParam(name = "type", value = "name of the parameter", required = true) - @PathParam("type") String parameter, - @ApiParam(name = "limit", value = "minimum value the parameter can have", required = false) - @QueryParam("min") double min, - @ApiParam(name = "max", value = "max value the parameter can have", required = false) - @QueryParam("max") double max - ); +// @GET +// @Path("filter/{type}/{parameter}") +// @ApiOperation( +// produces = MediaType.APPLICATION_JSON, +// httpMethod = "GET", +// value = "Getting the filtered devices", +// notes = "Get the list of devices based on the filter parameter", +// tags = "Device Event Management", +// extensions = { +// @Extension(properties = { +// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") +// }) +// } +// ) +// @ApiResponses( +// value = { +// @ApiResponse( +// code = 200, +// message = "OK. \n Successfully fetched the event.", +// response = EventRecords.class, +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "ETag", +// description = "Entity Tag of the response resource.\n" + +// "Used by caches, or in conditional requests."), +// @ResponseHeader( +// name = "Last-Modified", +// description = +// "Date and time the resource was last modified.\n" + +// "Used by caches, or in conditional requests."), +// } +// ), +// @ApiResponse( +// code = 400, +// message = +// "Bad Request. \n"), +// @ApiResponse( +// code = 406, +// message = "Not Acceptable.\n The requested media type is not supported"), +// @ApiResponse( +// code = 500, +// message = "Internal Server Error. \n Server error occurred while fetching the " + +// "list of supported device types.", +// response = ErrorResponse.class) +// } +// ) +// Response getFilteredDevices( +// @ApiParam(name = "type", value = "name of the device type", required = true) +// @PathParam("type") String deviceType, +// @ApiParam(name = "type", value = "name of the parameter", required = true) +// @PathParam("type") String parameter, +// @ApiParam(name = "limit", value = "minimum value the parameter can have", required = false) +// @QueryParam("min") double min, +// @ApiParam(name = "max", value = "max value the parameter can have", required = false) +// @QueryParam("max") double max +// ); @GET @Path("/{type}") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java index 5e55acdc77..8b3071f1ef 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java @@ -97,71 +97,71 @@ public interface GeoLocationBasedService { /** * Retrieve Analytics for the device type */ - @GET - @Path("stats/{deviceType}/{deviceId}") - @ApiOperation( - consumes = "application/json", - produces = "application/json", - httpMethod = "GET", - value = "Getting the Location Details of a Device", - notes = "Get the location details of a device during a define time period.", - response = Response.class, - tags = "Geo Service Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK.", - response = Response.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid Device Identifiers found.", - response = Response.class), - @ApiResponse( - code = 401, - message = "Unauthorized. \n Unauthorized request."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error on retrieving stats", - response = Response.class) - }) - Response getGeoDeviceStats( - @ApiParam( - name = "deviceId", - value = "The device ID.", - required = true) - @PathParam("deviceId") String deviceId, - @ApiParam( - name = "device-type", - value = "The device type, such as ios, android, or windows.", - required = true) - @PathParam("deviceType") - @Size(max = 45) - String deviceType, - @ApiParam( - name = "from", - value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.", - required = true) - @QueryParam("from") long from, - @ApiParam( - name = "to", - value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.", - required = true) - @QueryParam("to") long to); +// @GET +// @Path("stats/{deviceType}/{deviceId}") +// @ApiOperation( +// consumes = "application/json", +// produces = "application/json", +// httpMethod = "GET", +// value = "Getting the Location Details of a Device", +// notes = "Get the location details of a device during a define time period.", +// response = Response.class, +// tags = "Geo Service Management", +// extensions = { +// @Extension(properties = { +// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view") +// }) +// } +// ) +// @ApiResponses(value = { +// @ApiResponse( +// code = 200, +// message = "OK.", +// response = Response.class, +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "Last-Modified", +// description = "Date and time the resource was last modified.\n" + +// "Used by caches, or in conditional requests."), +// }), +// @ApiResponse( +// code = 400, +// message = "Bad Request. \n Invalid Device Identifiers found.", +// response = Response.class), +// @ApiResponse( +// code = 401, +// message = "Unauthorized. \n Unauthorized request."), +// @ApiResponse( +// code = 500, +// message = "Internal Server Error. \n Error on retrieving stats", +// response = Response.class) +// }) +// Response getGeoDeviceStats( +// @ApiParam( +// name = "deviceId", +// value = "The device ID.", +// required = true) +// @PathParam("deviceId") String deviceId, +// @ApiParam( +// name = "device-type", +// value = "The device type, such as ios, android, or windows.", +// required = true) +// @PathParam("deviceType") +// @Size(max = 45) +// String deviceType, +// @ApiParam( +// name = "from", +// value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.", +// required = true) +// @QueryParam("from") long from, +// @ApiParam( +// name = "to", +// value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.", +// required = true) +// @QueryParam("to") long to); /** * Get data to show device locations in a map @@ -602,128 +602,128 @@ public interface GeoLocationBasedService { /** * Retrieve Geo alerts history */ - @GET - @Path("alerts/history/{deviceType}/{deviceId}") - @ApiOperation( - consumes = "application/json", - produces = "application/json", - httpMethod = "GET", - value = "Getting the Geo Service Alert History of a Device", - notes = "Get the geo alert history of a device during the defined time period.", - response = Response.class, - tags = "Geo Service Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK.", - response = Response.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.") - }), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid Device Identifiers found.", - response = Response.class), - @ApiResponse( - code = 401, - message = "Unauthorized. \n Unauthorized request."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error on retrieving stats", - response = Response.class) - }) - Response getGeoAlertsHistory( - @ApiParam( - name = "deviceId", - value = "The device ID.", - required = true) - @PathParam("deviceId") String deviceId, - @ApiParam( - name = "device-type", - value = "The device type, such as ios, android, or windows.", - required = true) - @PathParam("deviceType") - @Size(max = 45) - String deviceType, - @ApiParam( - name = "from", - value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.", - required = true) - @QueryParam("from") long from, - @ApiParam( - name = "to", - value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.", - required = true) - @QueryParam("to") long to); +// @GET +// @Path("alerts/history/{deviceType}/{deviceId}") +// @ApiOperation( +// consumes = "application/json", +// produces = "application/json", +// httpMethod = "GET", +// value = "Getting the Geo Service Alert History of a Device", +// notes = "Get the geo alert history of a device during the defined time period.", +// response = Response.class, +// tags = "Geo Service Management", +// extensions = { +// @Extension(properties = { +// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") +// }) +// } +// ) +// @ApiResponses(value = { +// @ApiResponse( +// code = 200, +// message = "OK.", +// response = Response.class, +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "Last-Modified", +// description = "Date and time the resource was last modified.\n" + +// "Used by caches, or in conditional requests.") +// }), +// @ApiResponse( +// code = 400, +// message = "Bad Request. \n Invalid Device Identifiers found.", +// response = Response.class), +// @ApiResponse( +// code = 401, +// message = "Unauthorized. \n Unauthorized request."), +// @ApiResponse( +// code = 500, +// message = "Internal Server Error. \n Error on retrieving stats", +// response = Response.class) +// }) +// Response getGeoAlertsHistory( +// @ApiParam( +// name = "deviceId", +// value = "The device ID.", +// required = true) +// @PathParam("deviceId") String deviceId, +// @ApiParam( +// name = "device-type", +// value = "The device type, such as ios, android, or windows.", +// required = true) +// @PathParam("deviceType") +// @Size(max = 45) +// String deviceType, +// @ApiParam( +// name = "from", +// value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.", +// required = true) +// @QueryParam("from") long from, +// @ApiParam( +// name = "to", +// value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.", +// required = true) +// @QueryParam("to") long to); /** * Retrieve Geo alerts history for geo clusters */ - @GET - @Path("alerts/history") - @ApiOperation( - consumes = "application/json", - produces = "application/json", - httpMethod = "GET", - value = "Retrieve Geo alerts history for geo clusters", - notes = "Retrieving geo alert history of all defined alerts for geo clusters", - response = Response.class, - tags = "Geo Service Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK.", - response = Response.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.") - }), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid Device Identifiers found.", - response = Response.class), - @ApiResponse( - code = 401, - message = "Unauthorized. \n Unauthorized request."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error on retrieving stats", - response = Response.class) - }) - Response getGeoAlertsHistoryForGeoClusters( - @ApiParam( - name = "from", - value = "Get stats from what time", - required = true) - @QueryParam("from") long from, - @ApiParam( - name = "to", - value = "Get stats up to what time", - required = true) - @QueryParam("to") long to); +// @GET +// @Path("alerts/history") +// @ApiOperation( +// consumes = "application/json", +// produces = "application/json", +// httpMethod = "GET", +// value = "Retrieve Geo alerts history for geo clusters", +// notes = "Retrieving geo alert history of all defined alerts for geo clusters", +// response = Response.class, +// tags = "Geo Service Management", +// extensions = { +// @Extension(properties = { +// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") +// }) +// } +// ) +// @ApiResponses(value = { +// @ApiResponse( +// code = 200, +// message = "OK.", +// response = Response.class, +// responseHeaders = { +// @ResponseHeader( +// name = "Content-Type", +// description = "The content type of the body"), +// @ResponseHeader( +// name = "Last-Modified", +// description = "Date and time the resource was last modified.\n" + +// "Used by caches, or in conditional requests.") +// }), +// @ApiResponse( +// code = 400, +// message = "Bad Request. \n Invalid Device Identifiers found.", +// response = Response.class), +// @ApiResponse( +// code = 401, +// message = "Unauthorized. \n Unauthorized request."), +// @ApiResponse( +// code = 500, +// message = "Internal Server Error. \n Error on retrieving stats", +// response = Response.class) +// }) +// Response getGeoAlertsHistoryForGeoClusters( +// @ApiParam( +// name = "from", +// value = "Get stats from what time", +// required = true) +// @QueryParam("from") long from, +// @ApiParam( +// name = "to", +// value = "Get stats up to what time", +// required = true) +// @QueryParam("to") long to); /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java index f759ed13a9..52702536d1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java @@ -26,7 +26,7 @@ import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; +//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; @@ -280,19 +280,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { i++; } - if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type - , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()) - , Constants.DEFAULT_STREAM_VERSION, metaData - , null, payloadData)) { + // todo: amalka: commented data publishing +// if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type +// , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()) +// , Constants.DEFAULT_STREAM_VERSION, metaData +// , null, payloadData)) { return Response.status(Response.Status.OK).build(); - } else { - String msg = "Error occurred while publishing the event."; - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (DataPublisherConfigurationException e) { - String msg = "Error occurred while publishing the event."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); +// } else { +// String msg = "Error occurred while publishing the event."; +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); +// } +// } catch (DataPublisherConfigurationException e) { +// String msg = "Error occurred while publishing the event."; +// log.error(msg, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (DeviceAccessAuthorizationException e) { String msg = "Error occurred when checking for authorization"; log.error(msg, e); @@ -380,19 +381,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService { i++; } - if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type - , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()) - , Constants.DEFAULT_STREAM_VERSION, metaData - , null, payloadData)) { + // todo: amalka: commented data publishing +// if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type +// , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()) +// , Constants.DEFAULT_STREAM_VERSION, metaData +// , null, payloadData)) { return Response.status(Response.Status.OK).build(); - } else { - String msg = "Error occurred while publishing the event."; - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (DataPublisherConfigurationException e) { - String msg = "Error occurred while publishing the event."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); +// } else { +// String msg = "Error occurred while publishing the event."; +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); +// } +// } catch (DataPublisherConfigurationException e) { +// String msg = "Error occurred while publishing the event."; +// log.error(msg, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (DeviceAccessAuthorizationException e) { String msg = "Error occurred when checking for authorization"; log.error(msg, e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index 6c04581110..f5a7dacfd1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -4,18 +4,18 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.client.Stub; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; -import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; -import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; -import org.wso2.carbon.analytics.dataservice.commons.SortByField; -import org.wso2.carbon.analytics.dataservice.commons.SortType; -import org.wso2.carbon.analytics.datasource.commons.Record; -import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException; -import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; -import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable; -import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord; +//import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +//import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; +//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; +//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; +//import org.wso2.carbon.analytics.dataservice.commons.SortByField; +//import org.wso2.carbon.analytics.dataservice.commons.SortType; +//import org.wso2.carbon.analytics.datasource.commons.Record; +//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; +//import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException; +//import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; +//import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable; +//import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -81,49 +81,49 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe private static final String MQTT_CONTENT_VALIDATOR = "default"; private static final String TIMESTAMP_FIELD_NAME = "_timestamp"; - private static AnalyticsDataAPI getAnalyticsDataAPI() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - AnalyticsDataAPI analyticsDataAPI = - (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null); - if (analyticsDataAPI == null) { - String msg = "Analytics api service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return analyticsDataAPI; - } +// private static AnalyticsDataAPI getAnalyticsDataAPI() { +// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); +// AnalyticsDataAPI analyticsDataAPI = +// (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null); +// if (analyticsDataAPI == null) { +// String msg = "Analytics api service has not initialized."; +// log.error(msg); +// throw new IllegalStateException(msg); +// } +// return analyticsDataAPI; +// } - private static EventRecords getAllEventsForDevice(String tableName, String query, List sortByFields - , int offset, int limit) throws AnalyticsException { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI(); - EventRecords eventRecords = new EventRecords(); - int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query); - if (eventCount == 0) { - eventRecords.setCount(0); - } - List resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit, - sortByFields); - List recordIds = getRecordIds(resultEntries); - AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - eventRecords.setCount(eventCount); - List records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response); - records.sort(new Comparator() { - @Override public int compare(Record r1, Record r2) { - return Long.compare(r2.getTimestamp(), r1.getTimestamp()); - } - }); - eventRecords.setList(records); - return eventRecords; - } +// private static EventRecords getAllEventsForDevice(String tableName, String query, List sortByFields +// , int offset, int limit) throws AnalyticsException { +// int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); +// AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI(); +// EventRecords eventRecords = new EventRecords(); +// int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query); +// if (eventCount == 0) { +// eventRecords.setCount(0); +// } +// List resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit, +// sortByFields); +// List recordIds = getRecordIds(resultEntries); +// AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); +// eventRecords.setCount(eventCount); +// List records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response); +// records.sort(new Comparator() { +// @Override public int compare(Record r1, Record r2) { +// return Long.compare(r2.getTimestamp(), r1.getTimestamp()); +// } +// }); +// eventRecords.setList(records); +// return eventRecords; +// } - private static List getRecordIds(List searchResults) { - List ids = new ArrayList<>(); - for (SearchResultEntry searchResult : searchResults) { - ids.add(searchResult.getId()); - } - return ids; - } +// private static List getRecordIds(List searchResults) { +// List ids = new ArrayList<>(); +// for (SearchResultEntry searchResult : searchResults) { +// ids.add(searchResult.getId()); +// } +// return ids; +// } /** * Retrieves the stream definition from das for the given device type. @@ -195,65 +195,65 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe /** * Deploy Event Stream, Receiver, Publisher and Store Configuration. */ - @POST - @Path("/{type}") - @Override - public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType, - @QueryParam("skipPersist") boolean skipPersist, - @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants, - @Valid DeviceTypeEvent deviceTypeEvent) { - TransportType transportType = deviceTypeEvent.getTransportType(); - EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - try { - if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 || - deviceType == null || transportType == null || - !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { - String errorMessage = "Invalid Payload"; - log.error(errorMessage); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain); - String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION; - publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); - publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType); - if (!skipPersist) { - publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes); - } - publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType); - try { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); - if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { - publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); - publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType); - } - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - return Response.ok().build(); - } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (RemoteException e) { - log.error("Failed to connect with the remote services:" + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (UserStoreException e) { - log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (DeviceManagementException e) { - log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) { - log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType, - e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - } +// @POST +// @Path("/{type}") +// @Override +// public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType, +// @QueryParam("skipPersist") boolean skipPersist, +// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants, +// @Valid DeviceTypeEvent deviceTypeEvent) { +// TransportType transportType = deviceTypeEvent.getTransportType(); +// EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList(); +// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); +// try { +// if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 || +// deviceType == null || transportType == null || +// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { +// String errorMessage = "Invalid Payload"; +// log.error(errorMessage); +// return Response.status(Response.Status.BAD_REQUEST).build(); +// } +// String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain); +// String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION; +// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); +// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType); +// if (!skipPersist) { +// publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes); +// } +// publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType); +// try { +// PrivilegedCarbonContext.startTenantFlow(); +// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( +// MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); +// if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { +// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); +// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType); +// } +// } finally { +// PrivilegedCarbonContext.endTenantFlow(); +// } +// return Response.ok().build(); +// } catch (AxisFault e) { +// log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } catch (RemoteException e) { +// log.error("Failed to connect with the remote services:" + tenantDomain, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } catch (JWTClientException e) { +// log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } catch (UserStoreException e) { +// log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } catch (DeviceManagementException e) { +// log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) { +// log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType, +// e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } +// } /** * Delete device type specific artifacts from DAS. @@ -349,175 +349,175 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe /** * Returns device specific data for the give period of time. */ - @GET - @Path("/{type}/{deviceId}") - @Override - public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, - @QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset") - int offset, @QueryParam("limit") int limit) { - if (from == 0 || to == 0) { - String errorMessage = "Invalid values for from/to"; - return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); - } - if (limit == 0) { - String errorMessage = "Invalid values for offset/limit"; - return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); - } - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId - + " AND _timestamp : [" + fromDate + " TO " + toDate + "]"; - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); - try { - if (deviceType == null || - !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { - String errorMessage = "Invalid device type"; - log.error(errorMessage); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( - new DeviceIdentifier(deviceId, deviceType))) { - return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); - } - List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); - sortByFields.add(sortByField); - EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit); - return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); - } catch (AnalyticsException e) { - String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; - log.error(errorMsg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); - } catch (DeviceAccessAuthorizationException e) { - log.error(e.getErrorMessage(), e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (DeviceManagementException e) { - String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; - log.error(errorMsg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); - } - } +// @GET +// @Path("/{type}/{deviceId}") +// @Override +// public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, +// @QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset") +// int offset, @QueryParam("limit") int limit) { +// if (from == 0 || to == 0) { +// String errorMessage = "Invalid values for from/to"; +// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); +// } +// if (limit == 0) { +// String errorMessage = "Invalid values for offset/limit"; +// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); +// } +// String fromDate = String.valueOf(from); +// String toDate = String.valueOf(to); +// String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId +// + " AND _timestamp : [" + fromDate + " TO " + toDate + "]"; +// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); +// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); +// try { +// if (deviceType == null || +// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { +// String errorMessage = "Invalid device type"; +// log.error(errorMessage); +// return Response.status(Response.Status.BAD_REQUEST).build(); +// } +// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( +// new DeviceIdentifier(deviceId, deviceType))) { +// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); +// } +// List sortByFields = new ArrayList<>(); +// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); +// sortByFields.add(sortByField); +// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit); +// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); +// } catch (AnalyticsException e) { +// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; +// log.error(errorMsg); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); +// } catch (DeviceAccessAuthorizationException e) { +// log.error(e.getErrorMessage(), e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } catch (DeviceManagementException e) { +// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; +// log.error(errorMsg); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); +// } +// } /** * Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point. * Limit parameter needs to be zero or positive. */ - @GET - @Path("/last-known/{type}/{deviceId}") - @Override - public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) { - String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId; - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); - try { - if (deviceType == null || - !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { - String errorMessage = "Invalid device type"; - log.error(errorMessage); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( - new DeviceIdentifier(deviceId, deviceType))) { - return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); - } - List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); - sortByFields.add(sortByField); - if (limit == 0) { - EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1); - return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); - } else if (limit > 0) { - EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit); - return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); - } else { - String errorMessage = "Invalid limit value"; - return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); - } - } catch (AnalyticsException e) { - String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; - log.error(errorMsg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); - } catch (DeviceAccessAuthorizationException e) { - log.error(e.getErrorMessage(), e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (DeviceManagementException e) { - String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; - log.error(errorMsg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); - } - } +// @GET +// @Path("/last-known/{type}/{deviceId}") +// @Override +// public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) { +// String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId; +// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); +// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); +// try { +// if (deviceType == null || +// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { +// String errorMessage = "Invalid device type"; +// log.error(errorMessage); +// return Response.status(Response.Status.BAD_REQUEST).build(); +// } +// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( +// new DeviceIdentifier(deviceId, deviceType))) { +// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); +// } +// List sortByFields = new ArrayList<>(); +// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); +// sortByFields.add(sortByField); +// if (limit == 0) { +// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1); +// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); +// } else if (limit > 0) { +// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit); +// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); +// } else { +// String errorMessage = "Invalid limit value"; +// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); +// } +// } catch (AnalyticsException e) { +// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; +// log.error(errorMsg); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); +// } catch (DeviceAccessAuthorizationException e) { +// log.error(e.getErrorMessage(), e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); +// } catch (DeviceManagementException e) { +// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; +// log.error(errorMsg); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); +// } +// } /** * Returns the filterd device list. Devices are filterd using the paramter given and the timestamp of the record. * parameter should given as a range. */ - @GET - @Path("filter/{type}/{parameter}") - @Override - public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter, - @QueryParam("min") double min, @QueryParam("max") double max) { - String query; - Calendar c = java.util.Calendar.getInstance(); - long currentTimestamp = c.getTimeInMillis(); - long previousTimestamp = currentTimestamp - 300 * 1000; - String fromDate = String.valueOf(previousTimestamp); - String toDate = String.valueOf(currentTimestamp); - if (min != 0 & max != 0) { - query = parameter + " : [" + min + " TO " + max + "]" + - " AND _timestamp : [" + fromDate + " TO " + toDate + "]"; - } else { - String errorMessage = "The of range values need to be given"; - log.error(errorMessage); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); - try { - if (deviceType == null || - !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { - String errorMessage = "Invalid device type"; - log.error(errorMessage); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - - List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); - sortByFields.add(sortByField); - EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100); - List filterdEvents = eventRecords.getRecord(); - List uniqueFilterdEvents = new ArrayList(); - Set devices = new HashSet<>(); - - for (int i = 0; i < filterdEvents.size(); i++) { - String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId"); - if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( - new DeviceIdentifier(deviceid, deviceType))) { - devices.add(deviceid); - uniqueFilterdEvents.add(filterdEvents.get(i)); - } - } - - EventRecords filterdRecords = new EventRecords(); - filterdRecords.setList(uniqueFilterdEvents); - return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build(); - - } catch (AnalyticsException e) { - String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; - log.error(errorMsg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); - } catch (DeviceManagementException e) { - String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; - log.error(errorMsg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); - } catch (DeviceAccessAuthorizationException e) { - String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; - log.error(errorMsg); - return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); - } - } +// @GET +// @Path("filter/{type}/{parameter}") +// @Override +// public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter, +// @QueryParam("min") double min, @QueryParam("max") double max) { +// String query; +// Calendar c = java.util.Calendar.getInstance(); +// long currentTimestamp = c.getTimeInMillis(); +// long previousTimestamp = currentTimestamp - 300 * 1000; +// String fromDate = String.valueOf(previousTimestamp); +// String toDate = String.valueOf(currentTimestamp); +// if (min != 0 & max != 0) { +// query = parameter + " : [" + min + " TO " + max + "]" + +// " AND _timestamp : [" + fromDate + " TO " + toDate + "]"; +// } else { +// String errorMessage = "The of range values need to be given"; +// log.error(errorMessage); +// return Response.status(Response.Status.BAD_REQUEST).build(); +// } +// +// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); +// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); +// try { +// if (deviceType == null || +// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { +// String errorMessage = "Invalid device type"; +// log.error(errorMessage); +// return Response.status(Response.Status.BAD_REQUEST).build(); +// } +// +// List sortByFields = new ArrayList<>(); +// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); +// sortByFields.add(sortByField); +// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100); +// List filterdEvents = eventRecords.getRecord(); +// List uniqueFilterdEvents = new ArrayList(); +// Set devices = new HashSet<>(); +// +// for (int i = 0; i < filterdEvents.size(); i++) { +// String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId"); +// if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( +// new DeviceIdentifier(deviceid, deviceType))) { +// devices.add(deviceid); +// uniqueFilterdEvents.add(filterdEvents.get(i)); +// } +// } +// +// EventRecords filterdRecords = new EventRecords(); +// filterdRecords.setList(uniqueFilterdEvents); +// return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build(); +// +// } catch (AnalyticsException e) { +// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; +// log.error(errorMsg); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); +// } catch (DeviceManagementException e) { +// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; +// log.error(errorMsg); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); +// } catch (DeviceAccessAuthorizationException e) { +// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; +// log.error(errorMsg); +// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); +// } +// } private void publishEventReceivers(String streamNameWithVersion, TransportType transportType @@ -613,47 +613,47 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe } } - private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes) - throws RemoteException, UserStoreException, JWTClientException, - EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException { - EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub = - DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub(); - try { - AnalyticsTable analyticsTable = new AnalyticsTable(); - analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME); - analyticsTable.setStreamVersion(version); - analyticsTable.setTableName(streamName); - analyticsTable.setMergeSchema(false); - analyticsTable.setPersist(true); - AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1]; - int i = 0; - for (Attribute attribute : eventAttributes.getList()) { - AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord(); - analyticsTableRecord.setColumnName(attribute.getName()); - analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase()); - analyticsTableRecord.setFacet(false); - analyticsTableRecord.setIndexed(false); - analyticsTableRecord.setPersist(true); - analyticsTableRecord.setPrimaryKey(false); - analyticsTableRecord.setScoreParam(false); - analyticsTableRecords[i] = analyticsTableRecord; - i++; - } - AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord(); - analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE); - analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase()); - analyticsTableRecord.setFacet(false); - analyticsTableRecord.setIndexed(true); - analyticsTableRecord.setPersist(true); - analyticsTableRecord.setPrimaryKey(false); - analyticsTableRecord.setScoreParam(false); - analyticsTableRecords[i] = analyticsTableRecord; - analyticsTable.setAnalyticsTableRecords(analyticsTableRecords); - eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable); - } finally { - cleanup(eventStreamPersistenceAdminServiceStub); - } - } +// private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes) +// throws RemoteException, UserStoreException, JWTClientException, +// EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException { +// EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub = +// DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub(); +// try { +// AnalyticsTable analyticsTable = new AnalyticsTable(); +// analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME); +// analyticsTable.setStreamVersion(version); +// analyticsTable.setTableName(streamName); +// analyticsTable.setMergeSchema(false); +// analyticsTable.setPersist(true); +// AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1]; +// int i = 0; +// for (Attribute attribute : eventAttributes.getList()) { +// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord(); +// analyticsTableRecord.setColumnName(attribute.getName()); +// analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase()); +// analyticsTableRecord.setFacet(false); +// analyticsTableRecord.setIndexed(false); +// analyticsTableRecord.setPersist(true); +// analyticsTableRecord.setPrimaryKey(false); +// analyticsTableRecord.setScoreParam(false); +// analyticsTableRecords[i] = analyticsTableRecord; +// i++; +// } +// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord(); +// analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE); +// analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase()); +// analyticsTableRecord.setFacet(false); +// analyticsTableRecord.setIndexed(true); +// analyticsTableRecord.setPersist(true); +// analyticsTableRecord.setPrimaryKey(false); +// analyticsTableRecord.setScoreParam(false); +// analyticsTableRecords[i] = analyticsTableRecord; +// analyticsTable.setAnalyticsTableRecords(analyticsTableRecords); +// eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable); +// } finally { +// cleanup(eventStreamPersistenceAdminServiceStub); +// } +// } private void publishWebsocketPublisherDefinition(String streamNameWithVersion, String deviceType) throws RemoteException, UserStoreException, JWTClientException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java index b2c28d8f1e..9075dceddd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java @@ -25,14 +25,14 @@ import com.google.gson.Gson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; -import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; -import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; -import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; -import org.wso2.carbon.analytics.dataservice.commons.SortByField; -import org.wso2.carbon.analytics.dataservice.commons.SortType; -import org.wso2.carbon.analytics.datasource.commons.Record; -import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; +//import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +//import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; +//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; +//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; +//import org.wso2.carbon.analytics.dataservice.commons.SortByField; +//import org.wso2.carbon.analytics.dataservice.commons.SortType; +//import org.wso2.carbon.analytics.datasource.commons.Record; +//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; @@ -93,63 +93,63 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class); - @Path("stats/{deviceType}/{deviceId}") - @GET - @Consumes("application/json") - @Produces("application/json") - public Response getGeoDeviceStats(@PathParam("deviceId") String deviceId, - @PathParam("deviceType") String deviceType, - @QueryParam("from") long from, @QueryParam("to") long to) { - try { - if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) { - return Response.status(Response.Status.BAD_REQUEST.getStatusCode()) - .entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build(); - } - } catch (DeviceManagementException e) { - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build(); - } - String tableName = "IOT_PER_DEVICE_STREAM_GEO_FUSEDSPATIALEVENT"; - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - String query = "id:" + deviceId + " AND type:" + deviceType; - if (from != 0 || to != 0) { - query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]"; - } - try { - if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( - new DeviceIdentifier(deviceId, deviceType), - DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) { - return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); - } - List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField("timeStamp", SortType.ASC); - sortByFields.add(sortByField); - - // this is the user who initiates the request - String authorizedUser = MultitenantUtils.getTenantAwareUsername( - CarbonContext.getThreadLocalCarbonContext().getUsername()); - - try { - String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); - AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); - List searchResults = analyticsDataAPI.search(tenantId, tableName, query, - 0, - 100, - sortByFields); - List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(), - searchResults); - return Response.ok().entity(events).build(); - } catch (AnalyticsException | UserStoreException e) { - log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); - throw DeviceMgtUtil.buildBadRequestException( - Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); - } - } catch (DeviceAccessAuthorizationException e) { - log.error(e.getErrorMessage()); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); - } - } +// @Path("stats/{deviceType}/{deviceId}") +// @GET +// @Consumes("application/json") +// @Produces("application/json") +// public Response getGeoDeviceStats(@PathParam("deviceId") String deviceId, +// @PathParam("deviceType") String deviceType, +// @QueryParam("from") long from, @QueryParam("to") long to) { +// try { +// if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) { +// return Response.status(Response.Status.BAD_REQUEST.getStatusCode()) +// .entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build(); +// } +// } catch (DeviceManagementException e) { +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build(); +// } +// String tableName = "IOT_PER_DEVICE_STREAM_GEO_FUSEDSPATIALEVENT"; +// String fromDate = String.valueOf(from); +// String toDate = String.valueOf(to); +// String query = "id:" + deviceId + " AND type:" + deviceType; +// if (from != 0 || to != 0) { +// query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]"; +// } +// try { +// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( +// new DeviceIdentifier(deviceId, deviceType), +// DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) { +// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); +// } +// List sortByFields = new ArrayList<>(); +// SortByField sortByField = new SortByField("timeStamp", SortType.ASC); +// sortByFields.add(sortByField); +// +// // this is the user who initiates the request +// String authorizedUser = MultitenantUtils.getTenantAwareUsername( +// CarbonContext.getThreadLocalCarbonContext().getUsername()); +// +// try { +// String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); +// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); +// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); +// List searchResults = analyticsDataAPI.search(tenantId, tableName, query, +// 0, +// 100, +// sortByFields); +// List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(), +// searchResults); +// return Response.ok().entity(null).build(); +// } catch (AnalyticsException| UserStoreException e) { +// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); +// throw DeviceMgtUtil.buildBadRequestException( +// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); +// } +// } catch (DeviceAccessAuthorizationException e) { +// log.error(e.getErrorMessage()); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); +// } +// } @Path("stats/device-locations") @GET @@ -471,142 +471,142 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { } } - @Path("alerts/history/{deviceType}/{deviceId}") - @GET - @Consumes("application/json") - @Produces("application/json") - public Response getGeoAlertsHistory(@PathParam("deviceId") String deviceId, - @PathParam("deviceType") String deviceType, - @QueryParam("from") long from, @QueryParam("to") long to) { - String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS"; - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - String query = "id:" + deviceId + " AND type:" + deviceType; - if (from != 0 || to != 0) { - query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]"; - } - try { - if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( - new DeviceIdentifier(deviceId, deviceType), - DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) { - return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); - } - List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField("timeStamp", SortType.ASC); - sortByFields.add(sortByField); +// @Path("alerts/history/{deviceType}/{deviceId}") +// @GET +// @Consumes("application/json") +// @Produces("application/json") +// public Response getGeoAlertsHistory(@PathParam("deviceId") String deviceId, +// @PathParam("deviceType") String deviceType, +// @QueryParam("from") long from, @QueryParam("to") long to) { +// String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS"; +// String fromDate = String.valueOf(from); +// String toDate = String.valueOf(to); +// String query = "id:" + deviceId + " AND type:" + deviceType; +// if (from != 0 || to != 0) { +// query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]"; +// } +// try { +// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( +// new DeviceIdentifier(deviceId, deviceType), +// DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) { +// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); +// } +// List sortByFields = new ArrayList<>(); +// SortByField sortByField = new SortByField("timeStamp", SortType.ASC); +// sortByFields.add(sortByField); +// +// // this is the user who initiates the request +// String authorizedUser = MultitenantUtils.getTenantAwareUsername( +// CarbonContext.getThreadLocalCarbonContext().getUsername()); +// +// try { +// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); +// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); +// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); +// List searchResults = analyticsDataAPI.search(tenantId, tableName, query, +// 0, +// 100, +// sortByFields); +// List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(), +// searchResults); +// return Response.ok().entity(events).build(); +// } catch (AnalyticsException | UserStoreException e) { +// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); +// throw DeviceMgtUtil.buildBadRequestException( +// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); +// } +// } catch (DeviceAccessAuthorizationException e) { +// log.error(e.getErrorMessage()); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); +// } +// } - // this is the user who initiates the request - String authorizedUser = MultitenantUtils.getTenantAwareUsername( - CarbonContext.getThreadLocalCarbonContext().getUsername()); +// @Path("alerts/history") +// @GET +// @Consumes("application/json") +// @Produces("application/json") +// public Response getGeoAlertsHistoryForGeoClusters(@QueryParam("from") long from, @QueryParam("to") long to) { +// String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS"; +// String fromDate = String.valueOf(from); +// String toDate = String.valueOf(to); +// String query = ""; +// if (from != 0 || to != 0) { +// query = "timeStamp : [" + fromDate + " TO " + toDate + "]"; +// } +// try { +// List sortByFields = new ArrayList<>(); +// SortByField sortByField = new SortByField("timeStamp", SortType.ASC); +// sortByFields.add(sortByField); +// +// // this is the user who initiates the request +// String authorizedUser = MultitenantUtils.getTenantAwareUsername( +// CarbonContext.getThreadLocalCarbonContext().getUsername()); +// +// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); +// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); +// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); +// List searchResults = analyticsDataAPI.search(tenantId, tableName, query, +// 0, +// 100, +// sortByFields); +// List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(), +// searchResults); +// return Response.ok().entity(events).build(); +// +// } catch (AnalyticsException | UserStoreException e) { +// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); +// throw DeviceMgtUtil.buildBadRequestException( +// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); +// } +// } - try { - String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); - int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); - AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); - List searchResults = analyticsDataAPI.search(tenantId, tableName, query, - 0, - 100, - sortByFields); - List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(), - searchResults); - return Response.ok().entity(events).build(); - } catch (AnalyticsException | UserStoreException e) { - log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); - throw DeviceMgtUtil.buildBadRequestException( - Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); - } - } catch (DeviceAccessAuthorizationException e) { - log.error(e.getErrorMessage()); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); - } - } +// private List getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName, +// List columns, +// List searchResults) throws AnalyticsException { +// List ids = getIds(searchResults); +// List requiredColumns = (columns == null || columns.isEmpty()) ? null : columns; +// AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids); +// List records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response); +// Map eventBeanMap = getEventBeanKeyedWithIds(records); +// return getSortedEventBeans(eventBeanMap, searchResults); +// } - @Path("alerts/history") - @GET - @Consumes("application/json") - @Produces("application/json") - public Response getGeoAlertsHistoryForGeoClusters(@QueryParam("from") long from, @QueryParam("to") long to) { - String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS"; - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - String query = ""; - if (from != 0 || to != 0) { - query = "timeStamp : [" + fromDate + " TO " + toDate + "]"; - } - try { - List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField("timeStamp", SortType.ASC); - sortByFields.add(sortByField); +// private List getSortedEventBeans(Map eventBeanMap, +// List searchResults) { +// List sortedRecords = new ArrayList<>(); +// for (SearchResultEntry entry : searchResults) { +// sortedRecords.add(eventBeanMap.get(entry.getId())); +// } +// return sortedRecords; +// } - // this is the user who initiates the request - String authorizedUser = MultitenantUtils.getTenantAwareUsername( - CarbonContext.getThreadLocalCarbonContext().getUsername()); +// private Map getEventBeanKeyedWithIds(List records) { +// Map eventBeanMap = new HashMap<>(); +// for (Record record : records) { +// Event event = getEventBean(record); +// eventBeanMap.put(event.getId(), event); +// } +// return eventBeanMap; +// } - String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); - int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); - AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); - List searchResults = analyticsDataAPI.search(tenantId, tableName, query, - 0, - 100, - sortByFields); - List events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList(), - searchResults); - return Response.ok().entity(events).build(); +// private List getIds(List searchResults) { +// List ids = new ArrayList<>(); +// if (searchResults != null) { +// for (SearchResultEntry resultEntry : searchResults) { +// ids.add(resultEntry.getId()); +// } +// } +// return ids; +// } - } catch (AnalyticsException | UserStoreException e) { - log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); - throw DeviceMgtUtil.buildBadRequestException( - Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); - } - } - - private List getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName, - List columns, - List searchResults) throws AnalyticsException { - List ids = getIds(searchResults); - List requiredColumns = (columns == null || columns.isEmpty()) ? null : columns; - AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids); - List records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response); - Map eventBeanMap = getEventBeanKeyedWithIds(records); - return getSortedEventBeans(eventBeanMap, searchResults); - } - - private List getSortedEventBeans(Map eventBeanMap, - List searchResults) { - List sortedRecords = new ArrayList<>(); - for (SearchResultEntry entry : searchResults) { - sortedRecords.add(eventBeanMap.get(entry.getId())); - } - return sortedRecords; - } - - private Map getEventBeanKeyedWithIds(List records) { - Map eventBeanMap = new HashMap<>(); - for (Record record : records) { - Event event = getEventBean(record); - eventBeanMap.put(event.getId(), event); - } - return eventBeanMap; - } - - private List getIds(List searchResults) { - List ids = new ArrayList<>(); - if (searchResults != null) { - for (SearchResultEntry resultEntry : searchResults) { - ids.add(resultEntry.getId()); - } - } - return ids; - } - - private static Event getEventBean(Record record) { - Event eventBean = new Event(); - eventBean.setId(record.getId()); - eventBean.setTableName(record.getTableName()); - eventBean.setTimestamp(record.getTimestamp()); - eventBean.setValues(record.getValues()); - return eventBean; - } +// private static Event getEventBean(Record record) { +// Event eventBean = new Event(); +// eventBean.setId(record.getId()); +// eventBean.setTableName(record.getTableName()); +// eventBean.setTimestamp(record.getTimestamp()); +// eventBean.setValues(record.getValues()); +// return eventBean; +// } @Path("/geo-fence") @POST diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java index d326802c2a..16d4102176 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java @@ -64,8 +64,9 @@ public class CredentialManagementResponseBuilder { username = CarbonContext.getThreadLocalCarbonContext().getUsername(); userStoreManager.updateCredential(username, credentials.getNewPassword(), credentials.getOldPassword()); - DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, - PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + //todo:amalka +// DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, +// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); return Response.status(Response.Status.OK).entity("UserImpl password by username: " + username + " was successfully changed.").build(); } catch (UserStoreException e) { @@ -108,8 +109,9 @@ public class CredentialManagementResponseBuilder { new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build(); } userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword()); - DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, - PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + //todo:amalka +// DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, +// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); return Response.status(Response.Status.OK).entity("UserImpl password by username: " + username + " was successfully changed.").build(); } catch (UserStoreException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index 6a6f5daf88..fd8b0d9f59 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -46,14 +46,14 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; +//import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; @@ -171,7 +171,7 @@ public class DeviceMgtAPIUtils { private static KeyStore trustStore; private static char[] keyStorePassword; - private static IntegrationClientService integrationClientService; +// private static IntegrationClientService integrationClientService; private static MetadataManagementService metadataManagementService; private static OTPManagementService otpManagementService; @@ -374,22 +374,22 @@ public class DeviceMgtAPIUtils { } - public static IntegrationClientService getIntegrationClientService() { - if (integrationClientService == null) { - synchronized (DeviceMgtAPIUtils.class) { - if (integrationClientService == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null); - if (integrationClientService == null) { - String msg = "IntegrationClientService is not initialized"; - log.error(msg); - throw new IllegalStateException(msg); - } - } - } - } - return integrationClientService; - } +// public static IntegrationClientService getIntegrationClientService() { +// if (integrationClientService == null) { +// synchronized (DeviceMgtAPIUtils.class) { +// if (integrationClientService == null) { +// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); +// integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null); +// if (integrationClientService == null) { +// String msg = "IntegrationClientService is not initialized"; +// log.error(msg); +// throw new IllegalStateException(msg); +// } +// } +// } +// } +// return integrationClientService; +// } /** * Initializing and accessing method for OTPManagementService. @@ -626,17 +626,18 @@ public class DeviceMgtAPIUtils { return username; } - public static EventsPublisherService getEventPublisherService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - EventsPublisherService eventsPublisherService = - (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null); - if (eventsPublisherService == null) { - String msg = "Event Publisher service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return eventsPublisherService; - } + // todo: amalka: commented +// public static EventsPublisherService getEventPublisherService() { +// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); +// EventsPublisherService eventsPublisherService = +// (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null); +// if (eventsPublisherService == null) { +// String msg = "Event Publisher service has not initialized."; +// log.error(msg); +// throw new IllegalStateException(msg); +// } +// return eventsPublisherService; +// } public static String getStreamDefinition(String deviceType, String tenantDomain) { return STREAM_DEFINITION_PREFIX + tenantDomain + "." + deviceType.replace(" ", "."); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml index ed2ed21624..60db8782e9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index eca6c9a3b7..d896782b1a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -50,7 +50,7 @@ javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", com.fasterxml.jackson.annotation;version="${jackson-annotations.version}", - org.wso2.carbon.analytics.datasource.commons;version="${carbon.analytics.version.range}", + io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional, com.google.gson @@ -96,14 +96,14 @@ org.wso2.orbit.com.fasterxml.jackson.core jackson-annotations - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.api - - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.datasource.commons - + + + + + + + + com.google.code.gson gson diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index d9b34a770d..ae28f57c44 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -78,8 +78,8 @@ org.wso2.carbon.device.mgt.core.internal org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, javax.naming, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, @@ -90,7 +90,7 @@ org.wso2.carbon.core, org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.device.mgt.analytics.data.publisher.service, + org.wso2.carbon.user.api, org.wso2.carbon.user.core.*, org.wso2.carbon.registry.core.service, @@ -104,8 +104,8 @@ org.wso2.carbon.ndatasource.core, org.wso2.carbon.ntask.core.*, org.wso2.carbon.ntask.common, - org.apache.catalina, - org.apache.catalina.core, + + org.apache.commons.collections;version="${commons-collections.version.range}", org.wso2.carbon.email.sender.*, io.swagger.annotations.*;resolution:=optional, @@ -166,32 +166,32 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics.data.publisher - - - org.slf4j - slf4j-api - - - javax.servlet - javax.servlet-api - - - org.wso2.carbon.registry - org.wso2.carbon.registry.indexing - - - org.wso2.carbon.identity.framework - org.wso2.carbon.user.mgt - - - commons-lang - commons-lang - - - + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.carbon org.wso2.carbon.logging diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java index df5f030684..f29afccfcf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java @@ -53,6 +53,8 @@ public final class DeviceManagementConstants { public static final String SCOPES_FOR_TOKEN = "perm:device:operations perm:device:publish-event perm:windows:enroll"; public static final String IOT_GATEWAY_HOST = "iot.gateway.host"; public static final String IOT_GATEWAY_HTTPS_PORT = "iot.gateway.https.port"; + public static final String IOT_CORE_HOST = "iot.core.host"; + public static final String IOT_CORE_HTTPS_PORT = "iot.core.https.port"; public static final String APPLICATION_REGISTRATION_API_ENDPOINT = "/api-application-registration/register"; public static final String AUTHORIZATION_HEADER = "authorization"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index b152e65a84..396df0f61f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; +//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; @@ -178,9 +178,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { deviceInfo.getAvailableRAMMemory(), deviceInfo.isPluggedIn() }; - DeviceManagerUtil.getEventPublisherService().publishEvent( - DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload - ); +// DeviceManagerUtil.getEventPublisherService().publishEvent( +// DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload +// ); } } catch (TransactionManagementException e) { throw new DeviceDetailsMgtException("Transactional error occurred while adding the device information.", e); @@ -193,8 +193,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceDetailsMgtException("Error occurred while updating the last update timestamp of the " + "device", e); - } catch (DataPublisherConfigurationException e) { - throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); +// } catch (DataPublisherConfigurationException e) { +// throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -389,9 +389,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { deviceLocation.getBearing(), deviceLocation.getDistance() }; - DeviceManagerUtil.getEventPublisherService().publishEvent( - LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload - ); +// DeviceManagerUtil.getEventPublisherService().publishEvent( +// LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload +// ); } DeviceManagementDAOFactory.commitTransaction(); } catch (TransactionManagementException e) { @@ -403,9 +403,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } catch (DeviceManagementException e) { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceDetailsMgtException("Error occurred while getting the device information.", e); - } catch (DataPublisherConfigurationException e) { - DeviceManagementDAOFactory.rollbackTransaction(); - throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); +// } catch (DataPublisherConfigurationException e) { +// DeviceManagementDAOFactory.rollbackTransaction(); +// throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); } finally { DeviceManagementDAOFactory.closeConnection(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 7456111973..52a169ef61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -49,7 +49,7 @@ import org.apache.http.protocol.HTTP; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; +//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.common.ActivityPaginationRequest; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceEnrollmentInfoNotification; @@ -1964,20 +1964,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv operation.getStatus() != null ? operation.getStatus().toString() : null, operation.getOperationResponse() }; - DeviceManagerUtil.getEventPublisherService().publishEvent( - OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload - ); +// DeviceManagerUtil.getEventPublisherService().publishEvent( +// OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload +// ); } } } catch (DeviceManagementException e) { String msg = "Error occurred while reading configs."; log.error(msg, e); throw new OperationManagementException(msg, e); - } catch (DataPublisherConfigurationException e) { - String msg = "Error occurred while publishing event."; - log.error(msg, e); - throw new OperationManagementException(msg, e); - } + } //catch (DataPublisherConfigurationException e) { +// String msg = "Error occurred while publishing event."; +// log.error(msg, e); +// throw new OperationManagementException(msg, e); +// } } @Override @@ -2006,20 +2006,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv operation.getStatus() != null ? operation.getStatus().toString() : null, operation.getOperationResponse() }; - DeviceManagerUtil.getEventPublisherService().publishEvent( - OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload - ); +// DeviceManagerUtil.getEventPublisherService().publishEvent( +// OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload +// ); } } } catch (DeviceManagementException e) { String msg = "Error occurred while reading configs."; log.error(msg, e); throw new OperationManagementException(msg, e); - } catch (DataPublisherConfigurationException e) { - String msg = "Error occurred while publishing event."; - log.error(msg, e); - throw new OperationManagementException(msg, e); - } + } //catch (DataPublisherConfigurationException e) { +// String msg = "Error occurred while publishing event."; +// log.error(msg, e); +// throw new OperationManagementException(msg, e); +// } } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 7822754208..13593baf12 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -50,7 +50,7 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.caching.impl.CacheImpl; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; +//import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials; import org.wso2.carbon.device.mgt.common.ApplicationRegistration; import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException; @@ -595,17 +595,17 @@ public final class DeviceManagerUtil { return Caching.getCacheManagerFactory().getCacheManager(DeviceManagementConstants.DM_CACHE_MANAGER); } - public static EventsPublisherService getEventPublisherService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - EventsPublisherService eventsPublisherService = - (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null); - if (eventsPublisherService == null) { - String msg = "Event Publisher service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return eventsPublisherService; - } +// public static EventsPublisherService getEventPublisherService() { +// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); +// EventsPublisherService eventsPublisherService = +// (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null); +// if (eventsPublisherService == null) { +// String msg = "Event Publisher service has not initialized."; +// log.error(msg); +// throw new IllegalStateException(msg); +// } +// return eventsPublisherService; +// } /** * Retrieve EventConfigurationProviderService osgi service component diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 43353e1468..11c9471e76 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -178,15 +178,15 @@ javax.xml.stream, javax.xml.parsers;resolution:=optional, org.apache.commons.lang, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.w3c.dom, org.wso2.carbon.ndatasource.core, org.wso2.carbon.registry.core.service, org.wso2.carbon.utils.dbcreator, org.wso2.carbon.utils.multitenancy, org.wso2.carbon.device.mgt.core.service, - com.google.gson, - org.osgi.framework + com.google.gson org.wso2.carbon.device.mgt.extensions.pull.notification, org.wso2.carbon.device.mgt.extensions.pull.notification.* diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index b3bef7291a..744abc8ba1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -61,8 +61,8 @@ IoT Server Impl Bundle org.wso2.carbon.device.mgt.url.printer.internal - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, org.apache.axis2.*;version="${axis2.osgi.version.range}", org.wso2.carbon.core, diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 2d489faa9e..709e09d6bc 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -38,9 +38,9 @@ org.wso2.carbon.device.mgt.extensions org.wso2.carbon.device.mgt.ui org.wso2.carbon.device.mgt.api - org.wso2.carbon.device.mgt.analytics.data.publisher + org.wso2.carbon.device.mgt.url.printer - org.wso2.carbon.device.mgt.analytics.wsproxy + io.entgra.carbon.device.mgt.config.api diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml index 70cdb93216..65b62fca38 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml @@ -53,20 +53,20 @@ org.apache.axis2.*;version="${axis2.osgi.version.range}", org.apache.axiom.*; version="${axiom.osgi.version.range}", - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, org.wso2.carbon.context, org.wso2.carbon.utils.*, org.wso2.carbon.ndatasource.core, org.w3c.dom, - org.apache.velocity;version="${velocity.version}", - org.apache.velocity.app;version="${velocity.version}", - org.apache.velocity.context;version="${velocity.version}", - org.apache.velocity.exception;version="${velocity.version}", - org.apache.velocity.runtime.resource;version="${velocity.version}", - org.apache.velocity.runtime.resource.loader;version="${velocity.version}", + + + + + + org.apache.commons.io, org.apache.axis2.transport.mail, org.apache.commons.collections, @@ -149,10 +149,14 @@ org.apache.axis2.wso2 axis2 - - org.wso2.orbit.org.apache.velocity - velocity - + + + + + + + + commons-io.wso2 commons-io diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index ae46c74805..27de8ac3a6 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -87,10 +87,11 @@ org.wso2.carbon.device.mgt.oauth.extensions.* - org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}", + org.apache.commons.lang, org.apache.commons.logging, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.application.common;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.application.mgt.*;version="${carbon.identity.framework.version.range}", @@ -113,6 +114,10 @@ org.apache.oltu.oauth2.common.validators, org.apache.commons.lang3.tuple, + + + + diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java index 1153cb0561..4cc7881344 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java @@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator; import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; @@ -58,8 +57,8 @@ public class AccessTokenGrantHandler extends AbstractAuthorizationGrantHandler { } @Override - public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { - return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { + return super.validateScope(tokReqMsgCtx); } @Override diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java index 006317f179..f6560e76eb 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java @@ -20,14 +20,10 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler; import org.wso2.carbon.identity.oauth2.model.RequestParameter; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; /** * This sets up user with tenant aware username. @@ -38,8 +34,8 @@ public class ExtendedJWTGrantHandler extends JWTBearerGrantHandler { private static final String TENANT_DOMAIN_KEY = "tenantDomain"; @Override - public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { - return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { + return super.validateScope(tokReqMsgCtx); } @Override diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java index 5caededdaf..2193d2d3ed 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java @@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; @@ -35,8 +34,8 @@ public class ExtendedSAML2BearerGrantHandler extends SAML2BearerGrantHandler { private static Log log = LogFactory.getLog(ExtendedSAML2BearerGrantHandler.class); @Override - public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { - return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { + return super.validateScope(tokReqMsgCtx); } @Override diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index 4adb6539ab..abcf3859a3 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -109,8 +109,8 @@ org.apache.commons.httpclient, org.apache.commons.logging, org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.core.security, org.wso2.carbon.core.services.authentication, org.wso2.carbon.utils.multitenancy, diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index b793b016fa..7e171cd155 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -185,8 +185,8 @@ org.wso2.carbon.identity.jwt.client.extension.* - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.context, org.wso2.carbon.registry.core, org.wso2.carbon.registry.core.exceptions, diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index e10007a1ac..de175d9dba 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -33,8 +33,8 @@ http://wso2.org - org.wso2.carbon.identity.authenticator.backend.oauth - org.wso2.carbon.device.mgt.oauth.extensions + + org.wso2.carbon.identity.jwt.client.extension diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index 89a475e259..0c3d56ebc2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -35,9 +35,9 @@ Policy Decision Point Bundle org.wso2.carbon.policy.decision.point.internal - org.wso2.carbon.context.*; - org.osgi.framework, - org.osgi.service.component, + org.wso2.carbon.context;version="${carbon.kernel.version.range}", + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, org.wso2.carbon.policy.mgt.common.*, org.wso2.carbon.policy.mgt.core.*, diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index 20aab933b0..38acfd2d93 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -53,8 +53,8 @@ Policy Management Core Bundle org.wso2.carbon.policy.mgt.core.internal - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, javax.sql, javax.cache, diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index dd4d6e80c8..e047aa2278 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -39,7 +39,7 @@ org.wso2.carbon.policy.mgt.core org.wso2.carbon.policy.information.point org.wso2.carbon.policy.decision.point - org.wso2.carbon.complex.policy.decision.point + diff --git a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml index 1888660a53..6ae1098d84 100644 --- a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -53,8 +53,8 @@ org.apache.axis2.*;version="${axis2.osgi.version.range}", org.apache.axiom.*; version="${axiom.osgi.version.range}", - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, org.wso2.carbon.context, diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml index d4f72461b4..edc6bfedb2 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml @@ -87,20 +87,30 @@ - org.apache.cxf - cxf-rt-frontend-jaxws + org.springframework + spring-web provided org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http + cxf-bundle-jaxrs provided + + + + + + + + + + + + + + + javax.servlet javax.servlet-api diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/src/main/webapp/META-INF/webapp-classloading.xml index d0d7a01621..c0925583a3 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - CXF,Carbon + CXF3,Carbon diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml index d00ef252ad..783643a999 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml @@ -99,20 +99,35 @@ - org.apache.cxf - cxf-rt-frontend-jaxws + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.application.extension + provided + + + org.springframework + spring-web provided org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http + cxf-bundle-jaxrs provided + + + + + + + + + + + + + + + javax.servlet javax.servlet-api diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java index 49e0489de3..7bf0861f72 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java @@ -73,6 +73,7 @@ public class InvokerHandler extends HttpServlet { private static final long serialVersionUID = -6508020875358160165L; private static AuthData authData; private static String apiEndpoint; + private static String iotsCoreUrl; @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) { @@ -368,8 +369,14 @@ public class InvokerHandler extends HttpServlet { if (log.isDebugEnabled()) { log.debug("refreshing the token"); } + String iotsCorePort = System.getProperty("iot.core.https.port"); + if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { + iotsCorePort = System.getProperty("iot.core.http.port"); + } + iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + + HandlerConstants.COLON + iotsCorePort; HttpPost tokenEndpoint = new HttpPost( - apiEndpoint + HandlerConstants.API_COMMON_CONTEXT + HandlerConstants.TOKEN_ENDPOINT); + iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT); HttpSession session = req.getSession(false); if (session == null) { log.error("Couldn't find a session, hence it is required to login and proceed."); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index 133681355b..5a664552b8 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -35,7 +35,16 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; +import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; +import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; +import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; +import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; +import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; +import org.wso2.carbon.authenticator.stub.AuthenticationAdmin; +import org.wso2.carbon.authenticator.stub.Login; +import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -44,7 +53,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.ArrayList; import java.util.Base64; +import java.util.List; @MultipartConfig @WebServlet("/login") @@ -56,6 +67,7 @@ public class LoginHandler extends HttpServlet { private static String password; private static String gatewayUrl; private static String uiConfigUrl; + private static String keyManagerUrl; @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) { @@ -68,26 +80,37 @@ public class LoginHandler extends HttpServlet { httpSession = req.getSession(true); //setting session to expiry in 5 minutes httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT)); - + //todo: amalka do we need this remote call? JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); - HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); - apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() - .encodeToString((username + HandlerConstants.COLON + password).getBytes())); - apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, username, password)); - - ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); - - if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, clientAppResponse); - return; + List list = new ArrayList(); + for(int i=0; i < tags.size(); i++) { + list.add(tags.get(i).getAsString()); } - if (clientAppResponse.getCode() == HttpStatus.SC_CREATED && getTokenAndPersistInSession(req, resp, - clientAppResponse.getData(), scopes)) { + + String[] tagsAsStringArray = list.toArray(new String[list.size()]); + + String scopeString = HandlerUtil.getScopeString(scopes); + + if (scopeString != null) { + scopeString = scopeString.trim(); + } else { + scopeString = "default"; + } + + APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); + ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( + HandlerConstants.PUBLISHER_APPLICATION_NAME, + tagsAsStringArray, HandlerConstants.PRODUCTION_KEY, username, false, + ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, scopeString); + + if (apiApplicationKey != null && getTokenAndPersistInSession(apiApplicationKey.getConsumerKey(), + apiApplicationKey.getConsumerSecret(), req, resp, scopes)) { + log.info("tenantDomain : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + log.info("username : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); HandlerUtil.handleSuccess(resp, proxyResponse); @@ -100,6 +123,8 @@ public class LoginHandler extends HttpServlet { log.error("Error occurred while parsing the response. ", e); } catch (LoginException e) { log.error("Error occurred while getting token data. ", e); + } catch (APIManagerException e) { + log.error("Error occurred while creating application. ", e); } } @@ -107,19 +132,19 @@ public class LoginHandler extends HttpServlet { * Generates token from token endpoint and persists them inside the session * * @param req - {@link HttpServletRequest} - * @param clientAppResult - clientAppResult +// * @param clientAppResult - clientAppResult * @param scopes - scopes defied in the application-mgt.xml * @throws LoginException - login exception throws when getting token result */ - private boolean getTokenAndPersistInSession(HttpServletRequest req, HttpServletResponse resp, - String clientAppResult, JsonArray scopes) throws LoginException { + private boolean getTokenAndPersistInSession(String clientId, String clientSecret, HttpServletRequest req, + HttpServletResponse resp, JsonArray scopes) throws LoginException { JsonParser jsonParser = new JsonParser(); try { - JsonElement jClientAppResult = jsonParser.parse(clientAppResult); - if (jClientAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); - String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); - String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); +// JsonElement jClientAppResult = jsonParser.parse(clientAppResult); + if (clientId != null && clientSecret != null) { +// JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); +// String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); +// String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); String encodedClientApp = Base64.getEncoder() .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); @@ -171,12 +196,18 @@ public class LoginHandler extends HttpServlet { if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { iotsCorePort = System.getProperty("iot.core.http.port"); } + + String keyManagerPort = System.getProperty("iot.keymanager.https.port"); + username = req.getParameter("username"); password = req.getParameter("password"); gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + HandlerConstants.COLON + iotsCorePort + HandlerConstants.UI_CONFIG_ENDPOINT; + keyManagerUrl = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty("iot.keymanager.host") + HandlerConstants.COLON + keyManagerPort; + if (username == null || password == null) { String msg = "Invalid login request. Username or Password is not received for login request."; log.error(msg); @@ -193,7 +224,7 @@ public class LoginHandler extends HttpServlet { * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ private ProxyResponse getTokenResult(String encodedClientApp, JsonArray scopes) throws IOException { - HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); + HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); String scopeString = HandlerUtil.getScopeString(scopes); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java index 8ee6ec776b..641aa6d990 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -61,7 +61,7 @@ public class SsoLoginCallbackHandler extends HttpServlet { String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + HandlerConstants.COLON + iotsCorePort; - HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); + HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index 1ade046d43..23e76b81ae 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -101,7 +101,7 @@ public class SsoLoginHandler extends HttpServlet { */ private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { try { - File userMgtConf = new File("conf/user-mgt.xml"); + File userMgtConf = new File("repository/conf/user-mgt.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(userMgtConf); @@ -136,7 +136,7 @@ public class SsoLoginHandler extends HttpServlet { JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); // Register the client application - HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); + HttpPost apiRegEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.APP_REG_ENDPOINT); encodedAdminCredentials = Base64.getEncoder() .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes()); apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + @@ -262,7 +262,7 @@ public class SsoLoginHandler extends HttpServlet { * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ private ProxyResponse getTokenResult(String encodedClientApp) throws IOException { - HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); + HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java index 9686979d53..67b2834516 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java @@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.Base64; @MultipartConfig @WebServlet("/user") @@ -52,8 +53,8 @@ public class UserHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { String serverUrl = - req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); HttpSession httpSession = req.getSession(false); if (httpSession == null) { HandlerUtil.sendUnAuthorizeResponse(resp); @@ -68,26 +69,32 @@ public class UserHandler extends HttpServlet { String accessToken = authData.getAccessToken(); - HttpPost tokenEndpoint = new HttpPost(serverUrl + HandlerConstants.INTROSPECT_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, + HttpPost introspectionEndpoint = new HttpPost(serverUrl + HandlerConstants.INTROSPECT_ENDPOINT); + introspectionEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, + ContentType.APPLICATION_FORM_URLENCODED.toString()); + //todo:amalka + String username = "admin"; + String password = "admin"; + introspectionEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() + .encodeToString((username + HandlerConstants.COLON + password).getBytes())); + StringEntity introspectionPayload = new StringEntity("token=" + accessToken, ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); - ProxyResponse tokenStatus = HandlerUtil.execute(tokenEndpoint); + introspectionEndpoint.setEntity(introspectionPayload); + ProxyResponse introspectionStatus = HandlerUtil.execute(introspectionEndpoint); - if (tokenStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { + if (introspectionStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { log.error("Error occurred while invoking the API to get token status."); - HandlerUtil.handleError(resp, tokenStatus); + HandlerUtil.handleError(resp, introspectionStatus); return; } - String tokenData = tokenStatus.getData(); - if (tokenData == null) { + String introspectionData = introspectionStatus.getData(); + if (introspectionData == null) { log.error("Invalid token data is received."); - HandlerUtil.handleError(resp, tokenStatus); + HandlerUtil.handleError(resp, introspectionStatus); return; } JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenData); + JsonElement jTokenResult = jsonParser.parse(introspectionData); if (jTokenResult.isJsonObject()) { JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index 3d4255c0aa..bedf62385c 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -22,7 +22,7 @@ public class HandlerConstants { public static final String PUBLISHER_APPLICATION_NAME = "application-mgt-publisher"; public static final String APP_REG_ENDPOINT = "/api-application-registration/register"; public static final String UI_CONFIG_ENDPOINT = "/api/device-mgt-config/v1.0/configurations/ui-config"; - public static final String TOKEN_ENDPOINT = "/token"; + public static final String TOKEN_ENDPOINT = "/oauth2/token"; public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect"; public static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize"; public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/store/v0.12/applications/"; @@ -59,6 +59,7 @@ public class HandlerConstants { public static final String SCHEME_SEPARATOR = "://"; public static final String COLON = ":"; public static final String HTTP_PROTOCOL = "http"; + public static final String HTTPS_PROTOCOL = "https"; public static final String UNDERSCORE = "_"; public static final int INTERNAL_ERROR_CODE = 500; diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java index 4582468a0c..bc864c03ee 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java @@ -23,6 +23,8 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.sun.org.apache.xml.internal.serialize.OutputFormat; +import com.sun.org.apache.xml.internal.serialize.XMLSerializer; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,12 +38,12 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.apache.xml.serialize.OutputFormat; -import org.apache.xml.serialize.XMLSerializer; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; @@ -80,6 +82,7 @@ public class HandlerUtil { HandlerConstants.INTERNAL_ERROR_CODE)); return proxyResponse; } else { + int statusCode = response.getStatusLine().getStatusCode(); try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) { StringBuilder result = new StringBuilder(); @@ -400,4 +403,16 @@ public class HandlerUtil { return stringOutput; } + + public static APIManagementProviderService getAPIManagementProviderService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + APIManagementProviderService apiManagementProviderService = + (APIManagementProviderService) ctx.getOSGiService(APIManagementProviderService.class, null); + if (apiManagementProviderService == null) { + String msg = "API management provider service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return apiManagementProviderService; + } } diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/webapp/META-INF/webapp-classloading.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/webapp/META-INF/webapp-classloading.xml index cc5b3c66d7..9f50930c4f 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/webapp/META-INF/webapp-classloading.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/webapp/META-INF/webapp-classloading.xml @@ -31,5 +31,5 @@ Tomcat environment is the default and every webapps gets it even if they didn't specify it. e.g. If a webapps requires CXF, they will get both Tomcat and CXF. --> - Carbon + CXF3,Carbon diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 2d3df3e061..64e71e342d 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -63,15 +63,15 @@ javax.xml.bind.annotation, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.validation, - org.apache.catalina, - org.apache.catalina.connector, - org.apache.catalina.util, + + + org.apache.commons.logging, - org.apache.coyote, - org.apache.tomcat.util.buf, - org.apache.tomcat.util.http, - org.osgi.service.component, - org.osgi.framework, + + + + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.w3c.dom, org.wso2.carbon.context, org.wso2.carbon.core.util, @@ -79,7 +79,7 @@ org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}", org.wso2.carbon.identity.oauth2.*; version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}", - org.wso2.carbon.tomcat.ext.valves, + org.wso2.carbon.user.api, org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.tenant, @@ -106,8 +106,8 @@ org.apache.commons.pool.impl, org.apache.http.conn, org.apache.http.impl.conn, - javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}", - javax.xml.stream, + + org.apache.axiom.*; version="${axiom.osgi.version.range}", org.wso2.carbon.registry.core.*, org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}", diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index a934c7dc4c..401ad66f4e 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -107,9 +107,9 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.client:${project.version} - - org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.generated.client:${project.version} - + + + diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml index 067a6af7f8..ff54fb9cb8 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml @@ -24,7 +24,7 @@ - https://${iot.core.host}:${iot.core.https.port} + https://localhost:9443 true diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 201296d7d7..956fdf8d49 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -35,10 +35,10 @@ http://wso2.org - org.wso2.carbon.apimgt.integration.client.feature + org.wso2.carbon.apimgt.webapp.publisher.feature org.wso2.carbon.apimgt.application.extension.feature - org.wso2.carbon.apimgt.handler.server.feature + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml index ddeeaa5005..9e91286a79 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml @@ -30,7 +30,7 @@ - jdbc:h2:repository/database/WSO2DM_APPM_DB;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:./repository/database/WSO2DM_APPM_DB;DB_CLOSE_ON_EXIT=FALSE wso2carbon wso2carbon org.h2.Driver diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index bce727f0f2..29ce4363df 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -27,7 +27,6 @@ 4.0.0 - org.wso2.carbon.devicemgt certificate-mgt-feature 4.1.16-SNAPSHOT pom diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index 055fcd0a57..845938c469 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -43,34 +43,34 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics.data.publisher - - - org.wso2.carbon.registry - org.wso2.carbon.registry.indexing - - - org.wso2.carbon.analytics-common - org.wso2.carbon.event.receiver.stub - - - org.wso2.carbon.analytics-common - org.wso2.carbon.event.stream.stub - - - org.wso2.carbon.analytics-common - org.wso2.carbon.event.publisher.stub - - - org.wso2.carbon.analytics-common - org.wso2.carbon.event.stream.persistence.stub - - - org.wso2.orbit.org.scannotation - scannotation - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -127,27 +127,27 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:${carbon.device.mgt.version} - - org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.analytics.data.publisher:${carbon.device.mgt.version} - - - org.wso2.carbon.analytics-common:org.wso2.carbon.event.receiver.stub:${carbon.analytics.common.version} - - - org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.stub:${carbon.analytics.common.version} - - - org.wso2.carbon.analytics-common:org.wso2.carbon.event.publisher.stub:${carbon.analytics.common.version} - - - org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.persistence.stub:${carbon.analytics.common.version} - - - org.wso2.orbit.com.fasterxml.jackson.core:jackson-annotations:${jackson-annotations.version} - - - org.wso2.orbit.org.scannotation:scannotation:${scannotation.version} - + + + + + + + + + + + + + + + + + + + + + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml index 9e7e2fd601..23c74aaedb 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml @@ -20,7 +20,7 @@ - + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml index 5b8ee2f562..7d26b7b857 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml @@ -20,7 +20,7 @@ - + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index a0ba89e8b7..5bbf9e040b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -19,7 +19,7 @@ true - true + false application_management diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index 3c4216dfb9..0222243bf9 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -87,8 +87,8 @@ org.wso2.carbon.core.server:${carbon.kernel.version} - org.wso2.carbon.governance.metadata.server:${carbon.governance.version} - + + diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 28f576bf2e..1c4c45ab71 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -39,7 +39,7 @@ org.wso2.carbon.device.mgt.api.feature org.wso2.carbon.device.mgt.feature org.wso2.carbon.device.mgt.extensions.feature - org.wso2.carbon.device.mgt.analytics.feature + diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml index db6da06d04..6d17103c21 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml @@ -73,14 +73,14 @@ org.codehaus.woodstox wstx-asl - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics.data.publisher - - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.api - + + + + + + + + diff --git a/pom.xml b/pom.xml index 39f8ff4e85..bfa525b9df 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,6 @@ WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components - org.wso2 wso2 @@ -43,21 +42,23 @@ components/application-mgt components/policy-mgt components/certificate-mgt - components/webapp-authenticator-framework components/ui-request-interceptor components/transport-mgt features/device-mgt features/apimgt-extensions features/application-mgt features/policy-mgt - features/webapp-authenticator-framework features/certificate-mgt - features/oauth-extensions features/heartbeat-management features/ui-request-interceptor features/jwt-client features/device-mgt-extensions features/transport-mgt + + + + + @@ -245,16 +246,16 @@ org.wso2.carbon.apimgt.webapp.publisher ${carbon.device.mgt.version} - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.integration.client - ${carbon.device.mgt.version} - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.integration.generated.client - ${carbon.device.mgt.version} - + + + + + + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations @@ -286,11 +287,11 @@ org.wso2.carbon.device.mgt.analytics.data.publisher ${carbon.device.mgt.version} - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics.wsproxy - ${carbon.device.mgt.version} - + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.server.feature @@ -331,11 +332,11 @@ ${carbon.device.mgt.version} - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.handlers - ${carbon.device.mgt.version} - + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.device.application.mgt.server.feature @@ -832,7 +833,7 @@ org.wso2.carbon org.wso2.carbon.logging - ${carbon.kernel.version} + 4.4.9 org.wso2.carbon @@ -1153,17 +1154,17 @@ - - org.apache.cxf - cxf-rt-bindings-http - ${cxf.bindings.version} - - - org.codehaus.jra - jra - - - + + + + + + + + + + + org.apache.cxf cxf-rt-rs-extension-providers @@ -1347,11 +1348,21 @@ gson ${google.gson.version} + + org.wso2.orbit.com.squareup.okhttp + okhttp + ${okhttp.wso2.version} + com.squareup.okhttp3 okhttp ${squareup.okhttp3.version} + + org.wso2.orbit.com.squareup.okio + okio + ${okio.wso2.version} + com.squareup.okio okio @@ -1794,6 +1805,16 @@ commons-validator ${apache.validator.version} + + org.springframework + spring-web + ${spring-web.version} + + + org.apache.cxf + cxf-bundle-jaxrs + ${cxf-bundle-package.version} + @@ -2054,9 +2075,9 @@ 2.2.1 6.1.1 - 4.4.26 - [4.4.0, 5.0.0) - 1.5.4 + 4.6.1 + [4.6.0, 5.0.0) + 5.1.2 1.3 3.1.3 @@ -2097,16 +2118,16 @@ 4.7.15 - 5.11.148 - [5.2.0, 6.0.0) - 5.6.63 + 5.18.187 + [5.2.0, 7.0.0) + 6.4.111 5.4.6 - 1.0.10 - [1.0.10, 2.0.0) + 1.0.31 + [1.0.31, 2.0.0) [5.7.0, 6.0.0) - [5.2.0, 6.0.0) - [5.1.0, 6.0.0) + [5.2.0, 7.0.0) + [5.1.0, 7.0.0) 4.6.11 @@ -2131,8 +2152,8 @@ [2.6.0,3.0.0) - 6.2.201 - (6.0.0,7.0.0] + 9.0.5 + (6.0.0,10.0.0] 5.1.37 @@ -2142,20 +2163,20 @@ 2.1.23 - 4.6.28 - 4.6.8 - [4.4.8, 5.0.0) + 4.7.38 + ${carbon.registry.version} + [4.7.0, 5.0.0) - 3.2.0 - 2.5.11 + 3.3.6 + 1.1.wso2v1 1.9.0 - 1.52.0.wso2v1 - 1.52.0.wso2v2 - [1.52.0,1.60.0) + 1.60.0.wso2v1 + 1.60.0.wso2v1 + [1.52.0,1.70.0) 2.3.0.wso2v2 @@ -2166,7 +2187,9 @@ 3.0.0.wso2v1 1.3 2.3.1 - 3.8.1 + 4.6.0 + 4.2.0.wso2v1 + 2.4.0.wso2v1 1.13.0 9.3.1 1.1.1 @@ -2282,6 +2305,12 @@ 7.0.85 1.0 1.13.1 + + 5.1.2.RELEASE + 2.7.18 + + [1.6.0, 2.0.0) + [1.2.0,1.3.0) From 3ea79ecf77d59a2a48abf9202d67bc1508249072 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 10:51:19 +0530 Subject: [PATCH 21/49] cleaned up components/apimgt-extensions --- .../pom.xml | 32 - ...ApiApplicationRegistrationServiceImpl.java | 2 - .../pom.xml | 52 +- .../APIManagementProviderService.java | 5 +- .../APIManagementProviderServiceImpl.java | 66 +- ...ApplicationManagerExtensionDataHolder.java | 11 - ...ationManagerExtensionServiceComponent.java | 12 - .../pom.xml | 166 +- .../client/publisher/PublisherClient.java | 89 +- .../integration/client/store/StoreClient.java | 124 +- .../pom.xml | 268 +- .../src/main/resources/publisher-api.yaml | 13999 ++++------------ .../pom.xml | 220 +- .../publisher/APIPublisherServiceImpl.java | 8 - .../internal/APIPublisherDataHolder.java | 11 - .../APIPublisherServiceComponent.java | 12 - components/apimgt-extensions/pom.xml | 3 - pom.xml | 10 + 18 files changed, 3406 insertions(+), 11684 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index 9ec68e7315..c99c9d1988 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -48,42 +48,10 @@ cxf-bundle-jaxrs provided - - - - - - - - - - - - - - - - - - - - - - org.codehaus.jackson jackson-jaxrs - - - - - - - - - - commons-httpclient.wso2 commons-httpclient diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 96d3c8e059..702db64527 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -27,8 +27,6 @@ import org.wso2.carbon.apimgt.application.extension.api.util.RegistrationProfile import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; -//import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; -//import org.wso2.carbon.apimgt.integration.client.store.StoreClient; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 9e70ed3009..3f0f92602b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -51,23 +51,13 @@ org.wso2.carbon org.wso2.carbon.logging - - - - - - - - org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api - 9.0.5 org.wso2.carbon.apimgt org.wso2.carbon.apimgt.impl - 9.0.5 provided @@ -117,24 +107,30 @@ API Management Application Bundle org.wso2.carbon.apimgt.application.extension.internal - org.apache.commons.lang;version="[2.6,3)",org.apache.c - ommons.logging;version="[1.2,2)",org.json.simple,org.osgi.framework;v - ersion="${imp.package.version.osgi.framework}",org.osgi.service.component;version="${imp.package.version.osgi.service}",org.wso - 2.carbon.apimgt.api;version="[9.0,10)",org.wso2.carbon.apimgt.api.dto - ;version="[9.0,10)",org.wso2.carbon.apimgt.api.model;version="[9.0,10 - )",org.wso2.carbon.apimgt.application.extension.bean,org.wso2.carbon. - apimgt.application.extension.dto,org.wso2.carbon.apimgt.application.e - xtension.exception,org.wso2.carbon.apimgt.impl;version="[9.0,10)",org - .wso2.carbon.apimgt.impl.utils;version="[9.0,10)",org.wso2.carbon.con - text;version="[4.6,5)",org.wso2.carbon.device.mgt.core.config.ui;vers - ion="[4.1,5)",org.wso2.carbon.identity.jwt.client.extension,org.wso2. - carbon.identity.jwt.client.extension.dto,org.wso2.carbon.identity.jwt - .client.extension.exception,org.wso2.carbon.identity.jwt.client.exten - sion.service,org.wso2.carbon.registry.core.exceptions;version="[1.0,2 - )",org.wso2.carbon.registry.core.service;version="[1.0,2)",org.wso2.c - arbon.registry.indexing.service;version="[4.7,5)",org.wso2.carbon.use - r.api;version="[1.0,2)",org.wso2.carbon.user.core.service;version="[4 - .6,5)",org.wso2.carbon.user.core.tenant;version="[4.6,5)" + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.logging;version="[1.2,2)", + org.json.simple,org.osgi.framework;version="${imp.package.version.osgi.framework}", + org.osgi.service.component;version="${imp.package.version.osgi.service}", + org.wso2.carbon.apimgt.api;version="[9.0,10)", + org.wso2.carbon.apimgt.api.dto;version="[9.0,10)", + org.wso2.carbon.apimgt.api.model;version="[9.0,10)", + org.wso2.carbon.apimgt.application.extension.bean, + org.wso2.carbon.apimgt.application.extension.dto, + org.wso2.carbon.apimgt.application.extension.exception, + org.wso2.carbon.apimgt.impl;version="[9.0,10)", + org.wso2.carbon.apimgt.impl.utils;version="[9.0,10)", + org.wso2.carbon.context;version="[4.6,5)", + org.wso2.carbon.device.mgt.core.config.ui;version="[4.1,5)", + org.wso2.carbon.identity.jwt.client.extension, + org.wso2.carbon.identity.jwt.client.extension.dto, + org.wso2.carbon.identity.jwt.client.extension.exception, + org.wso2.carbon.identity.jwt.client.extension.service, + org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", + org.wso2.carbon.registry.core.service;version="[1.0,2)", + org.wso2.carbon.registry.indexing.service;version="[4.7,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.6,5)", + org.wso2.carbon.user.core.tenant;version="[4.6,5)" !org.wso2.carbon.apimgt.application.extension.internal, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java index 67fe9e2583..d1bc3911b6 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java @@ -21,8 +21,6 @@ package org.wso2.carbon.apimgt.application.extension; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; -//import org.wso2.carbon.apimgt.integration.client.store.StoreClient; -//import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; /** * This comprise on operation that is been done with api manager from CDMF. This service needs to be implemented in APIM. @@ -62,11 +60,10 @@ public interface APIManagementProviderService { * @param username to whom the application is created * @param isAllowedAllDomains application is allowed to all the tenants * @param validityTime validity period of the application -// * @param storeClient Specified store client + * @param scopes scopes * @return consumerkey and secrete of the created application. * @throws APIManagerException */ - ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], String keyType, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index cc385dff44..3b46ace15f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -18,20 +18,17 @@ package org.wso2.carbon.apimgt.application.extension; -//import feign.FeignException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.APIProvider; import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; import org.wso2.carbon.apimgt.api.model.Application; -import org.wso2.carbon.apimgt.api.model.KeyManagerConfiguration; import org.wso2.carbon.apimgt.api.model.SubscribedAPI; import org.wso2.carbon.apimgt.api.model.Subscriber; import org.wso2.carbon.apimgt.application.extension.bean.APIRegistrationProfile; @@ -43,17 +40,6 @@ import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; import org.wso2.carbon.apimgt.impl.APIAdminImpl; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerFactory; -//import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; -//import org.wso2.carbon.apimgt.integration.client.store.StoreClient; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIInfo; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIList; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Application; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationInfo; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKey; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKeyGenerateRequest; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationList; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Subscription; -//import org.wso2.carbon.apimgt.integration.generated.client.store.model.SubscriptionList; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; @@ -66,7 +52,6 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -78,66 +63,34 @@ import java.util.Set; public class APIManagementProviderServiceImpl implements APIManagementProviderService { private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class); - private static final String CONTENT_TYPE = "application/json"; - private static final int MAX_API_PER_TAG = 200; - private static final String APP_TIER_TYPE = "application"; public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); @Override public boolean isTierLoaded() { -// StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() -// .getStoreClient(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() - .getTenantDomain(); -// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); -// try { + + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + try { APIUtil.getTiers(APIConstants.TIER_APPLICATION_TYPE, tenantDomain); + return true; } catch (APIManagementException e) { log.error("APIs not ready", e); } - // storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, -// APP_TIER_TYPE, -// tenantDomain, CONTENT_TYPE, null, null); - return true; -// } catch (FeignException e) { -// log.error("Feign Exception", e); -// if (e.status() == 401) { -// OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); -// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); -// oAuthRequestInterceptor.removeToken(username, tenantDomain); -// try { -// storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, -// APP_TIER_TYPE, tenantDomain, CONTENT_TYPE, null, null); -// } catch (FeignException ex) { -// log.error("Invalid Attempt : " + ex); -// } -// } -// } catch (Exception e) { -// log.error("APIs not ready", e); -// } -// return false; + + return false; } @Override public void removeAPIApplication(String applicationName, String username) throws APIManagerException { -// StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() -// .getStoreClient(); -// ApplicationList applicationList = storeClient.getApplications() -// .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); Application application = apiConsumer.getApplicationsByName(username, applicationName, ""); if (application != null) { -// ApplicationInfo applicationInfo = applicationList.getList().get(0); -// storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), -// null, null); apiConsumer.removeApplication(application, username); } } catch (APIManagementException e) { - //todo:amalka - e.printStackTrace(); + throw new APIManagerException("Failed to remove api application : " + applicationName, e); } @@ -148,9 +101,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe */ @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String scopes) throws APIManagerException { + String keyType, String username, boolean isAllowedAllDomains, String validityTime, String scopes) + throws APIManagerException { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); if (StringUtils.isEmpty(username)) { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 368fda3a3b..26f0320974 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,7 +18,6 @@ package org.wso2.carbon.apimgt.application.extension.internal; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; -//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; @@ -35,7 +34,6 @@ public class APIApplicationManagerExtensionDataHolder { private TenantManager tenantManager; private TenantRegistryLoader tenantRegistryLoader; private TenantIndexingLoader indexLoader; -// private IntegrationClientService integrationClientService; private JWTClientManagerService jwtClientManagerService; private APIApplicationManagerExtensionDataHolder() { @@ -94,15 +92,6 @@ public class APIApplicationManagerExtensionDataHolder { return indexLoader; } -// public IntegrationClientService getIntegrationClientService() { -// return integrationClientService; -// } -// -// public void setIntegrationClientService( -// IntegrationClientService integrationClientService) { -// this.integrationClientService = integrationClientService; -// } - public JWTClientManagerService getJwtClientManagerService() { if (jwtClientManagerService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 4d98527956..d2c675c253 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -23,7 +23,6 @@ import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext;; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; -//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; @@ -91,17 +90,6 @@ public class APIApplicationManagerExtensionServiceComponent { APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null); } -// protected void setIntegrationClientService(IntegrationClientService integrationClientService) { -// if (integrationClientService != null && log.isDebugEnabled()) { -// log.debug("integrationClientService initialized"); -// } -// APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService); -// } -// -// protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { -// APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null); -// } - /** * Sets Realm Service. * diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 0784f282aa..eeddf628a5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -47,39 +47,46 @@ org.wso2.carbon.apimgt.integration.client.*, !org.wso2.carbon.apimgt.integration.client.internal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + org.osgi.framework, + org.osgi.service.component, + feign, + feign.codec, + feign.auth, + feign.gson, + feign.slf4j, + org.wso2.carbon.apimgt.integration.generated.client.publisher.api, + org.wso2.carbon.apimgt.integration.generated.client.store.api, + javax.xml.bind, + javax.xml.bind.annotation, + javax.xml.parsers;resolution:=optional, + org.apache.commons.logging, + org.w3c.dom, + org.wso2.carbon.context, + org.wso2.carbon.identity.jwt.client.*, + org.wso2.carbon.user.api, + org.wso2.carbon.utils, + com.fasterxml.jackson.annotation, + io.swagger.annotations, + org.wso2.carbon.core.util, + javax.xml, + org.wso2.carbon.base, + javax.net.ssl, + org.apache.commons.lang, + android.util;resolution:=optional, + javax.annotation;resolution:=optional, + javax.net;resolution:=optional, + javax.security.auth.x500;resolution:=optional, + javax.crypto;resolution:=optional, + javax.crypto.spec;resolution:=optional + + + jsr311-api, + feign-jaxrs, + feign-okhttp, + okhttp, + okio + @@ -113,60 +120,55 @@ - - - - - - - - + + com.squareup.okhttp3 + okhttp + + + com.squareup.okio + okio + io.github.openfeign feign-okhttp - - io.github.openfeign - feign-slf4j - 10.7.2 - - - - - - - - - - - - - - - - - - - - - + + org.wso2.carbon + org.wso2.carbon.logging + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + com.google.code.gson + gson + + + javax.ws.rs + jsr311-api + - - - - - - - - + + io.swagger + swagger-annotations + + + junit + junit + io.github.openfeign feign-core - - - - + + io.github.openfeign + feign-jackson + io.github.openfeign feign-jaxrs @@ -176,10 +178,10 @@ feign-gson - - - - + + org.testng + testng + org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java index 73a4234a91..3887d59c66 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java @@ -27,8 +27,7 @@ import feign.slf4j.Slf4jLogger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApIsApi; -import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApiLifecycleApi; +import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.*; import org.wso2.carbon.core.util.Utils; /** @@ -37,15 +36,13 @@ import org.wso2.carbon.core.util.Utils; public class PublisherClient { private static final Log log = LogFactory.getLog(PublisherClient.class); - private ApIsApi apIsApi = null; - private ApiLifecycleApi apiLifecycleApi = null; -// private APIIndividualApi api = null; -// private APICollectionApi apis = null; -// private DocumentIndividualApi document = null; -// private ApplicationIndividualApi application = null; -// private EnvironmentCollectionApi environments = null; -// private SubscriptionApi subscriptions = null; -// private ThrottlingTierCollectionApi tiers = null; + private APIIndividualApi api = null; + private APICollectionApi apis = null; + private DocumentIndividualApi document = null; + private ApplicationIndividualApi application = null; + private EnvironmentCollectionApi environments = null; + private SubscriptionCollectionApi subscriptions = null; + private ThrottlingTierCollectionApi tiers = null; /** @@ -60,50 +57,40 @@ public class PublisherClient { .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint()); - apIsApi = builder.target(ApIsApi.class, basePath); - apiLifecycleApi = builder.target(ApiLifecycleApi.class, basePath); -// api = builder.target(APIIndividualApi.class, basePath); -// apis = builder.target(APICollectionApi.class, basePath); -// document = builder.target(DocumentIndividualApi.class, basePath); -// application = builder.target(ApplicationIndividualApi.class, basePath); -// environments = builder.target(EnvironmentCollectionApi.class, basePath); -// subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); -// tiers = builder.target(ThrottlingTierCollectionApi.class, basePath); + api = builder.target(APIIndividualApi.class, basePath); + apis = builder.target(APICollectionApi.class, basePath); + document = builder.target(DocumentIndividualApi.class, basePath); + application = builder.target(ApplicationIndividualApi.class, basePath); + environments = builder.target(EnvironmentCollectionApi.class, basePath); + subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); + tiers = builder.target(ThrottlingTierCollectionApi.class, basePath); } - public ApIsApi getApIsApi() { - return apIsApi; + public APIIndividualApi getApi() { + return api; } - public ApiLifecycleApi getApiLifecycleApi() { - return apiLifecycleApi; + public APICollectionApi getApis() { + return apis; } - // public APIIndividualApi getApi() { -// return api; -// } -// -// public APICollectionApi getApis() { -// return apis; -// } -// -// public DocumentIndividualApi getDocument() { -// return document; -// } -// -// public ApplicationIndividualApi getApplication() { -// return application; -// } -// -// public EnvironmentCollectionApi getEnvironments() { -// return environments; -// } -// -// public SubscriptionCollectionApi getSubscriptions() { -// return subscriptions; -// } -// -// public ThrottlingTierCollectionApi getTiers() { -// return tiers; -// } + public DocumentIndividualApi getDocument() { + return document; + } + + public ApplicationIndividualApi getApplication() { + return application; + } + + public EnvironmentCollectionApi getEnvironments() { + return environments; + } + + public SubscriptionCollectionApi getSubscriptions() { + return subscriptions; + } + + public ThrottlingTierCollectionApi getTiers() { + return tiers; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java index 5d8a46d586..db751f204e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java @@ -39,17 +39,16 @@ import java.util.concurrent.TimeUnit; public class StoreClient { private static final org.apache.commons.logging.Log log = LogFactory.getLog(StoreClient.class); - private ApplicationsApi applicationsApi = null; -// private APICollectionApi apis = null; -// private ApIsApi individualApi = null; -// private ApplicationsApi applications = null; -// private ApplicationIndividualApi individualApplication = null; -// private SubscriptionCollectionApi subscriptions = null; -// private SubscriptionIndividualApi individualSubscription = null; -// private SubscriptionMultitpleApi subscriptionMultitpleApi = null; -// private ThrottlingTierIndividualApi individualTier = null; -// private TagsApi tags = null; -// private ThrottlingTierCollectionApi tiers = null; + private APICollectionApi apis = null; + private APIIndividualApi individualApi = null; + private ApplicationCollectionApi applications = null; + private ApplicationIndividualApi individualApplication = null; + private SubscriptionCollectionApi subscriptions = null; + private SubscriptionIndividualApi individualSubscription = null; + private SubscriptionMultitpleApi subscriptionMultitpleApi = null; + private ThrottlingTierIndividualApi individualTier = null; + private TagCollectionApi tags = null; + private ThrottlingTierCollectionApi tiers = null; public StoreClient(RequestInterceptor requestInterceptor) { @@ -61,59 +60,58 @@ public class StoreClient { .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint()); - applicationsApi = builder.target(ApplicationsApi.class, basePath); -// apis = builder.target(APICollectionApi.class, basePath); -// individualApi = builder.target(ApIsApi.class, basePath); -// applications = builder.target(ApplicationCollectionApi.class, basePath); -// individualApplication = builder.target(ApplicationIndividualApi.class, basePath); -// subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); -// individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath); -// subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath); -// tags = builder.target(TagCollectionApi.class, basePath); -// individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath); -// tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1)) -// .options(new Request.Options(10000, 5000)) -// .target(ThrottlingTierCollectionApi.class, basePath); + apis = builder.target(APICollectionApi.class, basePath); + individualApi = builder.target(APIIndividualApi.class, basePath); + applications = builder.target(ApplicationCollectionApi.class, basePath); + individualApplication = builder.target(ApplicationIndividualApi.class, basePath); + subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); + individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath); + subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath); + tags = builder.target(TagCollectionApi.class, basePath); + individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath); + tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1)) + .options(new Request.Options(10000, 5000)) + .target(ThrottlingTierCollectionApi.class, basePath); } -// public APICollectionApi getApis() { -// return apis; -// } -// -// public APIIndividualApi getIndividualApi() { -// return individualApi; -// } -// -// public ApplicationCollectionApi getApplications() { -// return applications; -// } -// -// public ApplicationIndividualApi getIndividualApplication() { -// return individualApplication; -// } -// -// public SubscriptionCollectionApi getSubscriptions() { -// return subscriptions; -// } -// -// public SubscriptionIndividualApi getIndividualSubscription() { -// return individualSubscription; -// } -// -// public ThrottlingTierIndividualApi getIndividualTier() { -// return individualTier; -// } -// -// public TagCollectionApi getTags() { -// return tags; -// } -// -// public ThrottlingTierCollectionApi getTiers() { -// return tiers; -// } -// -// public SubscriptionMultitpleApi getSubscriptionMultitpleApi() { -// return subscriptionMultitpleApi; -// } + public APICollectionApi getApis() { + return apis; + } + + public APIIndividualApi getIndividualApi() { + return individualApi; + } + + public ApplicationCollectionApi getApplications() { + return applications; + } + + public ApplicationIndividualApi getIndividualApplication() { + return individualApplication; + } + + public SubscriptionCollectionApi getSubscriptions() { + return subscriptions; + } + + public SubscriptionIndividualApi getIndividualSubscription() { + return individualSubscription; + } + + public ThrottlingTierIndividualApi getIndividualTier() { + return individualTier; + } + + public TagCollectionApi getTags() { + return tags; + } + + public ThrottlingTierCollectionApi getTiers() { + return tiers; + } + + public SubscriptionMultitpleApi getSubscriptionMultitpleApi() { + return subscriptionMultitpleApi; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index cc300b8014..22c399e5b7 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -26,59 +26,61 @@ http://wso2.org - - - org.openapitools - openapi-generator-maven-plugin - 5.0.0 - - - process-resources - publisher - - generate - - - ${project.basedir}/src/main/resources/publisher-api.yaml - java - - ${project.artifactId}.publisher.api - ${project.artifactId}.publisher.model - - - - - process-resources - store - - generate - - - ${project.basedir}/src/main/resources/devportal-api.yaml - java - - ${project.artifactId}.store.api - ${project.artifactId}.store.model - - - - - + + + io.swagger + swagger-codegen-maven-plugin + 2.2.1 + + + process-resources + publisher + + generate + + + ${project.basedir}/src/main/resources/publisher-api.yaml + java + + ${project.artifactId}.publisher.api + ${project.artifactId}.publisher.model + + feign + + + + process-resources + store + + generate + + + ${project.basedir}/src/main/resources/store-api.yaml + java + + ${project.artifactId}.store.api + ${project.artifactId}.store.model + + feign + + + + com.google.code.maven-replacer-plugin replacer 1.5.2 - + process-resources - replace-for-openapi-genenerated-code-publisher + replace-for-swagger-genenerated-code-publisher replace - ${project.basedir}/target/generated-sources/openapi/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java + ${project.basedir}/target/generated-sources/swagger/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java CURRENT_TENANT @@ -113,33 +115,28 @@ org.wso2.carbon.apimgt.integration.generated.client.store.api.*, org.wso2.carbon.apimgt.integration.generated.client.store.model.* - - com.google.gson;version="[2.8,3)", - com.google.gson.annotations;version="[2.8,3)", - com.google.gson.internal.bind.util, - com.google.gson.reflect;version="[2.8,3)", - com.google.gson.stream;version="[2.8,3)", - io.gsonfire;version="[1.8,2)", - io.swagger.annotations;version="[1.5,2)", - javax.annotation;version="[3.0,4)", - javax.net.ssl, - okhttp3, - okhttp3.internal.http, - okhttp3.internal.tls, - okhttp3.logging, - okio, - org.apache.oltu.oauth2.client;version="[1.0,2)", - org.apache.oltu.oauth2.client.request;version="[1.0,2)", - org.apache.oltu.oauth2.client.response;version="[1.0,2)", - org.apache.oltu.oauth2.common.exception;version="[1.0,2)", - org.apache.oltu.oauth2.common.message.types;version="[1.0,2)", - org.threeten.bp;version="[1.5,2)", - org.threeten.bp.format;version="[1.5,2)", - org.threeten.bp.temporal;version="[1.5,2)", - org.wso2.carbon.apimgt.integration.generated.client.publisher.model, - org.wso2.carbon.apimgt.integration.generated.client.store.model - - + + feign;version="${io.github.openfeign.version.range}", + feign.jackson;version="${io.github.openfeign.version.range}", + feign.codec;version="${io.github.openfeign.version.range}", + feign.auth;version="${io.github.openfeign.version.range}", + feign.gson;version="${io.github.openfeign.version.range}", + feign.slf4j;version="${io.github.openfeign.version.range}", + com.google.gson, + com.fasterxml.jackson.core;resolution:=optional, + com.fasterxml.jackson.annotation, + com.fasterxml.jackson.databind;resolution:=optional, + io.swagger.annotations, + javax.net.ssl, + com.fasterxml.jackson.datatype.joda;resolution:=optional, + org.apache.oltu.oauth2.client.*;resolution:=optional, + org.apache.oltu.oauth2.common.*;resolution:=optional, + org.junit;resolution:=optional, + + + jsr311-api, + feign-jaxrs + @@ -148,105 +145,60 @@ - - - io.swagger.core.v3 - swagger-annotations - 2.1.7 - - - com.google.code.gson gson - 2.8.5 - - - - + + javax.ws.rs + jsr311-api + io.swagger swagger-annotations - - com.squareup.okhttp3 - okhttp - 4.9.1 - - - - org.apache.oltu.oauth2 - org.apache.oltu.oauth2.client - 1.0.1 - - - - com.squareup.okhttp3 - logging-interceptor - 4.9.1 - - - - org.threeten - threetenbp - 1.5.0 - - - - io.gsonfire - gson-fire - 1.8.5 - - - io.swagger.parser.v3 - swagger-parser - 2.0.25 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + junit + junit + + + io.github.openfeign + feign-core + + + io.github.openfeign + feign-jackson + + + io.github.openfeign + feign-jaxrs + + + io.github.openfeign + feign-gson + + + org.testng + testng + + + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + + + io.github.openfeign + feign-slf4j + + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-databind + ${jackson-databind.version} + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + true diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml index 76fdb6f92d..b2068857a7 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml @@ -1,122 +1,115 @@ -# Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -# -# Licensed 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. -################################################################################ -openapi: 3.0.1 + +swagger: '2.0' +###################################################### +# Prolog +###################################################### info: - title: WSO2 API Manager - Publisher API + version: "0.12.0" + title: "WSO2 API Manager - Publisher API" description: | - This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. + This specifies a **RESTful API** for WSO2 **API Manager** - Publisher. - # Authentication - Our REST APIs are protected using OAuth2 and access control is achieved through scopes. Before you start invoking - the the API you need to obtain an access token with the required scopes. This guide will walk you through the steps - that you will need to follow to obtain an access token. - First you need to obtain the consumer key/secret key pair by calling the dynamic client registration (DCR) endpoint. You can add your preferred grant types - in the payload. A Sample payload is shown below. - ``` - { - "callbackUrl":"www.google.lk", - "clientName":"rest_api_publisher", - "owner":"admin", - "grantType":"client_credentials password refresh_token", - "saasApp":true - } - ``` - Create a file (payload.json) with the above sample payload, and use the cURL shown bellow to invoke the DCR endpoint. Authorization header of this should contain the - base64 encoded admin username and password. - **Format of the request** - ``` - curl -X POST -H "Authorization: Basic Base64(admin_username:admin_password)" -H "Content-Type: application/json" - \ -d @payload.json https://:/client-registration/v0.17/register - ``` - **Sample request** - ``` - curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" - \ -d @payload.json https://localhost:9443/client-registration/v0.17/register - ``` - Following is a sample response after invoking the above curl. - ``` - { - "clientId": "fOCi4vNJ59PpHucC2CAYfYuADdMa", - "clientName": "rest_api_publisher", - "callBackURL": "www.google.lk", - "clientSecret": "a4FwHlq0iCIKVs2MPIIDnepZnYMa", - "isSaasApplication": true, - "appOwner": "admin", - "jsonString": "{\"grant_types\":\"client_credentials password refresh_token\",\"redirect_uris\":\"www.google.lk\",\"client_name\":\"rest_api123\"}", - "jsonAppAttribute": "{}", - "tokenType": null - } - ``` - Next you must use the above client id and secret to obtain the access token. - We will be using the password grant type for this, you can use any grant type you desire. - You also need to add the proper **scope** when getting the access token. All possible scopes for publisher REST API can be viewed in **OAuth2 Security** section - of this document and scope for each resource is given in **authorization** section of resource documentation. - Following is the format of the request if you are using the password grant type. - ``` - curl -k -d "grant_type=password&username=&password=" - \ -H "Authorization: Basic base64(cliet_id:client_secret)" - \ https://:/token - ``` - **Sample request** - ``` - curl https://localhost:8243/token -k \ - -H "Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h" \ - -d "grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create" - ``` - Shown below is a sample response to the above request. - ``` - { - "access_token": "e79bda48-3406-3178-acce-f6e4dbdcbb12", - "refresh_token": "a757795d-e69f-38b8-bd85-9aded677a97c", - "scope": "apim:api_create apim:api_view", - "token_type": "Bearer", - "expires_in": 3600 - } - ``` - Now you have a valid access token, which you can use to invoke an API. - Navigate through the API descriptions to find the required API, obtain an access token as described above and invoke the API with the authentication header. - If you use a different authentication mechanism, this process may change. - - # Try out in Postman - If you want to try-out the embedded postman collection with "Run in Postman" option, please follow the guidelines listed below. - * All of the OAuth2 secured endpoints have been configured with an Authorization Bearer header with a parameterized access token. Before invoking any REST API resource make sure you run the `Register DCR Application` and `Generate Access Token` requests to fetch an access token with all required scopes. - * Make sure you have an API Manager instance up and running. - * Update the `basepath` parameter to match the hostname and port of the APIM instance. - - [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/a09044034b5c3c1b01a9) + Please see [full swagger definition](https://raw.githubusercontent.com/wso2/carbon-apimgt/v6.1.66/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher/src/main/resources/publisher-api.yaml) of the API which is written using [swagger 2.0](http://swagger.io/) specification. contact: - name: WSO2 - url: http://wso2.com/products/api-manager/ - email: architecture@wso2.com + name: "WSO2" + url: "http://wso2.com/products/api-manager/" + email: "architecture@wso2.com" license: - name: Apache 2.0 - url: http://www.apache.org/licenses/LICENSE-2.0.html - version: v2 -servers: - - url: https://apis.wso2.com/api/am/publisher/v2 -security: - - OAuth2Security: - - apim:api_view + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" + +###################################################### +# The fixed parts of the URLs of the API +###################################################### + +# The schemes supported by the API +schemes: + - https + +# The domain of the API. +# This is configured by the customer during deployment. +# The given host is just an example. +host: apis.wso2.com + +# The base path of the API. +# Will be prefixed to all paths. +basePath: /api/am/publisher/v0.12 + +# The following media types can be passed as input in message bodies of the API. +# The actual media type must be specified in the Content-Type header field of the request. +# The default is json, i.e. the Content-Type header is not needed to +# be set, but supporting it serves extensibility. +consumes: + - application/json + +# The following media types may be passed as output in message bodies of the API. +# The media type(s) consumable by the requestor is specified in the Accept header field +# of the corresponding request. +# The actual media type returned will be specfied in the Content-Type header field +# of the of the response. +# The default of the Accept header is json, i.e. there is not needed to +# set the value, but supporting it serves extensibility. +produces: + - application/json + + +x-wso2-security: + apim: + x-wso2-scopes: + - description: "" + roles: admin + name: apim:api_view + key: apim:api_view + - description: "" + roles: admin + name: apim:api_create + key: apim:api_create + - description: "" + roles: admin + name: apim:api_publish + key: apim:api_publish + - description: "" + roles: admin + name: apim:tier_view + key: apim:tier_view + - description: "" + roles: admin + name: apim:tier_manage + key: apim:tier_manage + - description: "" + roles: admin + name: apim:subscription_view + key: apim:subscription_view + - description: "" + roles: admin + name: apim:subscription_block + key: apim:subscription_block + - description: "" + roles: admin + name: apim:mediation_policy_view + key: apim:mediation_policy_view + - description: "" + roles: admin + name: apim:api_workflow + key: apim:api_workflow + + +###################################################### +# The "API Collection" resource APIs +###################################################### paths: - ###################################################### - # The "API Collection" resource APIs - ###################################################### /apis: + +#----------------------------------------------------- +# Retrieving the list of all APIs qualifying under a given search condition +#----------------------------------------------------- get: - tags: - - APIs + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This sample API provides Account Status Validation\",\n \"name\": \"AccountVal\",\n \"context\": \"/account\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\",\n \"status\": \"PUBLISHED\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"name\": \"api1\",\n \"context\": \"/api1\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\",\n \"status\": \"PUBLISHED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" summary: | Retrieve/Search APIs description: | @@ -124,10 +117,9 @@ paths: Each retrieved API is represented with a minimal amount of attributes. If you want to get complete details of an API, you need to use **Get details of an API** operation. parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/requestedTenant' - - name: query + - $ref : '#/parameters/limit' + - $ref : '#/parameters/offset' + - name : query in: query description: | **Search condition**. @@ -135,1011 +127,610 @@ paths: You can search in attributes by using an **":"** modifier. Eg. - "provider:wso2" will match an API if the provider of the API contains "wso2". - "provider:"wso2"" will match an API if the provider of the API is exactly "wso2". - "status:PUBLISHED" will match an API if the API is in PUBLISHED state. - "label:external" will match an API if it contains a Microgateway label called "external". + "provider:wso2" will match an API if the provider of the API is exactly "wso2". + + Additionally you can use wildcards. - Also you can use combined modifiers Eg. - name:pizzashack version:v1 will match an API if the name of the API is pizzashack and version is v1. + "provider:wso2*" will match an API if the provider of the API starts with "wso2". - Supported attribute modifiers are [**version, context, name, status, - description, subcontext, doc, provider, label**] + Supported attribute modifiers are [**version, context, status, + description, subcontext, doc, provider**] If no advanced attribute modifier has been specified, the API names containing the search term will be returned as a result. - Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) - schema: - type: string - - $ref: '#/components/parameters/If-None-Match' - - $ref: '#/components/parameters/expand' - - $ref: '#/components/parameters/Accept' + type: string + - $ref : "#/parameters/Accept" + - $ref : "#/parameters/If-None-Match" + tags: + - API (Collection) responses: 200: description: | OK. List of qualifying APIs is returned. + schema: + $ref: '#/definitions/APIList' headers: + Content-Type: + description: The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIList' + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis"' - x-examples: - $ref: docs/examples/apis/apis_get.yaml - operationId: getAllAPIs + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' +#----------------------------------------------------- +# Create a new API -API (Individual) +#----------------------------------------------------- post: - tags: - - APIs - summary: Create a New API + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis" + x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"PUBLISHED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": false,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\": \"in\"},{\"name\":\"log_out_message\",\"type\": \"out\"}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\":\"in\",\"id\":\"142ece76-b208-4aab-b29a-f382045ed066\",\"shared\":false},{\"name\":\"log_out_message\",\"type\":\"out\",\"id\":\"b3527be8-95e6-41e0-8097-3276987b7d4b\",\"shared\":false}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" + summary: Create a new API description: | This operation can be used to create a new API specifying the details of the API in the payload. The new API will be in `CREATED` state. There is a special capability for a user who has `APIM Admin` permission such that he can create APIs on behalf of other users. For that he can to specify `"provider" : "some_other_user"` in the payload so that the API's creator will be shown as `some_other_user` in the UI. parameters: - - name: openAPIVersion - in: query - description: Open api version + - in: body + name: body + description: | + API object that needs to be added + required: true schema: - type: string - default: v3 - enum: - - v2 - - v3 - requestBody: - description: API object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/API' - required: true + $ref: '#/definitions/API' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/Authorization' + tags: + - API (Individual) responses: 201: description: | Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity. + schema: + $ref: '#/definitions/API' headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string Location: description: | The URL of the newly created resource. - schema: - type: string + type: string Content-Type: description: | The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' + type: string + Authorization: + description: | + The brearer token. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis"' - x-examples: - $ref: docs/examples/apis/apis_post.yaml - operationId: createAPI + description: | + Unsupported Media Type. + The entity of the request was in a not supported format. + schema: + $ref: '#/definitions/Error' - ###################################################### - # The "Individual API" resource APIs - ###################################################### +###################################################### +# The "Individual API" resource APIs +###################################################### /apis/{apiId}: + +#----------------------------------------------------- +# Retrieve the details of an API definition +#----------------------------------------------------- get: - tags: - - APIs - summary: Get Details of an API + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" + summary: Get details of an API description: | Using this operation, you can retrieve complete details of a single API. You need to provide the Id of the API to retrive it. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API (Individual) responses: 200: description: | OK. Requested API is returned headers: + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' + type: string + schema: + $ref: '#/definitions/API' 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - - apim:api_import_export - - apim:api_product_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f"' - x-examples: - $ref: docs/examples/apis/apis_id_get.yaml - operationId: getAPI + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' +#----------------------------------------------------- +# Update the definition of an API +#----------------------------------------------------- put: - tags: - - APIs + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f" + x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\",\"chicken\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\": \"in\"},{\"name\":\"log_out_message\",\"type\": \"out\"}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\"https\"],\r\n \"tags\": [\r\n \"chicken\",\r\n \"pizza\"\r\n ],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\":\"in\",\"id\":\"142ece76-b208-4aab-b29a-f382045ed066\",\"shared\":false},{\"name\":\"log_out_message\",\"type\":\"out\",\"id\":\"b3527be8-95e6-41e0-8097-3276987b7d4b\",\"shared\":false}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" summary: Update an API description: | This operation can be used to update an existing API. But the properties `name`, `version`, `context`, `provider`, `state` will not be changed by this operation. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - description: API object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/API' - required: true + - $ref: '#/parameters/apiId' + - in: body + name: body + description: | + API object that needs to be added + required: true + schema: + $ref: '#/definitions/API' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API (Individual) responses: 200: description: | OK. Successful response with updated API object + schema: + $ref: '#/definitions/API' headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' 403: - $ref: '#/components/responses/Forbidden' + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - 409: - $ref: '#/components/responses/Conflict' + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f"' - operationId: updateAPI + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' +#----------------------------------------------------- +# Delete the definition of an API +#----------------------------------------------------- delete: - tags: - - APIs + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/6fb74674-4ab8-4b52-9886-f9a376985060" + x-wso2-request: | + DELETE https://localhost:9443/api/am/publisher/v0.12/apis/6fb74674-4ab8-4b52-9886-f9a376985060 + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK" summary: Delete an API description: | This operation can be used to delete an existing API proving the Id of the API. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API (Individual) responses: 200: description: | OK. Resource successfully deleted. - content: {} 403: - $ref: '#/components/responses/Forbidden' + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - 409: - $ref: '#/components/responses/Conflict' + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_delete - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f"' - operationId: deleteAPI - - /apis/{apiId}/topics: - put: - tags: - - APIs - summary: Update Topics - description: This operation can be used to update topics of an existing API. - operationId: updateTopics - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - description: API object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/TopicList' - required: true - responses: - 200: description: | - OK. - Successful response with updated API object - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' - /apis/{apiId}/reimport-service: - put: - tags: - - APIs - summary: Update the Service that is used to create the API - description: This operation can be used to re-import the Service used to create the API - operationId: reimportServiceFromCatalog - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Successful response with updated API object - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' +################################################################ +# The swagger resource of "Individual API" resource APIs +################################################################ /apis/{apiId}/swagger: +#----------------------------------------------------- +# Retrieve the API swagger definition +#----------------------------------------------------- get: - tags: - - APIs - summary: Get Swagger Definition + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\nContent-Length: 329\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" + summary: Get swagger definition description: | This operation can be used to retrieve the swagger definition of an API. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API (Individual) responses: 200: description: | OK. Requested swagger document of the API is returned headers: + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - type: string - example: "" + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f/swagger"' - operationId: getAPISwagger + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' +#----------------------------------------------------- +# Update the API swagger definition +#----------------------------------------------------- put: - tags: - - APIs - summary: Update Swagger Definition + consumes: + - multipart/form-data + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013\" -F apiDefinition=\"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\" -X PUT \"https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/swagger\"" + x-wso2-request: | + PUT https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/swagger + Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013 + Content-Length: 477 + Content-Type: multipart/form-data; boundary=------------------------4f51e636c0003d99 + + --------------------------4f51e636c0003d99 + Content-Disposition: form-data; name="apiDefinition" + + {"paths":{"\/*":{"get":{"x-auth-type":"Application","x-throttling-tier":"Unlimited","responses":{"200":{"description":"OK"}}}}},"x-wso2-security":{"apim":{"x-wso2-scopes":[]}},"swagger":"2.0","info":{"title":"PhoneVerification","description":"Verify a phone number","contact":{"email":"xx@ee.com","name":"xx"},"version":"1.0.0"}} + --------------------------4f51e636c0003d99-- + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" + summary: Update swagger definition description: | This operation can be used to update the swagger definition of an existing API. Swagger definition to be updated is passed as a form data parameter `apiDefinition`. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - properties: - apiDefinition: - type: string - description: Swagger definition of the API - url: - type: string - description: Swagger definition URL of the API - file: - type: string - description: Swagger definitio as a file - format: binary + - $ref: '#/parameters/apiId' + - in: formData + name: apiDefinition + description: Swagger definition of the API + type: string + required: true + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API (Individual) responses: 200: description: | OK. Successful response with updated Swagger definition headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string Location: description: | The URL of the newly created resource. - schema: - type: string + type: string Content-Type: description: | The content type of the body. - schema: - type: string - content: - application/json: - schema: - type: string - example: "" + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' 403: - $ref: '#/components/responses/Forbidden' + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F apiDefinition=@swagger.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/swagger"' - operationId: updateAPISwagger - - /apis/{apiId}/generate-mock-scripts: - post: - tags: - - APIs - summary: Generate Mock Response Payloads - description: | - This operation can be used to generate mock responses from examples of swagger definition of an API. - operationId: generateMockScripts - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: description: | - OK. - Requested swagger document of the API is returned with example responses - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - type: string - example: "" - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f/generate-mock-scripts"' - - /apis/{apiId}/generated-mock-scripts: - get: - tags: - - APIs - summary: Get Generated Mock Response Payloads - description: | - This operation can be used to get generated mock responses from examples of swagger definition of an API. - operationId: getGeneratedMockScriptsOfAPI - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Requested swagger document of the API is returned with example responses - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/MockResponsePayloadList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/7a2298c4-c905-403f-8fac-38c73301631f/generated-mock-scripts"' - - /apis/{apiId}/resource-policies: - get: - tags: - - API Resource Policies - summary: Get the Resource Policy(inflow/outflow) Definitions - description: | - This operation can be used to retrieve conversion policy resource definitions of an API. - parameters: - - $ref: '#/components/parameters/apiId' - - name: resourcePath - in: query - description: Resource path of the resource policy definition + Precondition Failed. + The request has not been performed because one of the preconditions is not met. schema: - type: string - - name: verb - in: query - description: HTTP verb of the resource path of the resource policy definition - schema: - type: string - - name: sequenceType - in: query - description: sequence type of the resource policy resource definition - required: true - schema: - type: string - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - List of resource policy definitions of the API is returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePolicyList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/resource-policies?resourcePath=checkPhoneNumber&verb=post&sequenceType=in"' - operationId: getAPIResourcePolicies + $ref: '#/definitions/Error' - /apis/{apiId}/resource-policies/{resourcePolicyId}: - get: - tags: - - API Resource Policies - summary: Get the Resource Policy(inflow/outflow) Definition for a Given Resource - Identifier. - description: | - This operation can be used to retrieve conversion policy resource definitions of an API given the resource identifier. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/resourcePolicyId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Requested resource policy definition of the API is returned for the given resource identifier. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePolicyInfo' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/resource-policies/8efc32a4-c7f1-4bee-b860-b7566e2bc0d5"' - operationId: getAPIResourcePoliciesByPolicyId - - put: - tags: - - API Resource Policies - summary: Update the Resource Policy(inflow/outflow) Definition for the Given - Resource Identifier - description: | - This operation can be used to update the resource policy(inflow/outflow) definition for the given resource identifier of an existing API. resource policy definition to be updated is passed as a body parameter `content`. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/resourcePolicyId' - - $ref: '#/components/parameters/If-Match' - requestBody: - description: Content of the resource policy definition that needs to be updated - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePolicyInfo' - required: true - responses: - 200: - description: | - OK. - Successful response with updated the resource policy definition - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePolicyInfo' - 400: - $ref: '#/components/responses/BadRequest' - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/resource-policies/8efc32a4-c7f1-4bee-b860-b7566e2bc0d5"' - operationId: updateAPIResourcePoliciesByPolicyId +################################################################ +# The thumbnail resource of "Individual API" resource APIs +################################################################ /apis/{apiId}/thumbnail: +#------------------------------------------------------------------------------------------------- +# Downloads a thumbnail image of an API +#------------------------------------------------------------------------------------------------- get: - tags: - - APIs - summary: Get Thumbnail Image + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail > image.jpg" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail + Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9 + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" + summary: Get thumbnail image description: | This operation can be used to download a thumbnail image of an API. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - API (Individual) responses: 200: description: | OK. Thumbnail image returned headers: + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/thumbnail"' - operationId: getAPIThumbnail + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' - put: - tags: - - APIs - summary: Upload a Thumbnail Image +#---------------------------------------------------------------------------- +# Upload a thumbnail image to a certain API +#---------------------------------------------------------------------------- + post: + consumes: + - multipart/form-data + x-scope: apim:api_create + x-wso2-curl: "curl -X POST -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail -F file=@image.jpg" + x-wso2-request: | + POST https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail + Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9 + Content-Type: multipart/form-data; boundary=------------------------5e542e0e5b50e1e4 + Content-Length: 18333 + + --------------------------5e542e0e5b50e1e4 + Content-Disposition: form-data; name="file"; filename="image.jpg" + Content-Type: image/jpeg + + [image content] + + --------------------------5e542e0e5b50e1e4-- + x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail\r\nContent-Type: application/json\r\n\r\n{\r\n \"relativePath\": \"/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail\",\r\n \"mediaType\": \"image/jpeg\"\r\n}" + summary: Upload a thumbnail image description: | This operation can be used to upload a thumbnail image of an API. The thumbnail to be uploaded should be given as a form data parameter `file`. - operationId: updateAPIThumbnail parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - required: - - file - properties: - file: - type: string - description: Image to upload - format: binary - required: true + - $ref: '#/parameters/apiId' + - in: formData + name: file + description: Image to upload + type: file + required: true + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API (Individual) responses: 200: description: | OK. Image updated + schema: + $ref : '#/definitions/FileInfo' headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string Location: description: | The URL of the uploaded thumbnail image of the API. - schema: - type: string + type: string Content-Type: description: | The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/FileInfo' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=image.jpeg "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/thumbnail"' - - /apis/{apiId}/subscription-policies: - get: - tags: - - APIs - summary: | - Get Details of the Subscription Throttling Policies of an API - description: | - This operation can be used to retrieve details of the subscription throttling policy of an API by specifying the API Id. - - `X-WSO2-Tenant` header can be used to retrive API subscription throttling policies that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Throttling Policy returned - headers: + type: string ETag: description: | Entity Tag of the response resource. - Used by caches, or in conditional requests. - schema: - type: string + Used by caches, or in conditional requests (Will be supported in future). + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ThrottlingPolicy' - 304: + Used by caches, or in conditional requests (Will be supported in future). + type: string + 400: description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - content: {} + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/2fd14eb8-b828-4013-b448-0739d2e76bf7/subscription-policies"' - operationId: getAPISubscriptionPolicies + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' +###################################################### +# The "Copy API" Processing Function resource API +###################################################### /apis/copy-api: + +#----------------------------------------------------- +# Create a new API based on an already existing one +#----------------------------------------------------- post: - tags: - - APIs - summary: Create a New API Version + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0\"" + x-wso2-request: | + POST https://localhost:9443/api/am/publisher/v0.12/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0 + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/25a84fc9-38c0-4578-95e8-29fb6b1c4771\nContent-Type: application/json\n\n{\r\n \"id\": \"25a84fc9-38c0-4578-95e8-29fb6b1c4771\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"2.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\\\/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"schema\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/Order\\\"},\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"Created.\\\"}}}},\\\"\\\\/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"headers\\\":{},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application\\\\/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application\\\\/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http:\\\\/\\\\/www.apache.org\\\\/licenses\\\\/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http:\\\\/\\\\/www.pizzashack.com\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\"https\"],\r\n \"tags\": [\r\n \"chicken\",\r\n \"pizza\"\r\n ],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" + summary: Create a new API version description: | This operation can be used to create a new version of an existing API. The new version is specified as `newVersion` query parameter. New API will be in `CREATED` state. parameters: - - name: newVersion - in: query - description: Version of the new API. - required: true - schema: - maxLength: 30 + - name: newVersion + description: Version of the new API. type: string - - name: defaultVersion - in: query - description: Specifies whether new API should be added as default version. - schema: - type: boolean - default: false - - name: serviceVersion - in: query - description: Version of the Service that will used in creating new version - schema: - type: string - required: false - - $ref: '#/components/parameters/apiId-Q' + in: query + required: true + - $ref: '#/parameters/apiId-Q' + tags: + - API (Individual) responses: 201: description: | @@ -1149,31 +740,38 @@ paths: Location: description: | The URL of the newly created API. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/copy-api?newVersion=2.0&defaultVersion=false&apiId=2fd14eb8-b828-4013-b448-0739d2e76bf7"' - x-examples: - $ref: docs/examples/apis/apis_copyapi.yaml#/post - operationId: createNewAPIVersion + description: | + Not Found. + API to copy does not exist. + 401: + description: | + Unauthenticated request. + schema: + $ref: '#/definitions/Error' +###################################################### +# The "Change Lifecycle" Processing Function resource API +###################################################### /apis/change-lifecycle: + +#----------------------------------------------------- +# Change the lifecycle of an API +#----------------------------------------------------- post: - tags: - - API Lifecycle + x-scope: apim:api_publish + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish\"" + x-wso2-request: | + POST https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK" summary: Change API Status description: | This operation is used to change the lifecycle of an API. Eg: Publish an API which is in `CREATED` state. In order to change the lifecycle, we need to provide the lifecycle `action` as a query parameter. @@ -1183,36 +781,43 @@ paths: Some actions supports providing additional paramters which should be provided as `lifecycleChecklist` parameter. Please see parameters table for more information. parameters: - name: action - in: query description: | The action to demote or promote the state of the API. - Supported actions are [ **Publish**, **Deploy as a Prototype**, **Demote to Created**, **Block**, **Deprecate**, **Re-Publish**, **Retire** ] - required: true - schema: - type: string - enum: - - Publish - - Deploy as a Prototype - - Demote to Created - - Block - - Deprecate - - Re-Publish - - Retire - - name: lifecycleChecklist + Supported actions are [ **Publish, Deploy as a Prototype, Demote to Created, Demote to Prototyped, Block, Deprecate, Re-Publish, Retire **] + in: query - description: |2 + type: string + required: true + enum: + - Publish + - Deploy as a Prototype + - Demote to Created + - Demote to Prototyped + - Block + - Deprecate + - Re-Publish + - Retire + - name: lifecycleChecklist + description: | Supported checklist items are as follows. - 1. **Deprecate old versions after publishing the API**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. - 2. **Requires re-subscription when publishing the API**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. + 1. **Deprecate Old Versions**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. + 2. **Require Re-Subscription**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. + You can specify additional checklist items by using an **"attribute:"** modifier. - Eg: "Deprecate old versions after publishing the API:true" will deprecate older versions of a particular API when it is promoted to Published state from Created state. Multiple checklist items can be given in "attribute1:true, attribute2:false" format. - **Sample CURL :** curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X POST "https://localhost:9443/api/am/publisher/v2/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish&lifecycleChecklist=Deprecate%20old%20versions%20after%20publishing%20the%20API%3Atrue,Requires%20re-subscription%20when%20publishing%20the%20API%3Afalse" - schema: - type: string - - $ref: '#/components/parameters/apiId-Q' - - $ref: '#/components/parameters/If-Match' + + Eg: "Deprecate Old Versions:true" will deprecate older versions of a particular API when it is promoted to Published state from Created state. Multiple checklist items can be given in "attribute1:true, attribute2:false" format. + + **Sample CURL :** curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X POST "https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish&lifecycleChecklist=Deprecate Old Versions:true,Require Re-Subscription:true" + + type: string + in: query + - $ref: '#/parameters/apiId-Q' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - API (Individual) responses: 200: description: | @@ -1222,3198 +827,1151 @@ paths: ETag: description: | Entity Tag of the changed API. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the API lifecycle has been modified the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/WorkflowResponse' - 202: - description: | - Accepted. - The request has been accepted. - content: - application/json: - schema: - $ref: '#/components/schemas/WorkflowResponse' + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - 409: - $ref: '#/components/responses/Conflict' + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish"' - operationId: changeAPILifecycle - - /apis/{apiId}/lifecycle-history: - get: - tags: - - API Lifecycle - summary: Get Lifecycle State Change History of the API. - description: | - This operation can be used to retrieve Lifecycle state change history of the API. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: description: | - OK. - Lifecycle state change history returned successfully. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/LifecycleHistory' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/lifecycle-history"' - operationId: getAPILifecycleHistory - - /apis/{apiId}/lifecycle-state: - get: - tags: - - API Lifecycle - summary: Get Lifecycle State Data of the API. - description: | - This operation can be used to retrieve Lifecycle state data of the API. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Lifecycle state data returned successfully. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/LifecycleState' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/lifecycle-state"' - operationId: getAPILifecycleState - - /apis/{apiId}/lifecycle-state/pending-tasks: - delete: - tags: - - API Lifecycle - summary: Delete Pending Lifecycle State Change Tasks - description: | - This operation can be used to remove pending lifecycle state change requests that are in pending state - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Lifecycle state change pending task removed successfully. - content: {} - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/lifecycle-state/pending-tasks"' - operationId: deleteAPILifecycleStatePendingTasks - - ###################################################### - # The "API Revisions" resource API - ###################################################### - /apis/{apiId}/revisions: - - #-------------------------------------------- - # List available revisions of an API - #-------------------------------------------- - get: - tags: - - API Revisions - summary: List available revisions of an API - description: | - List available revisions of an API - operationId: getAPIRevisions - parameters: - - $ref: '#/components/parameters/apiId' - - name: query - in: query + Precondition Failed. + The request has not been performed because one of the preconditions is not met. schema: - type: string - responses: - 200: - description: | - OK. - List of API revisions are returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevisionList' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions?query=deployed:true"' - - #-------------------------------------------- - # Create a new API revision - #-------------------------------------------- - post: - tags: - - API Revisions - summary: Create a new API revision - description: | - Create a new API revision - operationId: createAPIRevision - parameters: - - $ref: '#/components/parameters/apiId' - requestBody: - description: API object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevision' - responses: - 201: - description: | - Created. - Successful response with the newly created APIRevision object as the entity in the body. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevision' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions"' - - ###################################################### - # The "API Revisions" individual resource API - ###################################################### - /apis/{apiId}/revisions/{revisionId}: - - #-------------------------------------------- - # Get a revision - #-------------------------------------------- - get: - tags: - - API Revisions - summary: Retrieve a revision of an API - description: | - Retrieve a revision of an API - operationId: getAPIRevision - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/revisionId' - responses: - 200: - description: | - OK. - An API revision is returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevision' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' - - #-------------------------------------------- - # Delete a revision - #-------------------------------------------- - delete: - tags: - - API Revisions - summary: Delete a revision of an API - description: | - Delete a revision of an API - operationId: deleteAPIRevision - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/revisionId' - responses: - 200: - description: | - OK. - List of remaining API revisions are returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevisionList' - 204: - description: | - No Content. - Successfully deleted the revision - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' - - /apis/{apiId}/deploy-revision: - - #-------------------------------------------- - # List available deployed revision deployment details of an API - #-------------------------------------------- - get: - tags: - - API Revisions - summary: List available deployed revision deployment details of an API - description: | - List available deployed revision deployment details of an API - operationId: getAPIRevisionDeployments - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - List of deployed revision deployment details are returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevisionDeploymentList' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision"' - - #-------------------------------------------- - # Deploy a revision - #-------------------------------------------- - post: - tags: - - API Revisions - summary: Deploy a revision - description: | - Deploy a revision - operationId: deployAPIRevision - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/revisionId-Q' - requestBody: - description: Deployment object that needs to be added - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - responses: - 200: - description: | - OK. - 201: - description: | - Created. - Successful response with the newly deployed APIRevisionDeployment List object as the entity in the body. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' - - /apis/{apiId}/undeploy-revision: - #-------------------------------------------- - # Un-Deploy a revision from deployed gateway - #-------------------------------------------- - post: - tags: - - API Revisions - summary: Un-Deploy a revision - description: | - Un-Deploy a revision - operationId: undeployAPIRevision - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/revisionId-Q' - - $ref: '#/components/parameters/revisionNum-Q' - - name: allEnvironments - in: query - schema: - type: boolean - default: false - requestBody: - description: Deployment object that needs to be added - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - responses: - 200: - description: | - OK. - 201: - description: | - Created. - Successful response with the newly undeployed APIRevisionDeploymentList object as the entity in the body. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/undeploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' - - /apis/{apiId}/restore-revision: - - #-------------------------------------------------------- - # Restore a revision to the working copy of the API - #-------------------------------------------------------- - post: - tags: - - API Revisions - summary: Restore a revision - description: | - Restore a revision to the working copy of the API - operationId: restoreAPIRevision - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/revisionId-Q' - responses: - 201: - description: | - Restored. - Successful response with the newly restored API object as the entity in the body. - content: - application/json: - schema: - $ref: '#/components/schemas/API' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v1/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/restore-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' - - /apis/import-service: - post: - tags: - - APIs - summary: Import a Service from Service Catalog - description: This operation can be used to create an API from a Service from Service Catalog - operationId: importServiceFromCatalog - parameters: - - name: serviceKey - in: query - required: true - schema: - type: string - description: ID of service that should be imported from Service Catalog - requestBody: - content: - application/json: - schema: - '$ref': '#/components/schemas/API' - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains the URL of the newly created entity. - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - - /apis/{apiId}/comments: - get: - tags: - - Comments - summary: Retrieve API Comments - description: | - Get a list of Comments that are already added to APIs - operationId: getAllCommentsOfAPI - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/includeCommenterInfo' - responses: - 200: - description: | - OK. - Comments list is returned. - content: - application/json: - schema: - $ref: '#/components/schemas/CommentList' - 401: - $ref: '#/components/responses/Unauthorized' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments" - - post: - tags: - - Comments - summary: Add an API Comment - operationId: addCommentToAPI - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/parentCommentID' - requestBody: - description: | - Comment object that should to be added - content: - application/json: - schema: - title: Post request body - type: object - properties: - content: - type: string - description: | - Content of the comment - example: This is a comment - category: - type: string - description: | - Category of the comment - example: general - required: - - content - required: true - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request. - schema: - type: string - Location: - description: | - Location to the newly created Comment. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Comment' - 400: - $ref: '#/components/responses/BadRequest' - 401: - $ref: '#/components/responses/Unauthorized' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments"' - - /apis/{apiId}/comments/{commentId}: - get: - tags: - - Comments - summary: Get Details of an API Comment - description: | - Get the individual comment given by a username for a certain API. - operationId: getCommentOfAPI - parameters: - - $ref: '#/components/parameters/commentId' - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/If-None-Match' - - $ref: '#/components/parameters/includeCommenterInfo' - - $ref: '#/components/parameters/replyLimit' - - $ref: '#/components/parameters/replyOffset' - responses: - 200: - description: | - OK. - Comment returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Comment' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - content: {} - 401: - $ref: '#/components/responses/Unauthorized' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" - - patch: - tags: - - Comments - summary: Edit a comment - description: | - Edit the individual comment - operationId: editCommentOfAPI - parameters: - - $ref: '#/components/parameters/commentId' - - $ref: '#/components/parameters/apiId' - requestBody: - description: | - Comment object that should to be updated - content: - application/json: - schema: - title: Patch request body - type: object - properties: - content: - type: string - description: | - Content of the comment - example: This is a comment - category: - type: string - description: | - Category of the comment - example: general - required: true - responses: - 200: - description: | - OK. - Comment updated. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional request. - schema: - type: string - Location: #??? - description: | - Location to the newly created Comment. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Comment' - 400: - $ref: '#/components/responses/BadRequest' - 401: - $ref: '#/components/responses/Unauthorized' - 404: - $ref: '#/components/responses/NotFound' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4"' - - delete: - tags: - - Comments - summary: Delete an API Comment - description: | - Remove a Comment - operationId: deleteComment - parameters: - - $ref: '#/components/parameters/commentId' - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - responses: - 200: - description: | - OK. - Resource successfully deleted. - content: {} - 401: - $ref: '#/components/responses/Unauthorized' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: curl -k -X DELETE -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" - - /apis/{apiId}/comments/{commentId}/replies: - get: - tags: - - Comments - summary: Get replies of a comment - description: | - Get replies of a comment - operationId: getRepliesOfComment - parameters: - - $ref: '#/components/parameters/commentId' - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/If-None-Match' - - $ref: '#/components/parameters/includeCommenterInfo' - responses: - 200: - description: | - OK. - Comment returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/CommentList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - content: {} - 401: - $ref: '#/components/responses/Unauthorized' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/am/publisher/v1/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" - - /apis/import-openapi: - post: - tags: - - APIs - summary: Import an OpenAPI Definition - description: | - This operation can be used to create an API from an OpenAPI definition. Provide either `url` or `file` - to specify the definition. - - Specify additionalProperties with **at least** API's name, version, context and endpointConfig. - operationId: importOpenAPIDefinition - requestBody: - content: - multipart/form-data: - schema: - properties: - file: - type: string - description: Definition to upload as a file - format: binary - url: - type: string - description: Definition url - additionalProperties: - type: string - description: Additional attributes specified as a stringified JSON with API's schema - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@openapi.json -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-openapi"' - x-examples: - $ref: docs/examples/apis/import_openapi_post.yaml - - /apis/import-wsdl: - post: - tags: - - APIs - summary: Import a WSDL Definition - description: | - This operation can be used to create an API using a WSDL definition. Provide either `url` or `file` - to specify the definition. - - WSDL can be speficied as a single file or a ZIP archive with WSDLs and reference XSDs etc. - Specify additionalProperties with **at least** API's name, version, context and endpointConfig. - operationId: importWSDLDefinition - requestBody: - content: - multipart/form-data: - schema: - properties: - file: - type: string - description: | - WSDL definition as a file or archive - - **Sample cURL to Upload WSDL File** - - curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -F file=@api.wsdl -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-wsdl" - - **Sample cURL to Upload WSDL Archive** - - curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -F file="@wsdl.zip;type=application/zip" -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-wsdl" - format: binary - url: - type: string - description: WSDL Definition url - additionalProperties: - type: string - description: Additional attributes specified as a stringified JSON - with API's schema - implementationType: - type: string - description: | - If 'SOAP' is specified, the API will be created with only one resource 'POST /*' which is to be used for SOAP - operations. - - If 'HTTP_BINDING' is specified, the API will be created with resources using HTTP binding operations - which are extracted from the WSDL. - default: SOAP - enum: - - SOAPTOREST - - SOAP - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@api.wsdl -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-wsdl"' - x-examples: - $ref: docs/examples/apis/wsdl/import_wsdl_post.yaml - - /apis/import-graphql-schema: - post: - tags: - - APIs - summary: Import API Definition - description: | - This operation can be used to create api from api definition.APIMgtDAOTest - - API definition is GraphQL Schema - parameters: - - name: If-Match - in: header - description: | - Validator for conditional requests; based on ETag. - schema: - type: string - requestBody: - content: - multipart/form-data: - schema: - properties: - type: - type: string - description: Definition type to upload - file: - type: string - description: Definition to uploads a file - format: binary - additionalProperties: - type: string - description: Additional attributes specified as a stringified JSON - with API's schema - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@schema.graphql -F additionalProperties=@data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/import-graphql-schema"' - operationId: importGraphQLSchema - - /apis/validate-openapi: - post: - tags: - - Validation - summary: Validate an OpenAPI Definition - description: | - This operation can be used to validate an OpenAPI definition and retrieve a summary. Provide either `url` - or `file` to specify the definition. - operationId: validateOpenAPIDefinition - parameters: - - name: returnContent - in: query - description: | - Specify whether to return the full content of the OpenAPI definition in the response. This is only - applicable when using url based validation - schema: - type: boolean - default: false - requestBody: - content: - multipart/form-data: - schema: - properties: - url: - type: string - description: OpenAPI definition url - file: - type: string - description: OpenAPI definition as a file - format: binary - responses: - 200: - description: | - OK. - API definition validation information is returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAPIDefinitionValidationResponse' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@openapi.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-openapi"' - x-examples: - $ref: docs/examples/apis/validate_openapi_post.yaml - - /apis/validate-endpoint: - post: - tags: - - Validation - summary: Check Whether Given Endpoint URL is Valid - description: | - Using this operation, it is possible check whether the given API endpoint url is a valid url - operationId: validateEndpoint - parameters: - - name: endpointUrl - in: query - description: API endpoint url - required: true - schema: - type: string - - name: apiId - in: query - schema: - type: string - responses: - 200: - description: | - OK. - API definition validation information is returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ApiEndpointValidationResponse' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-endpoint?apiId=e0824883-3e86-403a-aec1-22bbc454eb7c&endpointUrl=https%3A%2F%2Flocalhost%3A9443%2Fam%2Fsample%2Fpizzashack%2Fv1%2Fapi%2F"' - - /apis/validate: - post: - tags: - - Validation - summary: Check Given API Context Name already Exists - description: | - Using this operation, you can check a given API context is already used. You need to provide the context name you want to check. - operationId: validateAPI - parameters: - - name: query - in: query - description: | - **Search condition**. - - You can search in attributes by using an **":"** modifier. - - Eg. - "name:wso2" will match an API if the provider of the API is exactly "wso2". - - Supported attribute modifiers are [** version, context, name **] - - If no advanced attribute modifier has been specified, search will match the - given query string against API Name. - required: true - schema: - type: string - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - API definition validation information is returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate?query=name%3Awso2"' - x-examples: - $ref: docs/examples/apis/apis_validate.yaml - - /apis/validate-wsdl: - post: - tags: - - Validation - summary: Validate a WSDL Definition - description: | - This operation can be used to validate a WSDL definition and retrieve a summary. Provide either `url` - or `file` to specify the definition. - operationId: validateWSDLDefinition - requestBody: - content: - multipart/form-data: - schema: - properties: - url: - type: string - description: Definition url - file: - type: string - description: Definition to upload as a file - format: binary - responses: - 200: - description: | - OK. - API definition validation information is returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/WSDLValidationResponse' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@api.wsdl "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-wsdl"' - x-examples: - $ref: docs/examples/apis/wsdl/validate_wsdl_post.yaml - - /apis/validate-graphql-schema: - post: - tags: - - Validation - summary: Validate GraphQL API Definition and Retrieve a Summary - description: | - This operation can be used to validate a graphQL definition and retrieve a summary. - requestBody: - content: - multipart/form-data: - schema: - required: - - file - properties: - file: - type: string - description: Definition to upload as a file - format: binary - required: true - responses: - 200: - description: | - OK. - API definition validation information is returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/GraphQLValidationResponse' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@schema.graphql "https://127.0.0.1:9443/api/am/publisher/v2/apis/validate-graphql-schema"' - operationId: validateGraphQLSchema - - /apis/{apiId}/graphql-schema: - get: - tags: - - GraphQL Schema (Individual) - summary: Get the Schema of a GraphQL API - description: | - This operation can be used to retrieve the Schema definition of a GraphQL API. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Requested GraphQL Schema DTO object belongs to the API - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/GraphQLSchema' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/graphql-schema"' - operationId: getAPIGraphQLSchema - - put: - tags: - - GraphQL Schema - summary: Add a Schema to a GraphQL API - description: | - This operation can be used to add a GraphQL Schema definition to an existing GraphQL API. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - required: - - schemaDefinition - properties: - schemaDefinition: - type: string - description: schema definition of the GraphQL API - required: true - responses: - 200: - description: | - OK. - Successful response with updated schema definition - headers: - ETag: - description: | - Entity Tag of the response resource. Used by cache, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F schemaDefinition=@schema.graphql "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/graphql-schema"' - operationId: updateAPIGraphQLSchema - - /apis/{apiId}/amznResourceNames: - get: - tags: - - AWS Lambda (Individual) - summary: Retrieve the ARNs of AWS Lambda Functions - description: | - This operation can be use to retrieve ARNs of AWS Lambda function for a given AWS credentials. - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Requested ARN List of the API is returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - type: string - example: |- - { - "count": "2", - "list": [ - "arn:aws:lambda:us-west-2:123456789012:function:my-function1", - "arn:aws:lambda:us-west-2:123456789012:function:my-function2" - ] - } - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/amznResourceNames"' - x-examples: - $ref: docs/examples/apis/apis_id_amznresourcenames_get.yaml - operationId: getAmazonResourceNamesOfAPI - - /apis/{apiId}/monetize: - post: - tags: - - API Monetization - summary: Configure Monetization for a Given API - description: | - This operation can be used to configure monetization for a given API. - parameters: - - $ref: '#/components/parameters/apiId' - requestBody: - description: Monetization data object - content: - application/json: - schema: - $ref: '#/components/schemas/APIMonetizationInfo' - required: true - responses: - 201: - description: | - OK. - Monetization status changed successfully. - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/monetize' - operationId: addAPIMonetization - - /apis/{apiId}/monetization: - get: - tags: - - API Monetization - summary: Get Monetization Status for each Tier in a Given API - description: | - This operation can be used to get monetization status for each tier in a given API - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Monetization status for each tier returned successfully. - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/monetize"' - operationId: getAPIMonetization - - /apis/{apiId}/revenue: - get: - tags: - - API Monetization - summary: Get Total Revenue Details of a Given Monetized API with Meterd Billing - description: | - This operation can be used to get details of total revenue details of a given monetized API with meterd billing. - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Details of a total revenue returned. - headers: - ETag: - description: Entity Tag of the response resource. Used by caches, or - in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: Date and time the resource has been modified the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevenue' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/revenue"' - operationId: getAPIRevenue + $ref: '#/definitions/Error' +###################################################### +# The "Document Collection" resource APIs +###################################################### /apis/{apiId}/documents: + +#----------------------------------------------------- +# Retrieve the documents associated with an API that qualify under a search condition +#----------------------------------------------------- get: - tags: - - API Documents - summary: Get a List of Documents of an API + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents\"" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"4145df31-04f1-440c-8d08-68952874622c\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" + summary: Get a list of documents of an API description: | - This operation can be used to retrieve a list of documents belonging to an API by providing the id of the API. + This operation can be used to retrive a list of documents belonging to an API by providing the id of the API. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Document (Collection) responses: 200: description: | OK. Document list is returned. + schema: + $ref: '#/definitions/DocumentList' headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string Content-Type: description: | The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/DocumentList' + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/e0824883-3e86-403a-aec1-22bbc454eb7c/documents"' - operationId: getAPIDocuments + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' +#----------------------------------------------------- +# Add a document to a certain API +#----------------------------------------------------- post: - tags: - - API Documents - summary: Add a New Document to an API + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\"" + x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" + summary: Add a new document to an API description: | This operation can be used to add a new documentation to an API. This operation only adds the metadata of a document. To add the actual content we need to use **Upload the content of an API document ** API once we obtain a document Id by this operation. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - description: Document object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - required: true + - $ref: '#/parameters/apiId' + - in: body + name: body + description: | + Document object that needs to be added + required: true + schema: + $ref: '#/definitions/Document' + - $ref: '#/parameters/Content-Type' + tags: + - Document (Collection) responses: 201: description: | Created. Successful response with the newly created Document object as entity in the body. Location header contains URL of newly added document. + schema: + $ref: '#/definitions/Document' headers: + Location: + description: | + Location to the newly created Document. + type: string + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - Location to the newly created Document. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_create - - apim:document_create - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents"' - operationId: addAPIDocument + description: | + Unsupported media type. + The entity of the request was in a not supported format. - /apis/{apiId}/documents/{documentId}: +###################################################### +# The "Individual Document" resource APIs +###################################################### + '/apis/{apiId}/documents/{documentId}': + +#----------------------------------------------------- +# Retrieve a particular document of a certain API +#----------------------------------------------------- get: - tags: - - API Documents - summary: Get a Document of an API + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5 + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" + summary: Get a document of an API description: | This operation can be used to retrieve a particular document's metadata associated with an API. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Document (Individual) responses: 200: description: | OK. Document returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5"' - operationId: getAPIDocumentByDocumentId - - put: - tags: - - API Documents - summary: Update a Document of an API - description: | - This operation can be used to update metadata of an API's document. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-Match' - requestBody: - description: Document object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - required: true - responses: - 200: - description: | - OK. - Document updated - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the updated document. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:document_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @doc.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5"' - operationId: updateAPIDocument - - delete: - tags: - - API Documents - summary: Delete a Document of an API - description: | - This operation can be used to delete a document associated with an API. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-Match' - responses: - 200: - description: | - OK. - Resource successfully deleted. - content: {} - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:document_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5"' - operationId: deleteAPIDocument - - /apis/{apiId}/documents/{documentId}/content: - get: - tags: - - API Documents - summary: Get the Content of an API Document - description: | - This operation can be used to retrive the content of an API's document. - - The document can be of 3 types. In each cases responses are different. - - 1. **Inline type**: - The content of the document will be retrieved in `text/plain` content type - - _Sample cURL_ : `curl -k -H "Authorization:Bearer 579f0af4-37be-35c7-81a4-f1f1e9ee7c51" -F inlineContent=@"docs.txt" -X POST "https://localhost:9443/api/am/publisher/v2/apis/995a4972-3178-4b17-a374-756e0e19127c/documents/43c2bcce-60e7-405f-bc36-e39c0c5e189e/content` - 2. **FILE type**: - The file will be downloaded with the related content type (eg. `application/pdf`) - 3. **URL type**: - The client will recieve the URL of the document as the Location header with the response with - `303 See Other` - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - File or inline content returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/octet-stream: - schema: - type: string - 303: - description: | - See Other. - Source can be retrived from the URL specified at the Location header. - headers: - Location: - description: | - The Source URL of the document. - schema: - type: string - content: {} - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content"' - operationId: getAPIDocumentContentByDocumentId - - post: - tags: - - API Documents - summary: Upload the Content of an API Document - description: | - Thid operation can be used to upload a file or add inline content to an API document. - - **IMPORTANT:** - * Either **file** or **inlineContent** form data parameters should be specified at one time. - * Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. - * Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - properties: - file: - type: string - description: Document to upload - format: binary - inlineContent: - type: string - description: Inline content of the document - responses: - 200: - description: | - OK. - Document updated - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the updated content of the document. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:document_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@sample.pdf "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content"' - operationId: addAPIDocumentContent - - /apis/{apiId}/documents/validate: - post: - tags: - - API Documents - summary: Check Whether a Document with the Provided Name Exist - description: | - This operation can be used to verify the document name exists or not. - operationId: validateDocument - parameters: - - $ref: '#/components/parameters/apiId' - - name: name - in: query - description: | - The name of the document which needs to be checked for the existance. - required: true schema: - type: string - - $ref: '#/components/parameters/If-Match' - responses: - 200: + $ref: '#/definitions/Document' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 304: description: | - OK. - Successful response if the document name exists. - 400: - $ref: '#/components/responses/BadRequest' + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). 404: description: | Not Found. - The specified resource does not exist. - security: - - OAuth2Security: - - apim:api_create - - apim:document_create - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/validate?name=CalculatorDoc"' - x-examples: - $ref: docs/examples/apis/apis_id_document_validate.yaml - - /apis/{apiId}/mediation-policies: - get: - tags: - - API Mediation Policies - summary: | - Get All Mediation Policies of an API - description: | - This operation provides you a list of available mediation policies of an API. - operationId: getAllAPIMediationPolicies - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - name: query - in: query - description: -Not supported yet- + Requested Document does not exist. schema: - type: string - - $ref: '#/components/parameters/If-None-Match' + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Update a particular document of a certain API +#----------------------------------------------------- + put: + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" + x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\nAuthorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" + summary: Update a document of an API + description: | + This operation can be used to update metadata of an API's document. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - in: body + name: body + description: | + Document object that needs to be added + required: true + schema: + $ref: '#/definitions/Document' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Document (Individual) responses: 200: description: | OK. - List of qualifying APIs is returned. + Document updated + schema: + $ref: '#/definitions/Document' headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/MediationList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - - apim:mediation_policy_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies"' - x-examples: - $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_get.yaml - - post: - tags: - - API Mediation Policies - summary: Add an API Specific Mediation Policy - description: | - This operation can be used to add an API specifc mediation policy. - operationId: addAPIMediationPolicy - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - required: - - type - properties: - mediationPolicyFile: - type: string - description: Mediation Policy to upload - format: binary - inlineContent: - type: string - description: Inline content of the Mediation Policy - type: - type: string - description: Type of the mediation sequence - required: true - responses: - 201: - description: | - OK. - mediation policy uploaded - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string Location: description: | - The URL of the uploaded mediation policy of the API. - schema: - type: string + The URL of the updated document. + type: string Content-Type: description: | The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Mediation' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:mediation_policy_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: multipart/form-data" -F mediationPolicyFile=@TokenExchange.xml - -F type=in "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies"' - x-examples: - $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_post.yaml - - /apis/{apiId}/mediation-policies/{mediationPolicyId}: - get: - tags: - - API Mediation Policy - summary: Get an API Specific Mediation Policy - description: | - This operation can be used to retrieve a particular API specific mediation policy. - operationId: getAPIMediationPolicyByPolicyId - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/mediationPolicyId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Mediation policy returned. - headers: + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Mediation' - 304: + type: string + 400: description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - - apim:mediation_policy_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' - x-examples: - $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_get.yaml + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' +#----------------------------------------------------- +# Delete a particular document of a certain API +#----------------------------------------------------- delete: - tags: - - API Mediation Policy - summary: Delete an API Specific Mediation Policy + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058" + x-wso2-request: | + DELETE https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058 + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK" + summary: Delete a document of an API description: | - This operation can be used to delete an existing API specific mediation policy providing the Id of the API and the Id of the mediation policy. - operationId: deleteAPIMediationPolicyByPolicyId + This operation can be used to delete a document associated with an API. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/mediationPolicyId' - - $ref: '#/components/parameters/If-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Document (Individual) responses: 200: description: | OK. Resource successfully deleted. - content: {} - 403: - $ref: '#/components/responses/Forbidden' 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:mediation_policy_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' - x-examples: - $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_delete.yaml - - /apis/{apiId}/mediation-policies/{mediationPolicyId}/content: - get: - tags: - - API Mediation Policy - summary: Download an API Specific Mediation Policy - description: | - This operation can be used to download a particular API specific mediation policy. - operationId: getAPIMediationPolicyContentByPolicyId - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/mediationPolicyId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: description: | - OK. - Mediation policy returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_view - - apim:mediation_policy_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a/content"' - x-examples: - $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_content_get.yaml + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' - put: - tags: - - API Mediation Policy - summary: Update an API Specific Mediation Policy - description: | - This operation can be used to update an existing mediation policy of an API. - operationId: updateAPIMediationPolicyContentByPolicyId - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/mediationPolicyId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: +################################################################ +# The content resource of "Individual Document" resource APIs +################################################################ + + '/apis/{apiId}/documents/{documentId}/content': + + #------------------------------------------------------------------------------------------------- + # Downloads a FILE type document/get the inline content or source url of a certain document + #------------------------------------------------------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\" > sample.pdf" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content + Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a + x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" + summary: Get the content of an API document + description: | + This operation can be used to retrive the content of an API's document. + + The document can be of 3 types. In each cases responses are different. + + 1. **Inline type**: + The content of the document will be retrieved in `text/plain` content type + + _Sample cURL_ : `curl -k -H "Authorization:Bearer 579f0af4-37be-35c7-81a4-f1f1e9ee7c51" -F inlineContent=@"docs.txt" -X POST "https://localhost:9443/api/am/publisher/v0.12/apis/995a4972-3178-4b17-a374-756e0e19127c/documents/43c2bcce-60e7-405f-bc36-e39c0c5e189e/content` + 2. **FILE type**: + The file will be downloaded with the related content type (eg. `application/pdf`) + 3. **URL type**: + The client will recieve the URL of the document as the Location header with the response with - `303 See Other` + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Document (Individual) + responses: + 200: + description: | + OK. + File or inline content returned. + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 303: + description: | + See Other. + Source can be retrived from the URL specified at the Location header. + headers: + Location: + description: | + The Source URL of the document. + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + 404: + description: | + Not Found. + Requested Document does not exist. schema: - required: - - type - properties: - file: - type: string - description: Mediation Policy to upload - format: binary - inlineContent: - type: string - description: Inline content of the Mediation Policy - type: - type: string - description: Type of the mediation sequence(in/out/fault) - required: true - responses: - 200: - description: | - OK. - Successful response with updated API object - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Mediation' - 400: - $ref: '#/components/responses/BadRequest' - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - - apim:mediation_policy_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@TokenExchange.xml -F type=@type.txt "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/mediation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a/content"' - x-examples: - $ref: docs/examples/mediation-policies/apis_id_mediationpolicies_id_content_put.yaml + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' - /apis/{apiId}/wsdl-info: - get: - tags: - - APIs - summary: Get WSDL Meta Information - description: | - This operation can be used to retrieve the WSDL meta information of an API. It states whether the API is a SOAP - API. If the API is a SOAP API, it states whether it has a single WSDL or a WSDL archive. - operationId: getWSDLInfoOfAPI - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Requested WSDL meta information of the API is returned - content: - application/json: - schema: - $ref: '#/components/schemas/WSDLInfo' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/wsdl-info"' - x-examples: - $ref: docs/examples/apis/wsdl/apiId_wsdl_info_get.yaml + #---------------------------------------------------------------------------- + # Upload a file or add inline content to a document of a certain API + #---------------------------------------------------------------------------- + post: + consumes: + - multipart/form-data + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -F file=@\"sample.pdf\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\"" + x-wso2-request: | + POST https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/documents/b3a79270-02bb-4e39-9ac1-90ce8f6c84af/content + Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + Content-Length: 8004 + Content-Type: multipart/form-data; boundary=------------------------7b9a53f1ffa452b9 + --------------------------7b9a53f1ffa452b9 + Content-Disposition: form-data; name="file"; filename="sample.pdf" + Content-Type: application/octet-stream + + [file content] + + --------------------------7b9a53f1ffa452b9-- + x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/documents/b3a79270-02bb-4e39-9ac1-90ce8f6c84af/content\nContent-Type: application/json\n\n{\n \"visibility\":\"API_LEVEL\",\n \"sourceType\":\"FILE\",\n \"sourceUrl\":null,\n \"otherTypeName\":null,\n \"documentId\":\"daf732d3-bda2-46da-b381-2c39d901ea61\",\n \"summary\":\"This is a sample documentation pdf\",\n \"name\":\"Introduction to PhoneVerification API PDF\",\n \"type\":\"HOWTO\"\n}" + summary: Upload the content of an API document + description: | + Thid operation can be used to upload a file or add inline content to an API document. + + **IMPORTANT:** + * Either **file** or **inlineContent** form data parameters should be specified at one time. + * Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. + * Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/documentId' + - in: formData + name: file + description: Document to upload + type: file + required: false + - in: formData + name: inlineContent + description: Inline content of the document + type: string + required: false + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Document (Individual) + responses: + 200: + description: | + OK. + Document updated + schema: + $ref: '#/definitions/Document' + headers: + Location: + description: | + The URL of the updated content of the document. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + + ##pp +###################################################### +# The "specific mediation policy" resource APIs +###################################################### + '/apis/{apiId}/policies/mediation': + + #----------------------------------------------------------------------------------------- + # Retrieving the list of all API specific mediation sequences under a given search condition + #----------------------------------------------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc\" https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation" + x-wso2-request: "GET https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\r\nAuthorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc" + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"count\": 1,\r\n \"next\": null,\r\n \"previous\": null,\r\n \"list\": [ {\r\n \"name\": \"add_custom_header_fault\",\r\n \"id\": \"6460d7e6-4272-4e3a-9879-437228d83123\",\r\n \"type\": \"fault\"\r\n }]\r\n}" + summary: | + Get all mediation policies of an API + description: | + This operation provides you a list of available mediation policies of an API. + parameters: + - $ref: '#/parameters/apiId' + - $ref : '#/parameters/limit' + - $ref : '#/parameters/offset' + - name : query + in: query + description: "-Not supported yet-" + type: string + - $ref : "#/parameters/Accept" + - $ref : "#/parameters/If-None-Match" + tags: + - Mediation Policy (Collection) + responses: + 200: + description: | + OK. + List of qualifying APIs is returned. + schema: + $ref: '#/definitions/mediationList' + headers: + Content-Type: + description: The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#---------------------------------------------------------------------------- +# Upload an API specific mediation policy +#---------------------------------------------------------------------------- + post: + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer 6cea3696-0151-3282-bf79-a0c4db6f308a\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\"" + x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\r\nContent-Type: application/json\r\nAuthorization: Bearer 6cea3696-0151-3282-bf79-a0c4db6f308a\r\n\r\n{\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" + x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: https://localhost:9443/api/am/publisher/v0.12/registry/resource/_system/governance/apimgt/applicationdata/provider/admin/hello/1.0.0/fault/add_custom_header_fault.xml\r\nContent-Type: application/json\r\n\r\n{ \r\n \"id\":\"624b9f7d-bfaf-484b-94cc-e84491f5d725\",\r\n \"name\":\"add_custom_header_fault\",\r\n \"type\":\"fault\",\r\n \"config\":\"\\n \\n\\n\"\r\n}" + summary: Add an API specific mediation policy + description: | + This operation can be used to add an API specifc mediation policy. + parameters: + - in: body + name: body + description: mediation policy to upload + required: true + schema: + $ref: '#/definitions/Mediation' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Mediation Policy (Collection) + responses: + 200: + description: | + OK. + mediation policy uploaded + schema: + $ref : '#/definitions/Mediation' + headers: + Location: + description: | + The URL of the uploaded thumbnail image of the API. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Individual API specific mediation sequence" resource +###################################################### + /apis/{apiId}/policies/mediation/{mediationPolicyId}: + +#----------------------------------------------------- +# Retrieve a particular API specific mediation squence +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer 5aa0acc0-0ce3-3a0b-8cc8-db5ef696ee23\" https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/624b9f7d-bfaf-484b-94cc-e84491f5d725" + x-wso2-request: "GET https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/624b9f7d-bfaf-484b-94cc-e84491f5d725\r\nAuthorization: Bearer 5aa0acc0-0ce3-3a0b-8cc8-db5ef696ee23" + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"id\": \"624b9f7d-bfaf-484b-94cc-e84491f5d725\",\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" + summary: Get an API specific mediation policy + description: | + This operation can be used to retrieve a particular API specific mediation policy. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/mediationPolicyId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Mediation Policy (Individual) + responses: + 200: + description: | + OK. + Mediation policy returned. + schema: + $ref: '#/definitions/Mediation' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + 404: + description: | + Not Found. + Requested Document does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Delete the mediation policy +#----------------------------------------------------- + delete: + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/60f5146d-1774-405d-86b3-9b040ac266d5" + x-wso2-request: "DELETE https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/60f5146d-1774-405d-86b3-9b040ac266d5\r\nAuthorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Delete an API specific mediation policy + description: | + This operation can be used to delete an existing API specific mediation policy providing the Id of the API and the Id of the mediation policy. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/mediationPolicyId' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Mediation Policy (Individual) + responses: + 200: + description: | + OK. + Resource successfully deleted. + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Update the a mediation policy +#----------------------------------------------------- + put: + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer 9e41fae2-3ada-3dd1-8f12-2077202f4285\" -H \"Content-Type: application/json\" -X PUT -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/820fdcf7-7258-42b5-809e-674b893644d1" + x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/820fdcf7-7258-42b5-809e-674b893644d1\r\nContent-Type: application/json\r\nAuthorization: Bearer 9e41fae2-3ada-3dd1-8f12-2077202f4285\r\n\r\n{\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"id\": \"a7365481-5b3f-463c-a646-a498895ac210\",\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" + summary: Update an API specific mediation policy + description: | + This operation can be used to update an existing mediation policy of an API. + parameters: + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/mediationPolicyId' + - in: body + name: body + description: | + Mediation policy object that needs to be updated + required: true + schema: + $ref: '#/definitions/Mediation' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Mediation Policy (Individual) + responses: + 200: + description: | + OK. + Successful response with updated API object + schema: + $ref: '#/definitions/Mediation' + headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The wsdl Resource +###################################################### /apis/{apiId}/wsdl: - get: - tags: - - APIs - summary: Get WSDL definition - description: | - This operation can be used to retrieve the WSDL definition of an API. It can be either a single WSDL file or a WSDL archive. - The type of the WSDL of the API is indicated at the "wsdlInfo" element of the API payload definition. - operationId: getWSDLOfAPI +#----------------------------------------------------- +# Retrieve the details about a certain wsdl +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/7f82f6b0-2667-441e-af23-c0fc44cf3a17/wsdl\"" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/apis/7f82f6b0-2667-441e-af23-c0fc44cf3a17/wsdl + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"name\": \"admin--hello1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" + summary: Get the WSDL of an API + description: | + This operation can be used to retrieve the WSDL definition of an API. parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/apiId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Wsdl (Individual) responses: 200: description: | OK. - Requested WSDL document of the API is returned + Requested WSDL DTO object belongs to the API + schema: + $ref: '#/definitions/Wsdl' headers: + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - content: {} + type: string + 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/wsdl"' - x-examples: - $ref: docs/examples/apis/wsdl/apiId_wsdl_get.yaml - - put: - tags: - - APIs - summary: Update WSDL Definition - description: | - This operation can be used to update the WSDL definition of an existing API. WSDL to be updated can be passed as either "url" or "file". - Only one of "url" or "file" can be used at the same time. "file" can be specified as a single WSDL file or as a zip file which has a WSDL - and its dependencies (eg: XSDs) - operationId: updateWSDLOfAPI - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - properties: - file: - type: string - description: WSDL file or archive to upload - format: binary - url: - type: string - description: WSDL Definition url - responses: - 200: description: | - OK. - Successful response with updated WSDL definition - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@api.wsdl "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/wsdl"' - x-examples: - $ref: docs/examples/apis/wsdl/apiId_wsdl_put.yaml - - /apis/{apiId}/graphql-policies/complexity: - get: - tags: - - GraphQL Policies - summary: Get the Complexity Related Details of an API - description: | - This operation can be used to retrieve complexity related details belonging to an API by providing the API id. - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Requested complexity details returned. - headers: - Content-Type: - description: | - The content of the body. - schema: - type: string - default: application/json - content: - application/json: - schema: - $ref: '#/components/schemas/GraphQLQueryComplexityInfo' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/graphql-policies/complexity"' - operationId: getGraphQLPolicyComplexityOfAPI - - - put: - tags: - - GraphQL Policies - summary: Update Complexity Related Details of an API - description: | - This operation can be used to update complexity details belonging to an API by providing the id of the API. - parameters: - - $ref: '#/components/parameters/apiId' - requestBody: - description: Role-depth mapping that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/GraphQLQueryComplexityInfo' - responses: - 200: - description: | - Created. - Complexity details created successfully. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/graphql-policies/complexity"' - operationId: updateGraphQLPolicyComplexityOfAPI - - /apis/{apiId}/graphql-policies/complexity/types: - get: - tags: - - GraphQL Policies - summary: Retrieve Types and Fields of a GraphQL Schema - description: | - This operation can be used to retrieve all types and fields of the GraphQL Schema by providing the API id. - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - Types and fields returned successfully. - headers: - Content-Type: - description: | - The content of the body. - schema: - type: string - default: application/json - content: - application/json: - schema: - $ref: '#/components/schemas/GraphQLSchemaTypeList' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/graphql-policies/complexity/types"' - operationId: getGraphQLPolicyComplexityTypesOfAPI - - /apis/{apiId}/resource-paths: - get: - tags: - - APIs - summary: Get Resource Paths of an API - description: | - This operation can be used to retrieve resource paths defined for a specific api. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - ResourcePaths returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modified the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePathList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/resource-paths"' - operationId: getAPIResourcePaths - - /apis/{apiId}/auditapi: - get: - tags: - - API Audit - summary: Retrieve the Security Audit Report of the Audit API - description: | - Retrieve the Security Audit Report of the Audit API - parameters: - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - The Security Audit Report has been returned. - headers: - Content-Type: - description: | - The content of the body. - schema: - type: string - default: application/json - content: - application/json: - schema: - $ref: '#/components/schemas/AuditReport' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/auditapi"' - x-examples: - $ref: "docs/examples/apis/apis_id_auditapi_get.yaml" - operationId: getAuditReportOfAPI - - /apis/{apiId}/external-stores: - get: - tags: - - External Stores - summary: Get the List of External Stores to which an API is Published - description: | - This operation can be used to retrieve a list of external stores which an API is published to by providing the id of the API. - operationId: getAllPublishedExternalStoresByAPI - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - External Store list is returned. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIExternalStoreList' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/external-stores"' - x-examples: - $ref: docs/examples/external-stores/external_stores.yaml#/getPublishedExternalStoresByAPI - - /apis/{apiId}/publish-to-external-stores: + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' +#----------------------------------------------------- +# Add a wsdl to the registry +#----------------------------------------------------- post: - tags: - - External Stores - summary: Publish an API to External Stores + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/af3f96da-9ccf-463f-8cee-13ec8530a9cd/wsdl\"" + x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/af3f96da-9ccf-463f-8cee-13ec8530a9cd/wsdl\r\nContent-Type: application/json\r\nAuthorization: Bearer 7d237cab-7011-3f81-b384-24d03e750873\r\n\r\n{\r\n \"name\": \"admin--PizzaShackAPI1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"name\": \"admin--PizzaShackAPI1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" + summary: Add a WSDL to an API description: | - This operation can be used to publish an API to a list of external stores. - operationId: publishAPIToExternalStores + This operation can be used to add a WSDL definition to an existing API. parameters: - - $ref: '#/components/parameters/apiId' - - name: externalStoreIds - in: query - description: External Store Ids of stores which the API needs to be published - or updated. + - $ref: '#/parameters/apiId' + - in: body + name: body + description: | + JSON payload including WSDL definition that needs to be added required: true schema: - type: string - - $ref: '#/components/parameters/If-Match' + $ref: '#/definitions/Wsdl' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Wsdl (Individual) responses: 200: description: | OK. - API was successfully published to all the selected external stores. + Successful response with updated wsdl definition headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | - Entity Tag of the blocked subscription. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + type: string Last-Modified: description: | - Date and time the subscription has been blocked. + Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIExternalStoreList' + type: string + 400: + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/publish-to-external-stores?externalStoreId=Store123#"' - x-examples: - $ref: docs/examples/external-stores/external_stores.yaml#/publishToExternalStore + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' - /apis/export: + +###################################################### +# The "Individual Application" resource APIs +###################################################### + '/applications/{applicationId}': + +#----------------------------------------------------- +# Retrieve the details about a certain application +#----------------------------------------------------- get: - tags: - - Import Export - summary: Export an API + x-scope: apim:api_create + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015 + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"name\": \"DefaultApplication\"\n}" + summary: Get details of an application description: | - This operation can be used to export the details of a particular API as a zip file. + This operation can be used to retrieve details of an individual application specifying the application id in the URI. parameters: - - name: apiId - in: query - description: UUID of the API - schema: - type: string - - name: name - in: query - description: | - API Name - schema: - type: string - - name: version - in: query - description: | - Version of the API - schema: - type: string - - name: revisionNumber - in: query - description: | - Revision number of the API artifact - schema: - type: string - - name: providerName - in: query - description: | - Provider name of the API - schema: - type: string - - name: format - in: query - description: | - Format of output documents. Can be YAML or JSON. - schema: - type: string - enum: - - JSON - - YAML - - name: preserveStatus - in: query - description: | - Preserve API Status on export - schema: - type: boolean - - name: latestRevision - in: query - description: | - Export the latest revision of the API - schema: - type: boolean - default: false + - $ref: '#/parameters/applicationId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Application (Individual) responses: 200: description: | OK. - Export Successful. + Application returned. + schema: + $ref: '#/definitions/Application' headers: Content-Type: description: | The content type of the body. - schema: - type: string - content: - application/zip: - schema: - type: string - format: binary + type: string + ETag: + description: | + Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_create - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/export?apiId=96077508-fd01-4fae-bc64-5de0e2baf43c&name=PizzaShackAPI&version=1.0&provider=admin&format=YAML" - > exportAPI.zip' - operationId: exportAPI + description: | + Not Found. + Requested application does not exist. + schema: + $ref: '#/definitions/Error' + 406: + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' - /apis/import: - post: - tags: - - Import Export - summary: Import an API - description: | - This operation can be used to import an API. - parameters: - - name: preserveProvider - in: query - description: | - Preserve Original Provider of the API. This is the user choice to keep or replace the API provider - required: false - schema: - type: boolean - - name: rotateRevision - in: query - description: | - Once the revision max limit reached, undeploy and delete the earliest revision and create a new revision - required: false - schema: - type: boolean - - name: overwrite - in: query - description: | - Whether to update the API or not. This is used when updating already existing APIs - required: false - schema: - type: boolean - requestBody: - content: - multipart/form-data: - schema: - required: - - file - properties: - file: - type: string - description: Zip archive consisting on exported api configuration - format: binary - responses: - 200: - description: | - Created. - API Imported Successfully. - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 409: - $ref: '#/components/responses/Conflict' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@admin-PizzaShackAPI-1.0.0.zip "https://127.0.0.1:9443/api/am/publisher/v2/apis/import?preserveProvider=false&overwrite=false"' - operationId: importAPI - - ###################################################### - # The "Subscription Collection" resource APIs - ###################################################### +###################################################### +# The "Subscription Collection" resource APIs +###################################################### /subscriptions: + +#----------------------------------------------------- +# Retrieve all subscriptions of a certain API +#----------------------------------------------------- get: - tags: - - Subscriptions + x-scope: apim:subscription_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b\"" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"previous\": \"\",\n \"list\": [\n {\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"subscriptionId\": \"7ac22c34-8745-4cfe-91e0-262c50b2f2e3\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" summary: Get all Subscriptions description: | This operation can be used to retrieve a list of subscriptions of the user associated with the provided access token. This operation is capable of 1. Retrieving all subscriptions for the user's APIs. - `GET https://127.0.0.1:9443/api/am/publisher/v2/subscriptions` + `GET https://localhost:9443/api/am/publisher/v0.12/subscriptions` 2. Retrieving subscriptions for a specific API. - `GET https://127.0.0.1:9443/api/am/publisher/v2/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed` + `GET https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed` parameters: - - $ref: '#/components/parameters/apiId-Q-Opt' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/If-None-Match' - - name: query - in: query - description: | - Keywords to filter subscriptions - schema: - type: string + - $ref: '#/parameters/apiId-Q' + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Subscription (Collection) responses: 200: description: | OK. Subscription list returned. + schema: + $ref: '#/definitions/SubscriptionList' headers: + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/SubscriptionList' + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:subscription_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions?apiId=96077508-fd01-4fae-bc64-5de0e2baf43c"' - operationId: getSubscriptions + description: | + Not Acceptable. The requested media type is not supported + schema: + $ref: '#/definitions/Error' - ###################################################### - # The Individual Subscription resource APIs - ###################################################### - /subscriptions/{subscriptionId}/usage: +###################################################### +# The "Individual Subscription" resource APIs +###################################################### + '/subscriptions/{subscriptionId}': + +#----------------------------------------------------- +# Retrieve a certain subscription +#----------------------------------------------------- get: - tags: - - API Monetization - summary: Get Details of a Pending Invoice for a Monetized Subscription with Metered Billing. + x-scope: apim:subscription_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809 + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n}" + summary: Get details of a subscription description: | - This operation can be used to get details of a pending invoice for a monetized subscription with meterd billing. + This operation can be used to get details of a single subscription. parameters: - - $ref: '#/components/parameters/subscriptionId' + - $ref: '#/parameters/subscriptionId' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Subscription (Individual) responses: 200: description: | OK. - Details of a pending invoice returned. + Subscription returned + schema: + $ref: '#/definitions/ExtendedSubscription' headers: - ETag: - description: Entity Tag of the response resource. Used by caches, or - in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: Date and time the resource has been modified the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string Content-Type: description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIMonetizationUsage' - 304: + type: string + ETag: + description: 'Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future).' + type: string + Last-Modified: + description: 'Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future).' + type: string + '304': description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: + '404': description: | Not Found. Requested Subscription does not exist. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - security: - - OAuth2Security: - - apim:subscription_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809/usage"' - operationId: getSubscriptionUsage - - /subscriptions/{subscriptionId}/subscriber-info: - get: - tags: - - Subscriber - summary: Get Details of a Subscriber - description: | - This operation can be used to get details of a user who subscribed to the API. - parameters: - - $ref: '#/components/parameters/subscriptionId' - responses: - 200: - description: | - OK. - Details of the subscriber are returned. - content: - application/json: - schema: - $ref: '#/components/schemas/SubscriberInfo' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:subscription_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809/subscriber-info"' - operationId: getSubscriberInfoBySubscriptionId + schema: + $ref: '#/definitions/Error' +###################################################### +# The "Block Subscription" Processing Function resource API +###################################################### /subscriptions/block-subscription: + +#----------------------------------------------------- +# Block a certain subscription +#----------------------------------------------------- post: - tags: - - Subscriptions - summary: Block a Subscription + x-scope: apim:subscription_block + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED\"" + x-wso2-request: | + POST https://localhost:9443/api/am/publisher/v0.12/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"PROD_ONLY_BLOCKED\"\n}" + summary: Block a subscription description: | This operation can be used to block a subscription. Along with the request, `blockState` must be specified as a query parameter. 1. `BLOCKED` : Subscription is completely blocked for both Production and Sandbox environments. 2. `PROD_ONLY_BLOCKED` : Subscription is blocked for Production environment only. parameters: - - $ref: '#/components/parameters/subscriptionId-Q' + - $ref: '#/parameters/subscriptionId-Q' - name: blockState in: query description: | Subscription block state. + type: string required: true - schema: - type: string - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - $ref: '#/components/parameters/If-Match' + enum: + - BLOCKED + - PROD_ONLY_BLOCKED + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Subscription (Individual) responses: 200: description: | @@ -4424,40 +1982,55 @@ paths: description: | Entity Tag of the blocked subscription. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the subscription has been blocked. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - content: {} + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested subscription does not exist. + schema: + $ref: '#/definitions/Error' 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:subscription_block - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED"' - operationId: blockSubscription + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' +###################################################### +# The "Unblock Subscription" Processing Function resource API +###################################################### /subscriptions/unblock-subscription: + +#----------------------------------------------------- +# Unblock a certain subscription +#----------------------------------------------------- post: - tags: - - Subscriptions + x-scope: apim:subscription_block + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809\"" + x-wso2-request: | + POST https://localhost:9443/api/am/publisher/v0.12/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809 + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8` + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n} " summary: Unblock a Subscription + parameters: + - $ref: '#/parameters/subscriptionId-Q' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' description: | This operation can be used to unblock a subscription specifying the subscription Id. The subscription will be fully unblocked after performing this operation. - parameters: - - $ref: '#/components/parameters/subscriptionId-Q' - - $ref: '#/components/parameters/If-Match' + tags: + - Subscription (Individual) responses: 200: description: | @@ -4468,7209 +2041,1651 @@ paths: description: | Entity Tag of the unblocked subscription. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the subscription has been unblocked. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - content: {} + type: string 400: - $ref: '#/components/responses/BadRequest' + description: | + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested subscription does not exist. + schema: + $ref: '#/definitions/Error' 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:subscription_block - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809"' - operationId: unBlockSubscription + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' +###################################################### +# The "Tier Collection" resource APIs +###################################################### + '/tiers/{tierLevel}': - ###################################################### - # The "Thorttling Tier Collection" resource APIs - ###################################################### - /throttling-policies/{policyLevel}: +#----------------------------------------------------- +# Retrieve the list of all available tiers +#----------------------------------------------------- get: - tags: - - Throttling Policies - summary: Get All Throttling Policies for the Given Type + x-scope: apim:tier_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/tiers/api" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/tiers/api + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"next\": \"\",\n \"count\": 4\n}" + summary: Get all tiers description: | - This operation can be used to list the available policies for a given policy level. Tier level should be specified as a path parameter and should be one of `subscription` and `api`. - `subscription` is for Subscription Level policies and `api` is for Resource Level policies - operationId: getAllThrottlingPolicies + This operation can be used to list the available tiers for a given tier level. Tier level should be specified as a path parameter and should be one of `api`, `application` and `resource`. parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/policyLevel' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/limit' + - $ref: '#/parameters/offset' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + tags: + - Throttling Tier (Collection) responses: 200: description: | OK. - List of policies returned. + List of tiers returned. + schema: + $ref: '#/definitions/TierList' headers: + Content-Type: + description: The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ThrottlingPolicyList' + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/throttling-policies/api"' + description: | + Not Acceptable. + The requested media type is not supported + schema: + $ref: '#/definitions/Error' - ###################################################### - # The "Subscription Throttling Based on Quota Type" resource APIs - ###################################################### - /throttling-policies/streaming/subscription: - get: - tags: - - Throttling Policies - summary: Get subscription throttling policies based on quota type +#----------------------------------------------------- +# Create a new tier +#----------------------------------------------------- + post: + x-scope: apim:tier_manage + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/api\"" + x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/tiers/api\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\":10,\n \"b\":30\n }\n}" + x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/tiers/Low\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"30\",\n \"a\": \"10\"\n }\n}" + summary: Create a Tier description: | - This operation can be used to list the available subscription policies for a given tenent ID based on the given quota type. - Quota Type should be provide as a query parameters and supported Quota types are "requestCount" ,"bandwidthVolume" and "eventCount" - operationId: getSubscriptionThrottlingPolicies + This operation can be used to create a new throttling tier. The only supported tier level is `api` tiers. + `POST https://localhost:9443/api/am/publisher/v0.12/tiers/api` + + **IMPORTANT:** + * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. parameters: - - $ref: '#/components/parameters/tierQuotaType' - - $ref: '#/components/parameters/If-None-Match' + - in: body + name: body + description: | + Tier object that should to be added + required: true + schema: + $ref: '#/definitions/Tier' + - $ref: '#/parameters/tierLevel-A' + - $ref: '#/parameters/Content-Type' + tags: + - Throttling Tier (Collection) responses: - 200: + 201: description: | - OK. - List of subscription policies returned. + Created. + Successful response with the newly created object as entity in the body. + Location header contains URL of newly created entity. + schema: + $ref: '#/definitions/Tier' headers: + Location: + description: | + Location of the newly created tier. + type: string + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ThrottlingPolicyList' - 304: + Used by caches, or in conditional request' + type: string + 400: description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/throttling-policies/subscription?tierQuotaType=RequestCountLimit"' + Bad Request. + Invalid request or validation error + schema: + $ref: '#/definitions/Error' + 415: + description: | + Unsupported media type. + The entity of the request was in a not supported format. - ###################################################### - # The "Individual Throttling Tier" resource APIs - ###################################################### - /throttling-policies/{policyLevel}/{policyName}: +###################################################### +# The "Individual Tier" resource APIs +###################################################### + '/tiers/{tierLevel}/{tierName}': + +#----------------------------------------------------- +# Retrieve a certain tier +#----------------------------------------------------- get: - tags: - - Throttling Policies - summary: Get Details of a Policy + x-scope: apim:tier_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/tiers/api/Bronze" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/tiers/api/Bronze + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" + summary: Get details of a tier description: | - This operation can be used to retrieve details of a single policy by specifying the policy level and policy name. - operationId: getThrottlingPolicyByName + This operation can be used to retrieve details of a single tier by specifying the tier level and tier name. + Note that the scope of the API is mandatory while retreiving the access token with the following cURL command : `curl -k -d \"grant_type=password&username=username&password=password&scope=apim:tier_view\" -H \"Authorization: Basic \" https://localhost:8243/token`. + You will receive the access token as the response, for example `"access_token":"8644c013-7ff1-3217-b150-d7b92cae6be7"`. parameters: - - $ref: '#/components/parameters/policyName' - - $ref: '#/components/parameters/policyLevel' - - $ref: '#/components/parameters/If-None-Match' + - $ref: '#/parameters/tierName' + - $ref: '#/parameters/tierLevel' + - $ref: '#/parameters/Accept' + - $ref: '#/parameters/If-None-Match' + - $ref: '#/parameters/If-Modified-Since' + tags: + - Throttling Tier (Individual) responses: 200: description: | OK. Tier returned + schema: + $ref: '#/definitions/Tier' headers: + Content-Type: + description: | + The content type of the body. + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string + type: string Last-Modified: description: | Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ThrottlingPolicy' + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 404: - $ref: '#/components/responses/NotFound' + description: | + Not Found. + Requested Tier does not exist. + schema: + $ref: '#/definitions/Error' 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/throttling-policies/api/Platinum"' + description: | + Not Acceptable. + The requested media type is not supported. + schema: + $ref: '#/definitions/Error' - ###################################################### - # The "Mediation Policy Collection" resource APIs - ###################################################### - /mediation-policies: - get: +#----------------------------------------------------- +# Update a certain tier +#----------------------------------------------------- + put: + x-scope: apim:tier_manage + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\"" + x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\": \"30\",\n \"b\": \"10\",\n \"c\": \"20\"\n }\n}\n" + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"10\",\n \"c\": \"20\",\n \"a\": \"30\"\n }\n}" + summary: Update a Tier + description: | + This operation can be used to update an existing tier. The only supported tier level is `api` tiers. + `PUT https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low` + + **IMPORTANT:** + * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. + parameters: + - $ref: '#/parameters/tierName' + - in: body + name: body + description: | + Tier object that needs to be modified + required: true + schema: + $ref: '#/definitions/Tier' + - $ref: '#/parameters/tierLevel-A' + - $ref: '#/parameters/Content-Type' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' tags: - - Global Mediation Policies + - Throttling Tier (Individual) + responses: + 200: + description: | + OK. + Subscription updated. + schema: + $ref: '#/definitions/Tier' + headers: + Location: + description: | + The URL of the newly created resource. + type: string + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the resource has been modifed the last time. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + The resource to be updated does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +#----------------------------------------------------- +# Delete a certain tier +#----------------------------------------------------- + delete: + x-scope: apim:tier_manage + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE \"https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\"" + x-wso2-request: | + DELETE https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK" + summary: Delete a Tier + description: | + This operation can be used to delete an existing tier. The only supported tier level is `api` tiers. + `DELETE https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low` + + **IMPORTANT:** + * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. + parameters: + - $ref: '#/parameters/tierName' + - $ref: '#/parameters/tierLevel-A' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + tags: + - Throttling Tier (Individual) + responses: + 200: + description: | + OK. + Resource successfully deleted. + 404: + description: | + Not Found. + Resource to be deleted does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + +###################################################### +# The "Update Permission" Processing Function resource API +###################################################### + '/tiers/update-permission': + +#----------------------------------------------------- +# Update the permission of a certain tier +#----------------------------------------------------- + post: + x-scope: apim:tier_manage + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/update-permission?tierName=Bronze&tierLevel=api\"" + x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/tiers/update-permission?tierName=Bronze&tierLevel=api\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"permissionType\":\"deny\",\n \"roles\": [\"Internal/everyone\",\"admin\"]\n}" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Update tier permission + description: | + This operation can be used to update tier permissions which controls access for the particular tier based on the subscribers' roles. + parameters: + - $ref: '#/parameters/tierName-Q' + - $ref: '#/parameters/tierLevel-Q' + - $ref: '#/parameters/If-Match' + - $ref: '#/parameters/If-Unmodified-Since' + - in: body + name: permissions + schema: + $ref: '#/definitions/TierPermission' + tags: + - Throttling Tier (Individual) + responses: + 200: + description: | + OK. + Successfully updated tier permissions + schema: + type: array + items: + $ref: '#/definitions/Tier' + headers: + ETag: + description: | + Entity Tag of the modified tier. + Used by caches, or in conditional requests (Will be supported in future). + type: string + Last-Modified: + description: | + Date and time the tier has been modified. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 400: + description: | + Bad Request. + Invalid request or validation error. + schema: + $ref: '#/definitions/Error' + 403: + description: | + Forbidden. + The request must be conditional but no condition has been specified. + schema: + $ref: '#/definitions/Error' + 404: + description: | + Not Found. + Requested tier does not exist. + schema: + $ref: '#/definitions/Error' + 412: + description: | + Precondition Failed. + The request has not been performed because one of the preconditions is not met. + schema: + $ref: '#/definitions/Error' + + +###################################################### +# The "Environment Collection" resource API +###################################################### + /environments: + +#----------------------------------------------------- +# Retrieve the list of environments configured for a certain API +#----------------------------------------------------- + get: + x-scope: apim:api_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/environments\"" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/environments + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"list\": [ {\n \"showInApiConsole\": true,\n \"serverUrl\": \"https://localhost:9443/services/\",\n \"endpoints\": {\n \"http\": \"http://localhost:8280\",\n \"https\": \"https://localhost:8243\"\n },\n \"name\": \"Production and Sandbox\",\n \"type\": \"hybrid\"\n }],\n \"count\": 1\n}" + summary: Get all gateway environments + description: | + This operation can be used to retrieve the list of gateway environments available. + parameters: + - $ref: '#/parameters/apiId-Q' + tags: + - Environment (Collection) + responses: + 200: + description: | + OK. + Environment list is returned. + schema: + $ref: '#/definitions/EnvironmentList' + headers: + Content-Type: + description: | + The content type of the body. + type: string + ETag: + description: | + Entity Tag of the response resource. + Used by caches, or in conditional requests (Will be supported in future). + type: string + 304: + description: | + Not Modified. + Empty body because the client has already the latest version of the requested resource (Will be supported in future). + 404: + description: | + Not Found. + Requested API does not exist. + schema: + $ref: '#/definitions/Error' + /policies/mediation: + +#----------------------------------------------------------------------------------------- +# Retrieving the list of all global mediation sequences under a given search condition +#----------------------------------------------------------------------------------------- + get: + x-scope: apim:mediation_policy_view + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/policies/mediation" + x-wso2-request: | + GET https://localhost:9443/api/am/publisher/v0.12/policies/mediation + Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 + x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"count\": 10,\r\n \"next\": null,\r\n \"previous\": null,\r\n \"list\": [\r\n {\r\n \"name\": \"debug_json_fault\",\r\n \"id\": \"563de8f3-dd1d-4ec7-afc2-d158c663ed34\",\r\n \"type\": \"fault\"\r\n },\r\n {\r\n \"name\": \"json_fault\",\r\n \"id\": \"f9c36f4d-a2b6-41e7-b311-d358a47916be\",\r\n \"type\": \"fault\"\r\n },\r\n {\r\n \"name\": \"json_to_xml_in_message\",\r\n \"id\": \"3921225b-7918-4b95-a851-22c4e4e3e911\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"debug_in_flow\",\r\n \"id\": \"2bc15f93-4455-4763-89b8-83600fb9d731\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"log_in_message\",\r\n \"id\": \"4d287cca-76ab-44ca-b22e-919fc27c50e3\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"preserve_accept_header\",\r\n \"id\": \"3776b215-b3bc-40b6-bdcb-06efa7de64be\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"xml_to_json_in_message\",\r\n \"id\": \"50ac2002-769e-4f90-8549-6d0248dff7d2\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"xml_to_json_out_message\",\r\n \"id\": \"2af75853-ed75-4d25-81aa-0ebbeca691ea\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"json_to_xml_out_message\",\r\n \"id\": \"d9fa3ffc-f6b6-4171-ab97-eb44196cb66e\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"debug_out_flow\",\r\n \"id\": \"260b7701-4071-46bd-9b66-900ac6fffed6\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"apply_accept_header\",\r\n \"id\": \"15c17c2f-33e3-4c37-a262-04dfa49983a4\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"log_out_message\",\r\n \"id\": \"d37dca41-c048-492a-82cf-9a2292c6fff0\",\r\n \"type\": \"out\"\r\n }\r\n ]\r\n}" summary: | Get all global level mediation policies description: | This operation provides you a list of available all global level mediation policies. - operationId: getAllGlobalMediationPolicies parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - name: query + - $ref : '#/parameters/limit' + - $ref : '#/parameters/offset' + - name : query in: query - description: -Not supported yet- - schema: - type: string - - $ref: '#/components/parameters/If-None-Match' + description: "-Not supported yet-" + type: string + - $ref : "#/parameters/Accept" + - $ref : "#/parameters/If-None-Match" + tags: + - Mediation Policy (Collection) responses: 200: description: | OK. List of mediation policies is returned. + schema: + $ref: '#/definitions/mediationList' headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string Content-Type: description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/MediationList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - - apim:mediation_policy_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/mediation-policies"' - x-examples: - $ref: docs/examples/mediation-policies/mediation_policies_get.yaml - - ################################################################### - # The "Individual Mediation Policy" resource - ################################################################### - /mediation-policies/{mediationPolicyId}/content: - get: - tags: - - Global Mediation Policy - summary: Download a Global Mediation Policy - description: | - This operation can be used to download a particular global mediation policy. - operationId: getGlobalMediationPolicyContent - parameters: - - $ref: '#/components/parameters/mediationPolicyId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Mediation policy returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_view - - apim:mediation_policy_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/mediation-policies/d48a3412-1b85-49be-99f4-b81a3722ae73/content" - > mediation.xml' - - /apis/{apiId}/client-certificates: - get: - tags: - - Client Certificates - summary: Retrieve/ Search Uploaded Client Certificates - description: | - This operation can be used to retrieve and search the uploaded client certificates. - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - name: alias - in: query - description: Alias for the client certificate - schema: - type: string - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. Successful response with the list of matching certificate information in the body. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ClientCertificates' - 400: - $ref: '#/components/responses/BadRequest' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - - apim:client_certificates_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates?alias=wso2carbon"' - operationId: getAPIClientCertificates - - post: - tags: - - Client Certificates - summary: Upload a New Certificate - description: | - This operation can be used to upload a new certificate for an endpoint. - parameters: - - $ref: '#/components/parameters/apiId' - requestBody: - content: - multipart/form-data: - schema: - required: - - alias - - certificate - - tier - properties: - certificate: - type: string - description: The certificate that needs to be uploaded. - format: binary - alias: - maxLength: 30 - minLength: 1 - type: string - description: Alias for the certificate - tier: - type: string - description: api tier to which the certificate should be applied. - required: true - responses: - 200: - description: | - OK. - The Certificate added successfully. - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ClientCertMetadata' - 400: - $ref: '#/components/responses/BadRequest' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_create - - apim:client_certificates_add - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: multipart/form-data" -F certificate=@test.crt -F alias=wso2carbon - -F apiId=fea749dd-d548-4a8b-b308-34903b39a34b -F tier=Gold "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates"' - operationId: addAPIClientCertificate - - /apis/{apiId}/client-certificates/{alias}: - get: - tags: - - Client Certificates - summary: Get the Certificate Information - description: | - This operation can be used to get the information about a certificate. - parameters: - - name: alias - in: path - required: true - schema: - type: string - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/CertificateInfo' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - - apim:client_certificates_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon"' - operationId: getAPIClientCertificateByAlias - - put: - tags: - - Client Certificates - summary: Update a Certificate - description: | - This operation can be used to update an uploaded certificate. - parameters: - - name: alias - in: path - description: Alias for the certificate - required: true - schema: - maxLength: 30 - minLength: 1 - type: string - - $ref: '#/components/parameters/apiId' - requestBody: - content: - multipart/form-data: - schema: - properties: - certificate: - type: string - description: The certificate that needs to be uploaded. - format: binary - tier: - type: string - description: The tier of the certificate - responses: - 200: - description: | - OK. - The Certificate updated successfully. - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ClientCertMetadata' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_create - - apim:client_certificates_update - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: multipart/form-data" -F certificate=@test.crt -F alias=wso2carbon - -F apiId=fea749dd-d548-4a8b-b308-34903b39a34b -F tier=Gold "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon"' - operationId: updateAPIClientCertificateByAlias - - delete: - tags: - - Client Certificates - summary: Delete a Certificate - description: | - This operation can be used to delete an uploaded certificate. - parameters: - - name: alias - in: path - description: | - The alias of the certificate that should be deleted. - required: true - schema: - type: string - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. - The Certificate deleted successfully. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_create - - apim:client_certificates_update - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon"' - operationId: deleteAPIClientCertificateByAlias - - /apis/{apiId}/client-certificates/{alias}/content: - get: - tags: - - Client Certificates - summary: Download a Certificate - description: | - This operation can be used to download a certificate which matches the given alias. - parameters: - - $ref: '#/components/parameters/apiId' - - name: alias - in: path - required: true - schema: - type: string - responses: - 200: - description: | - OK. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - - apim:client_certificates_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/client-certificates/wso2carbon/content"' - operationId: getAPIClientCertificateContentByAlias - - ###################################################### - # The "Certificate Management" resource APIs - ###################################################### - /endpoint-certificates: - get: - tags: - - Endpoint Certificates - summary: Retrieve/Search Uploaded Certificates - description: | - This operation can be used to retrieve and search the uploaded certificates. - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - name: alias - in: query - description: Alias for the certificate - schema: - maxLength: 30 - type: string - - name: endpoint - in: query - description: Endpoint of which the certificate is uploaded - schema: - type: string - responses: - 200: - description: | - OK. Successful response with the list of matching certificate information in the body. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Certificates' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - - apim:ep_certificates_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates?alias=wso2carbon&endpoint=www.abc.com"' - operationId: getEndpointCertificates - - post: - tags: - - Endpoint Certificates - summary: Upload a new Certificate. - description: | - This operation can be used to upload a new certificate for an endpoint. - requestBody: - content: - multipart/form-data: - schema: - required: - - alias - - certificate - - endpoint - properties: - certificate: - type: string - description: The certificate that needs to be uploaded. - format: binary - alias: - maxLength: 30 - minLength: 1 - type: string - description: Alias for the certificate - endpoint: - type: string - description: Endpoint to which the certificate should be applied. - required: true - responses: - 200: - description: | - OK. - The Certificate added successfully. - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/CertMetadata' - 400: - $ref: '#/components/responses/BadRequest' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_create - - apim:ep_certificates_add - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: multipart/form-data" -F certificate=@test.crt -F alias=alias - -F "endpoint=endpoint=https://www.abc.com" "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/endpoint-certificates"' - operationId: addEndpointCertificate - - /endpoint-certificates/{alias}: - get: - tags: - - Endpoint Certificates - summary: Get the Certificate Information - description: | - This operation can be used to get the information about a certificate. - parameters: - - name: alias - in: path - required: true - schema: - type: string - responses: - 200: - description: | - OK. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/CertificateInfo' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - - apim:ep_certificates_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates/wso2carbon"' - operationId: getEndpointCertificateByAlias - - put: - tags: - - Endpoint Certificates - summary: Update a certificate. - description: | - This operation can be used to update an uploaded certificate. - parameters: - - name: alias - in: path - description: Alias for the certificate - required: true - schema: - maxLength: 30 - minLength: 1 - type: string - requestBody: - content: - multipart/form-data: - schema: - required: - - certificate - properties: - certificate: - type: string - description: The certificate that needs to be uploaded. - format: binary - required: true - responses: - 200: - description: | - OK. - The Certificate updated successfully. - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/CertMetadata' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_create - - apim:ep_certificates_update - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: multipart/form-data" -F certificate=@test.crt "https://127.0.0.1:9443/api/am/publisher/v2/apis/d48a3412-1b85-49be-99f4-b81a3722ae73/endpoint-certificates/wso2carbon"' - operationId: updateEndpointCertificateByAlias - - delete: - tags: - - Endpoint Certificates - summary: Delete a certificate. - description: | - This operation can be used to delete an uploaded certificate. - parameters: - - name: alias - in: path - description: | - The alias of the certificate that should be deleted. - required: true - schema: - type: string - responses: - 200: - description: | - OK. - The Certificate deleted successfully. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_create - - apim:ep_certificates_update - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates/wso2carbon"' - operationId: deleteEndpointCertificateByAlias - - /endpoint-certificates/{alias}/content: - get: - tags: - - Endpoint Certificates - summary: Download a Certificate - description: | - This operation can be used to download a certificate which matches the given alias. - parameters: - - name: alias - in: path - required: true - schema: - type: string - responses: - 200: - description: | - OK. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - - apim:ep_certificates_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/endpoint-certificates/wso2carbon/content"' - operationId: getEndpointCertificateContentByAlias - - ###################################################### - # The "Content Search Results" resource APIs - ###################################################### - /search: - get: - tags: - - Unified Search - summary: | - Retrieve/Search APIs and API Documents by Content - description: | - This operation provides you a list of available APIs and API Documents qualifying the given keyword match. - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - name: query - in: query - description: | - **Search**. - - You can search by proving a keyword. - schema: - type: string - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - List of qualifying APIs and API documents is returned. - headers: + type: string ETag: description: | Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/SearchResultList' + type: string 304: description: | Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - - apim:api_import_export - - apim:api_product_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/search?query=pizza"' - x-examples: - $ref: docs/examples/apis/search_get.yaml - operationId: search - - ###################################################### - # The "API Product Collection" resource APIs - ###################################################### - /api-products: - get: - tags: - - API Products - summary: | - Retrieve/Search API Products - description: | - This operation provides you a list of available API Products qualifying under a given search condition. - - Each retrieved API Product is represented with a minimal amount of attributes. If you want to get complete details of an API Product, you need to use **Get details of an API Product** operation. - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - name: query - in: query + description: | + Not Acceptable. + The requested media type is not supported schema: - type: string - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - List of qualifying API Products is returned. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIProductList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products?query=PizzaAPIProduct"' - operationId: getAllAPIProducts + $ref: '#/definitions/Error' + + +###################################################### +# The "Workflow approval" resource API +###################################################### + /workflows/update-workflow-status: + +#------------------------------------------------------------------- +# Resume the workflow by approving or rejecting the workflow request +#------------------------------------------------------------------- post: - tags: - - API Products - summary: Create a New API Product + x-scope: apim:api_workflow + x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/workflows/update-workflow-status?workflowReferenceId=56e3a170-a7a7-45f8-b051-7e43a58a67e1\"" + x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/workflows/update-workflow-status?workflowReferenceId=56e3a170-a7a7-45f8-b051-7e43a58a67e1\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"status\" : \"APPROVED\",\n \"attributes\" : {\n \"apiCurrentState\": \"Created\",\n \"apiLCAction\": \"Publish\",\n \"apiName\":\"APIname\",\n \"apiVersion\" : \"1.0.0\",\n \"apiProvider\" : \"admin\",\n \"invoker\": \"admin\"\n }\n}" + x-wso2-response: "HTTP/1.1 200 OK" + summary: Update workflow status description: | - This operation can be used to create a new API Product specifying the details of the API Product in the payload. - requestBody: - description: API object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/APIProduct' - required: true + This operation can be used to approve or reject a workflow task. + parameters: + - $ref: '#/parameters/workflowReferenceId-Q' + - in: body + name: body + description: | + Workflow event that need to be updated + required: true + schema: + $ref: '#/definitions/Workflow' + tags: + - Workflows (Individual) responses: - 201: + 200: description: | - 'Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity.' + OK. + Workflow request information is returned. + schema: + $ref: '#/definitions/Workflow' headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string Content-Type: description: | The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIProduct' + type: string 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products"' - operationId: createAPIProduct - - ################################################################ - # The "Individual API Product" resource APIs - ################################################################ - /api-products/{apiProductId}: - get: - tags: - - API Products - summary: Get Details of an API Product - description: | - Using this operation, you can retrieve complete details of a single API Product. You need to provide the Id of the API to retrive it. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: description: | - OK. - Requested API Product is returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIProduct' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33"' - operationId: getAPIProduct - - put: - tags: - - API Products - summary: Update an API Product - description: | - This operation can be used to update an existing API product. - But the properties `name`, `provider` and `version` cannot be changed. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/If-Match' - requestBody: - description: API object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/APIProduct' - required: true - responses: - 200: - description: | - OK. - Successful response with updated API product object - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIProduct' - 400: - $ref: '#/components/responses/BadRequest' - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33"' - operationId: updateAPIProduct - - - delete: - tags: - - API Products - summary: Delete an API Product - description: | - This operation can be used to delete an existing API Product proving the Id of the API Product. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/If-Match' - responses: - 200: - description: | - OK. - Resource successfully deleted. - content: {} - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_product_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33"' - operationId: deleteAPIProduct - - /api-products/{apiProductId}/thumbnail: - get: - tags: - - API Products - summary: Get Thumbnail Image - description: | - This operation can be used to download a thumbnail image of an API product. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Thumbnail image returned - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/thumbnail" - > image.jpeg' - operationId: getAPIProductThumbnail - - put: - tags: - - API Products - summary: Upload a Thumbnail Image - description: | - This operation can be used to upload a thumbnail image of an API Product. The thumbnail to be uploaded should be given as a form data parameter `file`. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - required: - - file - properties: - file: - type: string - description: Image to upload - format: binary - required: true - responses: - 200: - description: | - OK. - Image updated - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the uploaded thumbnail image of the API Product. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/FileInfo' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: multipart/form-data" -F file=@image.jpeg "https://127.0.0.1:9443/api/am/publisher/v2/api-products/d48a3412-1b85-49be-99f4-b81a3722ae73/thumbnail"' - operationId: updateAPIProductThumbnail - - /api-products/{apiProductId}/swagger: - get: - tags: - - API Products - summary: Get Swagger Definition - description: | - This operation can be used to retrieve the swagger definition of an API. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Requested swagger document of the API is returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/swagger"' - operationId: getAPIProductSwagger - - /api-products/{apiProductId}/is-outdated: - get: - tags: - - API Products - summary: Check Whether API Product is Outdated - description: | - This operation can be used to retrieve the status indicating if an API Product is outdated due to updating of dependent APIs (This resource is not supported at the moment) - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Requested swagger document of the API is returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/APIProductOutdatedStatus' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - operationId: getIsAPIProductOutdated - - /api-products/{apiProductId}/documents: - get: - tags: - - API Product Documents - summary: Get a List of Documents of an API Product - description: | - This operation can be used to retrive a list of documents belonging to an API Product by providing the id of the API Product. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Document list is returned. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/DocumentList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents"' - operationId: getAPIProductDocuments - - post: - tags: - - API Product Documents - summary: Add a New Document to an API Product - description: | - This operation can be used to add a new documentation to an API Product. This operation only adds the metadata of a document. To add the actual content we need to use **Upload the content of an API Product document ** API once we obtain a document Id by this operation. - parameters: - - $ref: '#/components/parameters/apiProductId' - requestBody: - description: Document object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - required: true - responses: - 201: - description: | - Created. - Successful response with the newly created Document object as entity in the body. - Location header contains URL of newly added document. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - Location to the newly created Document. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents"' - operationId: addAPIProductDocument - - /api-products/{apiProductId}/documents/{documentId}: - get: - tags: - - API Product Documents - summary: Get a Document of an API Product - description: | - This operation can be used to retrieve a particular document's metadata associated with an API. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Document returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3"' - operationId: getAPIProductDocument - - put: - tags: - - API Product Documents - summary: Update a Document of an API Product - description: | - This operation can be used to update metadata of an API's document. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-Match' - requestBody: - description: Document object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - required: true - responses: - 200: - description: | - OK. - Document updated - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the updated document. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3"' - operationId: updateAPIProductDocument - - delete: - tags: - - API Product Documents - summary: Delete a Document of an API Product - description: | - This operation can be used to delete a document associated with an API Product. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-Match' - responses: - 200: - description: | - OK. - Resource successfully deleted. - content: {} - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3"' - operationId: deleteAPIProductDocument - - /api-products/{apiProductId}/documents/{documentId}/content: - get: - tags: - - API Product Documents - summary: Get the Content of an API Product Document - description: | - This operation can be used to retrive the content of an API's document. - - The document can be of 3 types. In each cases responses are different. - - 1. **Inline type**: - The content of the document will be retrieved in `text/plain` content type - - _Sample cURL_ : `curl -k -H "Authorization:Bearer 579f0af4-37be-35c7-81a4-f1f1e9ee7c51" -F inlineContent=@"docs.txt" -X POST "https://localhost:9443/api/am/publisher/v2/apis/995a4972-3178-4b17-a374-756e0e19127c/documents/43c2bcce-60e7-405f-bc36-e39c0c5e189e/content` - 2. **FILE type**: - The file will be downloaded with the related content type (eg. `application/pdf`) - 3. **URL type**: - The client will recieve the URL of the document as the Location header with the response with - `303 See Other` - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/Accept' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - File or inline content returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 303: - description: | - See Other. - Source can be retrived from the URL specified at the Location header. - headers: - Location: - description: | - The Source URL of the document. - schema: - type: string - content: {} - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3/content"' - operationId: getAPIProductDocumentContent - - post: - tags: - - API Product Documents - summary: Upload the Content of an API Product Document - description: | - Thid operation can be used to upload a file or add inline content to an API Product document. - - **IMPORTANT:** - * Either **file** or **inlineContent** form data parameters should be specified at one time. - * Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. - * Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/documentId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - properties: - file: - type: string - description: Document to upload - format: binary - inlineContent: - type: string - description: Inline content of the document - responses: - 200: - description: | - OK. - Document updated - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the updated content of the document. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: multipart/form-data" -F file=@sample.pdf "https://127.0.0.1:9443/api/am/publisher/v2/api-products/5bca47e1-8233-46a5-9295-525dca337f33/documents/83312daf-0d8a-427b-8f72-12755b7901d3/content"' - operationId: addAPIProductDocumentContent - - ###################################################### - # The "API Product Revisions" resource API - ###################################################### - /api-products/{apiProductId}/revisions: - - #-------------------------------------------- - # List available revisions of an API Product - #-------------------------------------------- - get: - tags: - - API Product Revisions - summary: List available revisions of an API Product - description: | - List available revisions of an API Product - operationId: getAPIProductRevisions - parameters: - - $ref: '#/components/parameters/apiProductId' - - name: query - in: query + Bad Request. + Invalid request or validation error. schema: - type: string - responses: - 200: - description: | - OK. - List of API Product revisions are returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevisionList' + $ref: '#/definitions/Error' 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_product_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions?query=deployed:true"' - - #-------------------------------------------- - # Create a new API Product revision - #-------------------------------------------- - post: - tags: - - API Product Revisions - summary: Create a new API Product revision - description: | - Create a new API Product revision - operationId: createAPIProductRevision - parameters: - - $ref: '#/components/parameters/apiProductId' - requestBody: - description: API Product object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevision' - responses: - 201: description: | - Created. - Successful response with the newly created APIRevision object as the entity in the body. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevision' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions"' - - ###################################################### - # The "API Revisions" individual resource API Product - ###################################################### - /api-products/{apiProductId}/revisions/{revisionId}: - - #-------------------------------------------- - # Get a revision - #-------------------------------------------- - get: - tags: - - API Product Revisions - summary: Retrieve a revision of an API Product - description: | - Retrieve a revision of an API Product - operationId: getAPIProductRevision - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/revisionId' - responses: - 200: - description: | - OK. - An API revision is returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevision' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' - - #-------------------------------------------- - # Delete a revision - #-------------------------------------------- - delete: - tags: - - API Product Revisions - summary: Delete a revision of an API Product - description: | - Delete a revision of an API Product - operationId: deleteAPIProductRevision - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/revisionId' - responses: - 200: - description: | - OK. - List of remaining API revisions are returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevisionList' - 204: - description: | - No Content. - Successfully deleted the revision - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/revisions/e0824883-3e86-403a-aec1-22bbc454eb7c"' - - /api-products/{apiProductId}/deploy-revision: - - #-------------------------------------------- - # List available deployed revision deployment details of an API Product - #-------------------------------------------- - get: - tags: - - API Product Revisions - summary: List available deployed revision deployment details of an API Product - description: | - List available deployed revision deployment details of an API Product - operationId: getAPIProductRevisionDeployments - parameters: - - $ref: '#/components/parameters/apiProductId' - responses: - 200: - description: | - OK. - List of deployed revision deployment details are returned. - content: - application/json: - schema: - $ref: '#/components/schemas/APIRevisionDeploymentList' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision"' - - #-------------------------------------------- - # Deploy a revision - #-------------------------------------------- - post: - tags: - - API Product Revisions - summary: Deploy a revision - description: | - Deploy a revision - operationId: deployAPIProductRevision - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/revisionId-Q' - requestBody: - description: Deployment object that needs to be added - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - responses: - 200: - description: | - OK. - 201: - description: | - Created. - Successful response with the newly deployed APIRevisionDeployment List object as the entity in the body. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/deploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' - - /api-products/{apiProductId}/undeploy-revision: - #-------------------------------------------- - # Un-Deploy a revision from deployed gateway - #-------------------------------------------- - post: - tags: - - API Product Revisions - summary: Un-Deploy a revision - description: | - Un-Deploy a revision - operationId: undeployAPIProductRevision - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/revisionId-Q' - - $ref: '#/components/parameters/revisionNum-Q' - - name: allEnvironments - in: query + Not Found. + Workflow for the given reference in not found. schema: - type: boolean - default: false - requestBody: - description: Deployment object that needs to be added - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - responses: - 200: - description: | - OK. - 201: - description: | - Created. - Successful response with the newly undeployed APIRevisionDeploymentList object as the entity in the body. - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - - apim:api_product_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/undeploy-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' + $ref: '#/definitions/Error' +###################################################### +# Parameters - required by some of the APIs above +###################################################### +parameters: - /api-products/{apiProductId}/restore-revision: +# API Identifier +# Specified as part of the path expression + apiId: + name: apiId + in: path + description: | + **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. + Should be formatted as **provider-name-version**. + required: true + type: string + x-encoded: true - #-------------------------------------------------------- - # Restore a revision to the working copy of the API Product - #-------------------------------------------------------- - post: - tags: - - API Product Revisions - summary: Restore a revision - description: | - Restore a revision to the working copy of the API Product - operationId: restoreAPIProductRevision - parameters: - - $ref: '#/components/parameters/apiProductId' - - $ref: '#/components/parameters/revisionId-Q' - responses: - 201: - description: | - Restored. - Successful response with the newly restored API Product object as the entity in the body. - content: - application/json: - schema: - $ref: '#/components/schemas/APIProduct' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/restore-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"' +# API Identifier +# Specified as part of the query string + apiId-Q: + name: apiId + in: query + description: | + **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. + The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. + Should be formatted as **provider-name-version**. + required: true + type: string + x-encoded: true - /api-products/export: - get: - tags: - - Import Export - summary: Export an API Product - description: | - This operation can be used to export the details of a particular API Product as a zip file. - parameters: - - name: name - in: query - description: | - API Product Name - schema: - type: string - - name: version - in: query - description: | - Version of the API Product - schema: - type: string - - name: providerName - in: query - description: | - Provider name of the API Product - schema: - type: string - - name: revisionNumber - in: query - description: | - Revision number of the API Product - schema: - type: string - - name: format - in: query - description: | - Format of output documents. Can be YAML or JSON. - schema: - type: string - enum: - - JSON - - YAML - - name: preserveStatus - in: query - description: | - Preserve API Product Status on export - schema: - type: boolean - - name: latestRevision - in: query - description: | - Export the latest revision of the API Product - schema: - type: boolean - default: false - responses: - 200: - description: | - OK. - Export Successful. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/zip: - schema: - type: string - format: binary - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-products/export?name=LeasingAPIProduct&version=1.0.0&revisionNumber=2&provider=admin&format=YAML" - > exportAPIProduct.zip' - operationId: exportAPIProduct - /api-products/import: - post: - tags: - - Import Export - summary: Import an API Product - description: | - This operation can be used to import an API Product. - parameters: - - name: preserveProvider - in: query - description: | - Preserve Original Provider of the API Product. This is the user choice to keep or replace the API Product provider - required: false - schema: - type: boolean - - name: rotateRevision - in: query - description: | - Once the revision max limit reached, undeploy and delete the earliest revision and create a new revision - required: false - schema: - type: boolean - - name: importAPIs - in: query - description: | - Whether to import the dependent APIs or not. - schema: - type: boolean - - name: overwriteAPIProduct - in: query - description: | - Whether to update the API Product or not. This is used when updating already existing API Products. - schema: - type: boolean - - name: overwriteAPIs - in: query - description: | - Whether to update the dependent APIs or not. This is used when updating already existing dependent APIs of an API Product. - schema: - type: boolean - requestBody: - content: - multipart/form-data: - schema: - required: - - file - properties: - file: - type: string - description: | - Zip archive consisting on exported API Product configuration - format: binary - responses: - 200: - description: | - Created. - API Product Imported Successfully. - content: {} - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 409: - $ref: '#/components/responses/Conflict' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_product_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@admin-PizzaShackAPIProduct.zip "https://127.0.0.1:9443/api/am/admin/v2/api-products/importt?preserveProvider=false&overwriteAPIProduct=false&overwriteAPIs=false&importAPIs=false"' - operationId: importAPIProduct +# Document Identifier +# Specified as part of the path expression + documentId: + name: documentId + in: path + description: | + Document Identifier + required: true + type: string - ###################################################### - # Roles resource APIs - ###################################################### - /roles/{roleId}: - head: - tags: - - Roles - summary: Check Whether Given Role Name already Exist - description: | - Using this operation, user can check a given role name exists or not. - operationId: validateSystemRole - parameters: - - $ref: '#/components/parameters/roleId' - responses: - 200: - description: OK. Requested role name exists. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/roles/SW50ZXJuYWwvcHVibGlzaGVyCQ"' +# Application Identifier +# Specified as part of the path expression + applicationId: + name: applicationId + in: path + description: | + **Application Identifier** consisting of the UUID of the Application. + required: true + type: string - /me/roles/{roleId}: - head: - tags: - - Roles - summary: Validate Whether the Logged-in User has the Given Role - description: | - Using this operation, logged-in user can check whether he has given role. - operationId: validateUserRole - parameters: - - $ref: '#/components/parameters/roleId' - responses: - 200: - description: OK. Requested user has the role. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/me/roles/SW50ZXJuYWwvcHVibGlzaGVyCQ"' +# Subscription Identifier +# Specified as part of the path expression + subscriptionId: + name: subscriptionId + in: path + description: | + Subscription Id + required: true + type: string - ###################################################### - # The "ExternalStore Collection" resource APIs - ###################################################### - /external-stores: - get: - tags: - - External Stores - summary: Retrieve External Stores List to Publish an API - description: | - Retrieve external stores list configured to publish an API - operationId: getAllExternalStores - responses: - 200: - description: | - OK. - External Stores list returned - content: - application/json: - schema: - $ref: '#/components/schemas/ExternalStore' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/external-stores"' +# Mediation policy identifier +# Specified as part of the path expression + mediationPolicyId: + name: mediationPolicyId + in: path + description: | + Mediation policy Id + required: true + type: string - ###################################################### - # The Publisher settings resource APIs - ###################################################### - /settings: - get: - tags: - - Settings - summary: Retreive Publisher Settings - description: | - Retreive publisher settings - responses: - 200: - description: | - OK. - Settings returned - content: - application/json: - schema: - $ref: '#/components/schemas/Settings' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:publisher_settings - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/settings"' - operationId: getSettings - ###################################################### - # The tenant resource APIs - ###################################################### - /tenants: - get: - tags: - - Tenants - summary: | - Get Tenants by State - description: | - This operation is to get tenants by state - operationId: getTenantsByState - parameters: - - name: state - in: query - description: | - The state represents the current state of the tenant - Supported states are [active, inactive] - schema: - type: string - default: active - enum: - - active - - inactive - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - responses: - 200: - description: | - OK. - Tenant names returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/TenantList' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/tenants?state=active"' +# Subscription Identifier +# Specified as part of the query string + subscriptionId-Q: + name: subscriptionId + in: query + description: | + Subscription Id + required: true + type: string - /tenants/{tenantDomain}: - head: - tags: - - Tenants - summary: Check Whether the Given Tenant already Exists - description: | - Using this operation, user can check whether a given tenant exists or not. - operationId: getTenantExistence - parameters: - - $ref: '#/components/parameters/tenantDomain' - responses: - 200: - description: OK. Requested tenant exists. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/tenants/wso2.com"' - x-examples: - $ref: docs/examples/tenants/tenants.yaml +# Tier Name +# Specified as part of the path expression + tierName: + name: tierName + in: path + description: | + Tier name + required: true + type: string - #################################################### - # Publisher Alerts management REST API - #################################################### - /alert-types: - get: - tags: - - Alerts - summary: | - Get the list of API Publisher alert types. - description: | - This operation is used to get the list of supportd alert types for the 'publisher' agent. - operationId: getPublisherAlertTypes - responses: - 200: - description: | - OK. - The list of publisher alert types are returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/AlertTypesList' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:pub_alert_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/alert-types"' - x-examples: - $ref: docs/examples/alerts/alerts.yaml#/get +# Tier Name +# Specified as part of the query string + tierName-Q: + name: tierName + in: query + description: | + Name of the tier + required: true + type: string - /alert-subscriptions: - get: - tags: - - Alert Subscriptions - summary: | - Get the List of API Publisher Alert Types Subscribed by the User - description: | - This operation is used to get the list of subscribed alert types by the user. - operationId: getSubscribedAlertTypes - responses: - 200: - description: | - OK. - The list of subscribed alert types are returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/AlertsInfo' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:pub_alert_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/alert-subscriptions"' - x-examples: - $ref: docs/examples/alerts/alerts_subscriptions.yaml#/get +# Tier Type +# Specified as part of the path expression + tierLevel: + name: tierLevel + in: path + description: | + List API or Application or Resource type tiers. + type: string + enum: + - api + - application + - resource + required: true - put: - tags: - - Alert Subscriptions - summary: | - Subscribe to the Selected Tlert types by the User - description: | - This operation is used to get the list of subscribed alert types by the user. - operationId: subscribeToAlerts - requestBody: - description: The alerts list and the email list to subscribe. - content: - application/json: - schema: - $ref: '#/components/schemas/AlertsInfo' - required: true - responses: - 201: - description: | - OK. - Successful response with the newly subscribed alerts. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/AlertsInfoResponse' - 400: - $ref: '#/components/responses/BadRequest' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:pub_alert_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/alert-subscriptions"' - x-examples: - $ref: docs/examples/alerts/alerts_subscriptions.yaml#/put +# Tier Type +# Specified as part of the path expression + tierLevel-A: + name: tierLevel + in: path + description: | + List API or Application or Resource type tiers. + type: string + enum: + - api + required: true - delete: - tags: - - Alert Subscriptions - summary: | - Unsubscribe User from All the Alert Types - description: | - This operation is used to unsubscribe the respective user from all the alert types. - operationId: unsubscribeAllAlerts - responses: - 200: - description: | - OK. - The user is unsubscribed from the alerts successfully. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: {} - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:pub_alert_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/alert-subscriptions"' - x-examples: - $ref: docs/examples/alerts/alerts_subscriptions.yaml#/delete +# Tier Type +# Specified as part of the query string + tierLevel-Q: + name: tierLevel + in: query + description: | + List API or Application or Resource type tiers. + type: string + enum: + - api + - application + - resource + required: true - /alerts/{alertType}/configurations: - get: - tags: - - Alert Configuration - summary: | - Get All AbnormalRequestsPerMin Alert Configurations - description: | - This operation is used to get all configurations of the AbnormalRequestsPerMin alert type. - operationId: getAllAlertConfigs - parameters: - - $ref: '#/components/parameters/alertType' - responses: - 200: - description: | - OK. - The Developer Portal alert configuration. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/AlertConfigList' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:pub_alert_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/alerts/{alertType}/configurations"' - x-examples: - $ref: docs/examples/alerts/alerts_config.yaml#/get +# Used for pagination: +# The maximum number of resoures to be returned by a GET + limit: + name: limit + in: query + description: | + Maximum length of resource array to return. + default: 25 + type: integer - /alerts/{alertType}/configurations/{configurationId}: - put: - tags: - - Alert Configuration - summary: | - Add AbnormalRequestsPerMin Alert Configurations. - description: | - This operation is used to add configuration for the AbnormalRequestsPerMin alert type. - operationId: addAlertConfig - parameters: - - $ref: '#/components/parameters/alertType' - - $ref: '#/components/parameters/configurationId' - requestBody: - description: Configuration for AbnormalRequestCount alert type - content: - application/json: - schema: - $ref: '#/components/schemas/AlertConfigInfo' - required: true - responses: - 201: - description: | - Created. - Successful response with newly created object as entity. - Location header contains URL of newly created entity. - headers: - Location: - description: | - The location of the newly created entity. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/AlertConfig' - 400: - $ref: '#/components/responses/BadRequest' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:pub_alert_manage - x-examples: - $ref: docs/examples/alerts/alerts_config.yaml#/put +# Used for pagination: +# The order number of an instance in a qualified set of resoures +# at which to start to return the next batch of qualified resources + offset: + name: offset + in: query + description: | + Starting point within the complete list of items qualified. + default: 0 + type: integer - delete: - tags: - - Alert Configuration - summary: | - Delete the Selected Configuration from AbnormalRequestsPerMin Alert Type. - description: | - This operation is used to delete configuration from the AbnormalRequestsPerMin alert type. - operationId: deleteAlertConfig - parameters: - - $ref: '#/components/parameters/alertType' - - $ref: '#/components/parameters/configurationId' - responses: - 200: - description: | - OK. - The alert config is deleted successfully. - content: {} - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:pub_alert_manage - x-examples: - $ref: docs/examples/alerts/alerts_config.yaml#/delete +# The HTTP Accept header + Accept: + name: Accept + in: header + description: | + Media types acceptable for the response. Default is application/json. + default: application/json + type: string - ###################################################### - # The "Label Collection" resource API - ###################################################### - /labels: - get: - tags: - - Label Collection - summary: Get all Registered Labels - description: | - Get all registered Labels - responses: - 200: - description: | - OK. - Labels returned - content: - application/json: - schema: - $ref: '#/components/schemas/LabelList' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/labels"' - operationId: getLabels +# The HTTP Content-Type header + Content-Type: + name: Content-Type + in: header + description: | + Media type of the entity in the body. Default is application/json. + default: application/json + required: true + type : string - ###################################################### - # The "API Category Collection" resource API - ###################################################### - /api-categories: - get: - tags: - - API Category (Collection) - summary: Get all API categories - description: | - Get all API categories - responses: - 200: - description: | - OK. - Categories returned - content: - application/json: - schema: - $ref: '#/components/schemas/APICategoryList' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/api-categories"' - operationId: getAllAPICategories +# The HTTP Authorization header + Authorization: + name: Authorization + in: header + description: | + Holds the bearer token for apis that require authentication. + required: true + type : string - ###################################################### - # The "Scopes" resource APIs - ###################################################### - /scopes: - get: - tags: - - Scopes - summary: Get All Available Shared Scopes - description: | - This operation can be used to get all the available Shared Scopes. - operationId: getSharedScopes - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - responses: - 200: - description: | - OK. - Shared Scope list is returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ScopeList' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/scopes"' +# The HTTP If-None-Match header +# Used to avoid retrieving data that are already cached + If-None-Match: + name: If-None-Match + in: header + description: | + Validator for conditional requests; based on the ETag of the formerly retrieved + variant of the resource (Will be supported in future). + type : string - post: - tags: - - Scopes - summary: Add a New Shared Scope - description: | - This operation can be used to add a new Shared Scope. - operationId: addSharedScope - requestBody: - description: Scope object that needs to be added - content: - application/json: - schema: - $ref: '#/components/schemas/Scope' - required: true - responses: - 201: - description: | - Created. - Successful response with the newly created Scope object as an entity in the body. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Scope' - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:shared_scope_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/scopes"' +# The HTTP If-Modified-Since header +# Used to avoid retrieving data that are already cached + If-Modified-Since: + name: If-Modified-Since + in: header + description: | + Validator for conditional requests; based on Last Modified header of the + formerly retrieved variant of the resource (Will be supported in future). + type: string - /scopes/{scopeId}: - get: - tags: - - Scopes - summary: Get a Shared Scope by Scope Id - description: | - This operation can be used to retrieve details of a Shared Scope by a given scope Id. - operationId: getSharedScope - parameters: - - $ref: '#/components/parameters/scopeId' - responses: - 200: - description: | - OK. - Requested Shared Scope is returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Scope' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901"' +# The HTTP If-Match header +# Used to avoid concurrent updates + If-Match: + name: If-Match + in: header + description: | + Validator for conditional requests; based on ETag (Will be supported in future). + type: string - put: - tags: - - Scopes - summary: Update a Shared Scope - description: | - This operation can be used to update a Shared Scope by a given scope Id. - operationId: updateSharedScope - parameters: - - $ref: '#/components/parameters/scopeId' - requestBody: - description: Scope object that needs to be updated - content: - application/json: - schema: - $ref: '#/components/schemas/Scope' - required: true - responses: - 200: - description: | - OK. - Successful response with updated Scope object - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Scope' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:shared_scope_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901"' +# The HTTP If-Unmodified-Since header +# Used to avoid concurrent updates + If-Unmodified-Since: + name: If-Unmodified-Since + in: header + description: | + Validator for conditional requests; based on Last Modified header (Will be supported in future). + type: string - delete: - tags: - - Scopes - summary: Delete a Shared Scope - description: | - This operation can be used to delete a Shared Scope proving the Id of the scope. - operationId: deleteSharedScope - parameters: - - $ref: '#/components/parameters/scopeId' - responses: - 200: - description: | - OK. - Resource successfully deleted. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:shared_scope_manage - x-code-samples: - - lang: Curl - source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901"' - head: - tags: - - Scopes - summary: Check Given Scope Name already Exists - description: | - Using this operation, user can check a given scope name exists or not. - operationId: validateScope - parameters: - - $ref: '#/components/parameters/scopeName' - responses: - 200: - description: OK. Requested scope name exists. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create - - apim:api_publish - x-code-samples: - - lang: Curl - source: 'curl -k -I -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/scopes/YXBpbTphcGlfdmlldw"' +# Workflow reference ID +# Specified as part of the path expression + workflowReferenceId-Q: + name: workflowReferenceId + in: query + description: | + Workflow reference id + required: true + type: string - /scopes/{scopeId}/usage: - get: - tags: - - Scopes - summary: Get usages of a Shared Scope by Scope Id - description: | - This operation can be used to retrieve usages of a Shared Scope by a given scope Id. - operationId: getSharedScopeUsages - parameters: - - $ref: '#/components/parameters/scopeId' - responses: - 200: - description: | - OK. - Usages of the shared scope is returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/SharedScopeUsage' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/scopes/01234567-0123-0123-0123-012345678901/usage"' +###################################################### +# The resources used by some of the APIs above within the message body +###################################################### +definitions: - ###################################################### - # The "Key Managers Collection" resource API - ###################################################### - /key-managers: - get: - tags: - - Key Managers (Collection) - summary: Get All Key Managers - description: | - Get all Key managers - responses: - 200: - description: | - OK. - Categories returned - content: - application/json: - schema: - $ref: '#/components/schemas/KeyManagerList' - security: - - OAuth2Security: - - apim:api_create - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/key-managers"' - operationId: getAllKeyManagers +#----------------------------------------------------- +# The API List resource +#----------------------------------------------------- + APIList: + title: API List + properties: + count: + type: integer + description: | + Number of APIs returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/apis?limit=1&offset=2&query=" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/apis?limit=1&offset=0&query=" + list: + type: array + items: + $ref: '#/definitions/APIInfo' + pagination: + properties: + offset: + type: integer + example: 12 + limit: + type: integer + example: 25 + total: + type: integer + example: 1290 - ###################################################### - # The "Deployments" resource APIs - ###################################################### - /deployments: - get: - tags: - - Deployments - summary: Retrieve Deployment Environments Details - description: | - This operation can be used to retrieve cloud clusters information defines in tenant-conf.json file. - - With that you can deploy an API to selected cloud environments. - operationId: deploymentsGet - responses: - 200: - description: | - OK. Successful response with the list of deployment environments information in the body. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/DeploymentList' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/deployments"' - - /apis/{apiId}/deployments: - get: - tags: - - DeploymentStatus - summary: Retrieve Deployment Status Details - description: | - This operation can be used to retrieve the status of deployments in cloud clusters. - - With that you can get the status of the deployed APIs in cloud environments. - operationId: deploymentsGetStatus - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. Successful response with the list of deployment environments information in the body. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/DeploymentStatusList' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apim:api_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/am/publisher/v2/apis/92bc1330-1848-4fe8-b992-c792186c212e/deployments/"' - - /apis/validate-asyncapi: - post: - tags: - - Validation - summary: Validate an AsyncAPI Specification +#----------------------------------------------------- +# The API Info resource +#----------------------------------------------------- + APIInfo: + title: API Info object with basic API details. + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorAPI description: - This operation can be used to validate and AsyncAPI Specification and retrieve a summary. Provide either 'url' - or 'file' to specify the definition. - operationId: validateAsyncAPISpecification - parameters: - - name: returnContent - in: query - description: - Specify whether to return the full content of the AsyncAPI specification in the response. This is only - applicable when using url based validation - schema: - type: boolean - default: false - requestBody: - content: - multipart/form-data: - schema: - properties: - url: - type: string - description: AsyncAPI definition url - file: - type: string - description: AsyncAPI definition as a file - format: binary - responses: - 200: - description: - OK. - API definition validation information is returned - headers: - Content-Type: - description: - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/AsyncAPISpecificationValidationResponse' - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apim:api_create + type: string + example: A calculator API that supports basic operations + context: + type: string + example: CalculatorAPI + version: + type: string + example: 1.0.0 + provider: + description: | + If the provider value is not given, the user invoking the API will be used as the provider. + type: string + example: admin + status: + type: string + example: CREATED + thumbnailUri: + type: string + example: /apis/01234567-0123-0123-0123-012345678901/thumbnail - /apis/import-asyncapi: - post: - tags: - - APIs - summary: import an AsyncAPI Specification - description: - This operation can be used to create and API from the AsyncAPI Specification. Provide either 'url' or 'file' - to specify the definition. - - Specify additionalProperties with **at least** API's name, version, context and endpointConfig. - operationId: importAsyncAPISpecification - requestBody: - content: - multipart/form-data: - schema: - properties: - file: - type: string - description: Definition to upload as a file - format: binary - url: - type: string - description: Definition url - additionalProperties: - type: string - description: Additional attributes specified as a stringified JSON with API's schema - responses: - 201: - description: - Created. Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - headers: - Etag: - description: - Entity Tag of the respons resource. Used by caches, or in conditional requests (Will be supported in the future). - schema: - type: string - Location: - description: - The URL of the newly created resource. - schema: - type: string - Content-type: - description: - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/API' - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apim:api_create - - /apis/{apiId}/asyncapi: - get: - tags: - - APIs - summary: Get AsyncAPI definition - description: | - This operation can be used to retrieve the AsyncAPI definition of an API. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - Requested AsyncAPI definition of the API is returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Willl= be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has beed modified the last time. - Used by caches, or in conditional request (Will be supported in future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - type: string - example: "" - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - content: { } - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apim:api_view - - put: - tags: - - APIs - summary: Update AsyncAPI definition - description: | - This operation can be used to update the AsyncAPI definition of an existing API. AsyncAPI definition to be updated is passed as a form data parameter 'apiDefinition'. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/If-Match' - requestBody: - content: - multipart/form-data: - schema: - properties: - apiDefinition: - type: string - description: AsyncAPI definition of the API - url: - type: string - description: AsyncAPI definition URL of the API - file: - type: string - description: AsyncAPI definition as a file - format: binary - responses: - 200: - description: | - OK. - Successful response with updated AsyncAPI definition - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has beed modified the last time. - Use =d by caches, or in conditional requests (Will be supported in future). - schema: - type: string - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - type: string - example: "" - 400: - $ref: '#/components/responses/BadRequest' - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 412: - $ref: '#/components/responses/PreconditionFailed' - security: - - OAuth2Security: - - apim:api_create - -components: - schemas: - Comment: - title: Comment - required: - - content - type: object - properties: - id: - type: string - readOnly: true - example: 943d3002-000c-42d3-a1b9-d6559f8a4d49 - content: - maxLength: 512 - type: string - example: This is a comment - createdTime: - type: string - readOnly: true - example : 2021-02-11-09:57:25 - createdBy: - type: string - readOnly: true - example: admin - updatedTime: - type: string - readOnly: true - example : 2021-02-12-19:57:25 - category: - type: string - default: general - parentCommentId: - type: string - example: 6f38aea2-f41e-4ac9-b3f2-a9493d00ba97 - entryPoint: - type: string - enum: [devPortal, publisher] - commenterInfo: - $ref: '#/components/schemas/CommenterInfo' - replies: - $ref: '#/components/schemas/CommentList' - CommentList: - title: Comments List - type: object - properties: - count: - type: integer - description: | - Number of Comments returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Comment' - pagination: - $ref: '#/components/schemas/Pagination' - CommenterInfo: - type: object - properties: - firstName: - type: string - example: John - lastName: - type: string - example: David - fullName: - type: string - example: John David - APIList: - title: API List - type: object - properties: - count: - type: integer - description: | - Number of APIs returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/APIInfo' - pagination: - $ref: '#/components/schemas/Pagination' - APIListExpanded: - title: API List - type: object - properties: - count: - type: integer - description: | - Number of APIs returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/API' - pagination: - $ref: '#/components/schemas/Pagination' - - APIInfo: - title: API Info object with basic API details. - type: object - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - type: string - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - example: admin - type: - type: string - example: HTTP - lifeCycleStatus: - type: string - example: CREATED - workflowStatus: - type: string - example: APPROVED - hasThumbnail: - type: boolean - example: true - securityScheme: - type: array - items: - type: string - - Topic: - title: Topic object - required: +#----------------------------------------------------- +# The API resource +#----------------------------------------------------- + API: + title: API object + required: - name - - mode - - description - type: object - properties: - id: - type: string - description: id - readOnly: true - example: 1222344 - name: - maxLength: 50 - minLength: 1 - pattern: '(^[^~!@#;:%^*()+={}|\\<>"'',&$\s+]*$)' - type: string - example: PizzaShackAPI - mode: - maxLength: 32766 - type: string - example: This is a simple API for Pizza Shack online pizza delivery store. - description: - maxLength: 32766 - type: string - example: This is a simple API for Pizza Shack online pizza delivery store. - TopicList: - title: Topic List - type: object - properties: - count: - type: integer - description: | - Number of Topics returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Topic' - pagination: - $ref: '#/components/schemas/Pagination' - API: - title: API object - required: - - context - - name - - version - type: object - properties: - id: - type: string - description: | - UUID of the api registry artifact - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - name: - maxLength: 50 - minLength: 1 - pattern: '(^[^~!@#;:%^*()+={}|\\<>"'',&$\s+]*$)' - type: string - example: PizzaShackAPI - description: - maxLength: 32766 - type: string - example: This is a simple API for Pizza Shack online pizza delivery store. - context: - maxLength: 82 - minLength: 1 - type: string - example: pizza - version: - maxLength: 30 - minLength: 1 - type: string - pattern: '^[^~!@#;:%^*()+={}|\\<>"'',&/$]+$' - example: 1.0.0 - provider: - maxLength: 50 - type: string - description: | - If the provider value is not given user invoking the api will be used as the provider. - example: admin - lifeCycleStatus: - type: string - example: CREATED - x-otherScopes: - - apim:api_publish - wsdlInfo: - $ref: '#/components/schemas/WSDLInfo' - wsdlUrl: - type: string - readOnly: true - example: /apimgt/applicationdata/wsdls/admin--soap1.wsdl - testKey: - type: string - readOnly: true - example: 8swdwj9080edejhj - responseCachingEnabled: - type: boolean - example: true - cacheTimeout: - type: integer - example: 300 - destinationStatsEnabled: - type: string - example: Disabled - hasThumbnail: - type: boolean - example: false - isDefaultVersion: - type: boolean - example: false - isRevision: - type: boolean - example: false - revisionedApiId: - type: string - description: | - UUID of the api registry artifact - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - revisionId: - type: integer - example: 1 - enableSchemaValidation: - type: boolean - example: false - enableStore: - type: boolean - example: true - x-otherScopes: - - apim:api_publish - type: - type: string - description: The api creation type to be used. Accepted values are HTTP, - WS, SOAPTOREST, GRAPHQL, WEBSUB, SSE - example: HTTP - default: HTTP - enum: - - HTTP - - WS - - SOAPTOREST - - SOAP - - GRAPHQL - - WEBSUB - - SSE - transport: - type: array - description: | - Supported transports for the API (http and/or https). - example: - - http - - https - items: - type: string - tags: - type: array - example: - - pizza - - food - items: - type: string - x-otherScopes: - - apim:api_publish - policies: - type: array - example: - - Unlimited - items: - type: string - x-otherScopes: - - apim:api_publish - apiThrottlingPolicy: - type: string - description: The API level throttling policy selected for the particular - API - example: Unlimited - x-otherScopes: - - apim:api_publish - authorizationHeader: - type: string - description: | - Name of the Authorization header used for invoking the API. If it is not set, Authorization header name specified - in tenant or system level will be used. - example: Authorization - securityScheme: - type: array - description: | - Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If - it is not set OAuth2 will be set as the security for the current API. - example: - - oauth2 - items: - type: string - maxTps: - $ref: '#/components/schemas/APIMaxTps' - visibility: - type: string - description: The visibility level of the API. Accepts one of the following. - PUBLIC, PRIVATE, RESTRICTED. - example: PUBLIC - default: PUBLIC - enum: - - PUBLIC - - PRIVATE - - RESTRICTED - x-otherScopes: - - apim:api_publish - visibleRoles: - type: array - description: The user roles that are able to access the API in Developer Portal - example: [] - items: - type: string - x-otherScopes: - - apim:api_publish - visibleTenants: - type: array - example: [] - items: - type: string - endpointSecurity: - $ref: '#/components/schemas/APIEndpointSecurity' - gatewayEnvironments: - type: array - description: | - List of gateway environments the API is available - example: - - Production and Sandbox - items: - type: string - x-otherScopes: - - apim:api_publish - deploymentEnvironments: - type: array - description: | - List of selected deployment environments and clusters - items: - $ref: '#/components/schemas/DeploymentEnvironments' - x-otherScopes: - - apim:api_publish - labels: - type: array - description: | - Labels of micro-gateway environments attached to the API. - example: [] - items: - type: string - mediationPolicies: - type: array - example: - - name: json_to_xml_in_message - type: in - - name: xml_to_json_out_message - type: out - - name: json_fault - type: fault - items: - $ref: '#/components/schemas/MediationPolicy' - subscriptionAvailability: - type: string - description: The subscription availability. Accepts one of the following. - CURRENT_TENANT, ALL_TENANTS or SPECIFIC_TENANTS. - example: CURRENT_TENANT - default: CURRENT_TENANT - enum: - - CURRENT_TENANT - - ALL_TENANTS - - SPECIFIC_TENANTS - x-otherScopes: - - apim:api_publish - subscriptionAvailableTenants: - type: array - example: [] - items: - type: string - additionalProperties: - type: object - additionalProperties: - type: string - description: Map of custom properties of API - x-otherScopes: - - apim:api_publish - monetization: - $ref: '#/components/schemas/APIMonetizationInfo' - accessControl: - type: string - description: | - Is the API is restricted to certain set of publishers or creators or is it visible to all the - publishers and creators. If the accessControl restriction is none, this API can be modified by all the - publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, - based on the restriction. - default: NONE - enum: - - NONE - - RESTRICTED - accessControlRoles: - type: array - description: The user roles that are able to view/modify as API publisher - or creator. - example: [] - items: - type: string - businessInformation: - $ref: '#/components/schemas/APIBusinessInformation' - x-otherScopes: - - apim:api_publish - corsConfiguration: - $ref: '#/components/schemas/APICorsConfiguration' - websubSubscriptionConfiguration: - $ref: '#/components/schemas/WebsubSubscriptionConfiguration' - workflowStatus: - type: string - example: APPROVED - createdTime: - type: string - lastUpdatedTime: - type: string - x-otherScopes: - - apim:api_publish - endpointConfig: - type: object - properties: {} - description: | - Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. - - `Simple REST Endpoint` - { - "endpoint_type": "http", - "sandbox_endpoints": { - "url": "https://localhost:9443/am/sample/pizzashack/v1/api/" - }, - "production_endpoints": { - "url": "https://localhost:9443/am/sample/pizzashack/v1/api/" - } - } - - `Loadbalanced Endpoint` - - { - "endpoint_type": "load_balance", - "algoCombo": "org.apache.synapse.endpoints.algorithms.RoundRobin", - "sessionManagement": "", - "sandbox_endpoints": [ - { - "url": "https://localhost:9443/am/sample/pizzashack/v1/api/1" - }, - { - "endpoint_type": "http", - "template_not_supported": false, - "url": "https://localhost:9443/am/sample/pizzashack/v1/api/2" - } - ], - "production_endpoints": [ - { - "url": "https://localhost:9443/am/sample/pizzashack/v1/api/3" - }, - { - "endpoint_type": "http", - "template_not_supported": false, - "url": "https://localhost:9443/am/sample/pizzashack/v1/api/4" - } - ], - "sessionTimeOut": "", - "algoClassName": "org.apache.synapse.endpoints.algorithms.RoundRobin" - } - - `Failover Endpoint` - - { - "production_failovers":[ - { - "endpoint_type":"http", - "template_not_supported":false, - "url":"https://localhost:9443/am/sample/pizzashack/v1/api/1" - } - ], - "endpoint_type":"failover", - "sandbox_endpoints":{ - "url":"https://localhost:9443/am/sample/pizzashack/v1/api/2" - }, - "production_endpoints":{ - "url":"https://localhost:9443/am/sample/pizzashack/v1/api/3" - }, - "sandbox_failovers":[ - { - "endpoint_type":"http", - "template_not_supported":false, - "url":"https://localhost:9443/am/sample/pizzashack/v1/api/4" - } - ] - } - - `Default Endpoint` - - { - "endpoint_type":"default", - "sandbox_endpoints":{ - "url":"default" - }, - "production_endpoints":{ - "url":"default" - } - } - - `Endpoint from Endpoint Registry` - { - "endpoint_type": "Registry", - "endpoint_id": "{registry-name:entry-name:version}", - } - example: - endpoint_type: http - sandbox_endpoints: - url: https://localhost:9443/am/sample/pizzashack/v1/api/ - production_endpoints: - url: https://localhost:9443/am/sample/pizzashack/v1/api/ - endpointImplementationType: - type: string - example: INLINE - default: ENDPOINT - enum: - - INLINE - - ENDPOINT - scopes: - type: array - items: - $ref: '#/components/schemas/APIScope' - operations: - type: array - example: - - target: /order/{orderId} - verb: POST - authType: Application & Application User - throttlingPolicy: Unlimited - - target: /menu - verb: GET - authType: Application & Application User - throttlingPolicy: Unlimited - items: - $ref: '#/components/schemas/APIOperations' - threatProtectionPolicies: - type: object - properties: - list: - type: array - items: - type: object - properties: - policyId: - type: string - priority: - type: integer - categories: - type: array - description: | - API categories - items: - type: string - example: "" - x-otherScopes: - - apim:api_publish - keyManagers: - type: object - properties: {} - description: | - API Key Managers - readOnly: true - serviceInfo: - type: object - properties: - key: - type: string - example: PetStore-1.0.0 - name: - type: string - example: PetStore - version: - type: string - example: 1.0.0 - outdated: - type: boolean - example: false - x-scopes: - - apim:api_create - - apim:api_import_export - - #----------------------------------------------------- - # The API Revision resource - #----------------------------------------------------- - APIRevision: - title: API Info object with basic API details - properties: - displayName: - type: string - example: REVISION 1 - id: - type: string - example: c26b2b9b-4632-4ca4-b6f3-521c8863990c - description: - type: string - example: removed a post resource - createdTime: - type: string - format: date-time - apiInfo: - $ref: '#/components/schemas/APIRevisionAPIInfo' - deploymentInfo: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - - #----------------------------------------------------- - # The API Revision - API Info resource - #----------------------------------------------------- - APIRevisionAPIInfo: - title: API Info object with basic Revisioned API details - readOnly: true - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - - #----------------------------------------------------- - # The API Revision List resource - #----------------------------------------------------- - APIRevisionList: - title: API Revisions List - properties: - count: - type: integer - description: | - Number of API revisions returned - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/APIRevision' - #----------------------------------------------------- - # The API Revision Deployment List resource - #----------------------------------------------------- - APIRevisionDeploymentList: - title: API Revision to Deployment mapped object with basic API deployment details - properties: - list: - type: array - items: - $ref: '#/components/schemas/APIRevisionDeployment' - #----------------------------------------------------- - # The API Revision Deployment resource - #----------------------------------------------------- - APIRevisionDeployment: - title: APIRevisionDeployment Info object with basic API deployment details - properties: - revisionUuid: - type: string - example: c26b2b9b-4632-4ca4-b6f3-521c8863990c - name: - type: string - example: default - vhost: - maxLength: 255 - minLength: 1 - # hostname regex as per RFC 1123 (http://tools.ietf.org/html/rfc1123) and appended * - pattern: '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' - type: string - example: mg.wso2.com - displayOnDevportal: - type: boolean - example: true - deployedTime: - type: string - format: date-time - - AuditReport: - title: Resource for Audit Report - type: object - properties: - report: - type: string - description: | - The API Security Audit Report - grade: - type: string - description: | - The overall grade of the Security Audit - example: "27.95" - numErrors: - type: integer - description: | - The number of errors in the API Definition - example: 20 - externalApiId: - type: string - description: | - The External API ID - example: fd21f9f7-3674-49cf-8a83-dca401f635de - APIProductList: - title: API Product List - type: object - properties: - count: - type: integer - description: | - Number of API Products returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/APIProductInfo' - pagination: - $ref: '#/components/schemas/Pagination' - APIProductInfo: - title: API Info object with basic API details. - type: object - properties: - id: - type: string - description: | - UUID of the api product - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - description: Name of the API Product - example: PizzaShackAPIProduct - context: - type: string - example: pizzaproduct - description: - type: string - description: A brief description about the API - example: This is a simple API for Pizza Shack online pizza delivery store - provider: - type: string - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - example: admin - hasThumbnail: - type: boolean - example: true - state: - type: string - description: | - State of the API product. Only published api products are visible on the Developer Portal - enum: - - CREATED - - PUBLISHED - securityScheme: - type: array - description: | - Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If - it is not set OAuth2 will be set as the security for the current API. - example: - - oauth2 - items: - type: string - APIProduct: - title: API Product object - required: - - name - type: object - properties: - id: - type: string - description: | - UUID of the api product - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - name: - maxLength: 50 - minLength: 1 - type: string - description: Name of the API Product - example: PizzaShackAPIProduct - context: - maxLength: 60 - minLength: 1 - type: string - example: pizzaproduct - description: - type: string - description: A brief description about the API - example: This is a simple API for Pizza Shack online pizza delivery store - provider: - maxLength: 50 - type: string - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - example: admin - hasThumbnail: - type: boolean - example: false - state: - type: string - description: | - State of the API product. Only published api products are visible on the Developer Portal - enum: - - CREATED - - PUBLISHED - enableSchemaValidation: - type: boolean - example: false - enableStore: - type: boolean - example: true - testKey: - type: string - readOnly: true - example: 8swdwj9080edejhj - isRevision: - type: boolean - example: false - revisionedApiProductId: - type: string - description: | - UUID of the api product registry artifact - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - revisionId: - type: integer - example: 1 - responseCachingEnabled: - type: boolean - example: true - cacheTimeout: - type: integer - example: 300 - visibility: - type: string - description: The visibility level of the API. Accepts one of the following. - PUBLIC, PRIVATE, RESTRICTED. - example: PUBLIC - default: PUBLIC - enum: - - PUBLIC - - PRIVATE - - RESTRICTED - visibleRoles: - type: array - description: The user roles that are able to access the API - example: [] - items: - type: string - visibleTenants: - type: array - example: [] - items: - type: string - accessControl: - type: string - description: | - Defines whether the API Product is restricted to certain set of publishers or creators or is it visible to all the - publishers and creators. If the accessControl restriction is none, this API Product can be modified by all the - publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, - based on the restriction. - default: NONE - enum: - - NONE - - RESTRICTED - accessControlRoles: - type: array - description: The user roles that are able to view/modify as API Product - publisher or creator. - example: [] - items: - type: string - gatewayEnvironments: - type: array - description: | - List of gateway environments the API Product is available - example: - - Production and Sandbox - items: - type: string - apiType: - type: string - description: The API type to be used. Accepted values are API, APIPRODUCT - example: APIPRODUCT - enum: - - API - - APIPRODUCT - transport: - type: array - description: | - Supported transports for the API (http and/or https). - example: - - http - - https - items: - type: string - tags: - type: array - example: - - pizza - - food - items: - type: string - policies: - type: array - example: - - Unlimited - items: - type: string - apiThrottlingPolicy: - type: string - description: The API level throttling policy selected for the particular - API Product - example: Unlimited - authorizationHeader: - type: string - description: | - Name of the Authorization header used for invoking the API. If it is not set, Authorization header name specified - in tenant or system level will be used. - example: Authorization - securityScheme: - type: array - description: | - Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If - it is not set OAuth2 will be set as the security for the current API. - example: - - oauth2 - items: - type: string - subscriptionAvailability: - type: string - description: The subscription availability. Accepts one of the following. - CURRENT_TENANT, ALL_TENANTS or SPECIFIC_TENANTS. - example: CURRENT_TENANT - default: ALL_TENANTS - enum: - - CURRENT_TENANT - - ALL_TENANTS - - SPECIFIC_TENANTS - subscriptionAvailableTenants: - type: array - example: [] - items: - type: string - x-otherScopes: - - apim:api_publish - additionalProperties: - type: object - additionalProperties: - type: string - description: Map of custom properties of API - monetization: - $ref: '#/components/schemas/APIMonetizationInfo' - businessInformation: - $ref: '#/components/schemas/APIProductBusinessInformation' - corsConfiguration: - $ref: '#/components/schemas/APICorsConfiguration' - createdTime: - type: string - lastUpdatedTime: - type: string - apis: - type: array - description: | - APIs and resources in the API Product. - example: - - name: PizzaShackAPI - apiId: 01234567-0123-0123-0123-012345678901 - version: "1.0" - operations: - - target: /order/{orderId} - verb: POST - authType: Application & Application User - throttlingPolicy: Unlimited - - target: /menu - verb: GET - authType: Application & Application User - throttlingPolicy: Unlimited - items: - $ref: '#/components/schemas/ProductAPI' - scopes: - type: array - example: [] - items: - $ref: '#/components/schemas/APIScope' - categories: - type: array - description: | - API categories - example: [] - items: - type: string - ProductAPI: - title: ProductAPI - required: - - apiId - type: object - properties: - name: - type: string - example: PizzaShackAPI - apiId: - type: string - example: 01234567-0123-0123-0123-012345678901 - version: - type: string - example: "1.0" - operations: - type: array - items: - $ref: '#/components/schemas/APIOperations' - ResourcePath: - title: ResourcePath - required: - - id - type: object - properties: - id: - type: integer - example: 1 - resourcePath: - type: string - example: /menu - httpVerb: - type: string - example: GET - ResourcePathList: - title: ResourcePath List - type: object - properties: - count: - type: integer - description: | - Number of API Resource Paths returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/ResourcePath' - pagination: - $ref: '#/components/schemas/Pagination' - APIProductOutdatedStatus: - title: APIProduct is outdated status - type: object - properties: - isOutdated: - type: boolean - description: | - Indicates if an API Product is outdated - example: true - APIProductBusinessInformation: - type: object - properties: - businessOwner: - maxLength: 120 - type: string - example: businessowner - businessOwnerEmail: - type: string - example: businessowner@wso2.com - technicalOwner: - maxLength: 120 - type: string - example: technicalowner - technicalOwnerEmail: - type: string - example: technicalowner@wso2.com - Claim: - title: Claim - type: object - properties: - name: - type: string - example: email - URI: - type: string - example: http://wso2.org/claims/emailaddress - value: - type: string - example: admin@wso2.com - SubscriberInfo: - title: SubscriberInfo - type: object - properties: - name: - type: string - example: admin - claims: - type: array - items: - $ref: '#/components/schemas/Claim' - Application: - title: Application - required: - - name - - throttlingTier - type: object - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - type: string - example: admin - throttlingTier: - type: string - example: Unlimited - description: - type: string - example: Sample calculator application - groupId: - type: string - example: "" - ApplicationInfo: - title: Application info object with basic application details - type: object - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - type: string - example: admin - description: - type: string - example: Sample calculator application - subscriptionCount: - type: integer - DocumentList: - title: Document List - type: object - properties: - count: - type: integer - description: | - Number of Documents returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Document' - pagination: - $ref: '#/components/schemas/Pagination' - Document: - title: Document - required: - - name - - sourceType - - type - - visibility - type: object - properties: - documentId: - type: string - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - name: - maxLength: 60 - minLength: 1 - type: string - example: PizzaShackDoc - type: - type: string - example: HOWTO - enum: - - HOWTO - - SAMPLES - - PUBLIC_FORUM - - SUPPORT_FORUM - - API_MESSAGE_FORMAT - - SWAGGER_DOC - - OTHER - summary: - maxLength: 32766 - minLength: 1 - type: string - example: Summary of PizzaShackAPI Documentation - sourceType: - type: string - example: INLINE - enum: - - INLINE - - MARKDOWN - - URL - - FILE - sourceUrl: - type: string - readOnly: true - example: "" - fileName: - type: string - readOnly: true - example: "" - inlineContent: - type: string - example: This is doc content. This can have many lines. - otherTypeName: - type: string - readOnly: true - example: "" - visibility: - type: string - example: API_LEVEL - enum: - - OWNER_ONLY - - PRIVATE - - API_LEVEL - createdTime: - type: string - readOnly: true - createdBy: - type: string - example: admin - lastUpdatedTime: - type: string - readOnly: true - lastUpdatedBy: - type: string - readOnly: true - example: admin - GraphQLSchema: - title: GraphQL Schema - required: - - name - type: object - properties: - name: - type: string - example: admin--HackerNewsAPI.graphql - schemaDefinition: - type: string - GraphQLQueryComplexityInfo: - title: GraphQL Query Complexity Info - type: object - properties: - list: - type: array - items: - $ref: '#/components/schemas/GraphQLCustomComplexityInfo' - GraphQLCustomComplexityInfo: - title: GraphQL Custom Complexity Info - required: - - complexityValue - - field - - type - type: object - properties: - type: - type: string - description: | - The type found within the schema of the API - example: Country - field: - type: string - description: | - The field which is found under the type within the schema of the API - example: name - complexityValue: - type: integer - description: | - The complexity value allocated for the associated field under the specified type - example: 1 - GraphQLSchemaTypeList: - title: List of types and corresponding fields of the GraphQL Schema - type: object - properties: - typeList: - type: array - items: - $ref: '#/components/schemas/GraphQLSchemaType' - GraphQLSchemaType: - title: Single type and corresponding fields found within the GraphQL Schema - type: object - properties: - type: - type: string - description: | - Type found within the GraphQL Schema - example: Country - fieldList: - type: array - description: | - Array of fields under current type - example: - - code - - name - items: - type: string - MediationList: - title: Mediation List - type: object - properties: - count: - type: integer - description: | - Number of mediation sequences returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/MediationInfo' - pagination: - $ref: '#/components/schemas/Pagination' - MediationInfo: - title: MediationInfo - required: - - id - - name - - type - type: object - properties: - name: - type: string - example: json_fault.xml - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - type: - type: string - example: in - enum: - - in - - out - - fault - Mediation: - title: Mediation - required: - - name - - type - type: object - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: json_fault.xml - type: - type: string - example: in - enum: - - in - - out - - fault - ThrottlingPolicyList: - title: Throttling policy list - type: object - properties: - count: - type: integer - description: | - Number of Tiers returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/ThrottlingPolicy' - pagination: - $ref: '#/components/schemas/Pagination' - ThrottlingPolicy: - title: Tier - required: - - name - - requestCount - - stopOnQuotaReach - - tierPlan - - unitTime - type: object - properties: - name: - type: string - example: Platinum - description: - type: string - example: Allows 50 request(s) per minute. - policyLevel: - type: string - example: api - enum: - - subscription - - api - displayName: - type: string - example: Platinum - attributes: - type: object - additionalProperties: - type: string - description: | - Custom attributes added to the policy policy - example: {} - requestCount: - type: integer - description: | - Maximum number of requests which can be sent within a provided unit time - format: int64 - example: 50 - dataUnit: - description: | - Unit of data allowed to be transfered. Allowed values are "KB", "MB" and "GB" - type: string - example: KB - unitTime: - type: integer - format: int64 - example: 60000 - timeUnit: - type: string - example: min - rateLimitCount: - type: integer - default: 0 - description: Burst control request count - example: 10 - rateLimitTimeUnit: - type: string - description: Burst control time unit - example: min - quotaPolicyType: - type: string - description: Default quota limit type - enum: - - REQUESTCOUNT - - BANDWIDTHVOLUME - example: REQUESTCOUNT - tierPlan: - type: string - description: | - This attribute declares whether this policy is available under commercial or free - example: FREE - enum: - - FREE - - COMMERCIAL - stopOnQuotaReach: - type: boolean - description: | - By making this attribute to false, you are capabale of sending requests - even if the request count exceeded within a unit time - example: true - monetizationProperties: - type: object - additionalProperties: - type: string - description: Properties of a tier plan which are related to monetization - example: {} - SubscriptionList: - title: Subscription List - type: object - properties: - count: - type: integer - description: | - Number of Subscriptions returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Subscription' - pagination: - $ref: '#/components/schemas/Pagination' - Subscription: - title: Subscription - required: - - applicationInfo - - subscriptionId - - subscriptionStatus - - throttlingPolicy - type: object - properties: - subscriptionId: - type: string - example: 01234567-0123-0123-0123-012345678901 - applicationInfo: - $ref: '#/components/schemas/ApplicationInfo' - throttlingPolicy: - type: string - example: Unlimited - subscriptionStatus: - type: string - example: BLOCKED - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - UNBLOCKED - - ON_HOLD - - REJECTED - - TIER_UPDATE_PENDING - APIMonetizationUsage: - title: API monetization usage object - type: object - properties: + - context + - version + - tiers + - isDefaultVersion + - transport + - endpointConfig + - visibility + - type + properties: + id: + type: string + description: | + UUID of the api registry artifact + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + description: Name of the API + example: CalculatorAPI + description: + type: string + description: A brief description about the API + example: A calculator API that supports basic operations + context: + type: string + description: A string that represents the context of the user's request + example: CalculatorAPI + version: + type: string + description: The version of the API + example: 1.0.0 + provider: + description: | + If the provider value is not given user invoking the api will be used as the provider. + type: string + example: admin + apiDefinition: + description: | + Swagger definition of the API which contains details about URI templates and scopes + type: string + example: "{\"paths\":{\"/substract\":{\"get\":{\"x-auth-type\":\"Application & Application User\",\"x-throttling-tier\":\"Unlimited\",\"parameters\":[{\"name\":\"x\",\"required\":true,\"type\":\"string\",\"in\":\"query\"},{\"name\":\"y\",\"required\":true,\"type\":\"string\",\"in\":\"query\"}],\"responses\":{\"200\":{}}}},\"/add\":{\"get\":{\"x-auth-type\":\"Application & Application User\",\"x-throttling-tier\":\"Unlimited\",\"parameters\":[{\"name\":\"x\",\"required\":true,\"type\":\"string\",\"in\":\"query\"},{\"name\":\"y\",\"required\":true,\"type\":\"string\",\"in\":\"query\"}],\"responses\":{\"200\":{}}}}},\"swagger\":\"2.0\",\"info\":{\"title\":\"CalculatorAPI\",\"version\":\"1.0.0\"}}" + wsdlUri: + description: | + WSDL URL if the API is based on a WSDL endpoint + type: string + example: "http://www.webservicex.com/globalweather.asmx?wsdl" + status: + type: string + description: This describes in which status of the lifecycle the API is + example: CREATED + responseCaching: + type: string + example: Disabled + cacheTimeout: + type: integer + example: 300 + destinationStatsEnabled: + type: string + example: Disabled + isDefaultVersion: + type: boolean + example: false + type: + type: string + description: The transport to be set. Accepted values are HTTP, WS + enum: + - HTTP + - WS + example: HTTP + default: HTTP + transport: + description: | + Supported transports for the API (http and/or https). + type: array + items: + type: string + example: ["http","https"] + tags: + type: array + description: Search keywords related to the API + items: + type: string + example: ["substract","add"] + tiers: + type: array + description: The subscription tiers selected for the particular API + items: + type: string + example: ["Unlimited"] + apiLevelPolicy: + description: The policy selected for the particular API + type: string + example: "Unlimited" + maxTps: properties: - type: object - additionalProperties: - type: string - description: Map of custom properties related to monetization usage - APIRevenue: - title: API revenue data object - type: object - properties: + production: + type: integer + format: int64 + example: 1000 + sandbox: + type: integer + format: int64 + example: 1000 + thumbnailUri: + type: string + example: "/apis/01234567-0123-0123-0123-012345678901/thumbnail" + visibility: + type: string + description: The visibility level of the API. Accepts one of the following. PUBLIC, PRIVATE, RESTRICTED OR CONTROLLED. + enum: + - PUBLIC + - PRIVATE + - RESTRICTED + - CONTROLLED + example: PUBLIC + visibleRoles: + type: array + description: The user roles that are able to access the API + items: + type: string + example: [] + endpointConfig: + type: string + example: "{\"production_endpoints\":{\"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/\",\"config\":{\"suspendErrorCode\":\"101000\",\"suspendDuration\":\"2000\",\"suspendMaxDuration\":\"3\",\"factor\":\"2\",\"retryErroCode\":\"101000\",\"retryTimeOut\":\"4\",\"retryDelay\":\"1000\",\"actionSelect\":\"fault\",\"actionDuration\":\"3000\"}},\"sandbox_endpoints\":{\"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/\",\"config\":null},\"endpoint_type\":\"http\"}" + endpointSecurity: properties: - type: object - additionalProperties: + type: type: string - description: Map of custom properties related to API revenue - MediationPolicy: - title: Mediation Policy - required: - - name - type: object - properties: - id: - type: string - example: 69ea3fa6-55c6-472e-896d-e449dd34a824 - name: - type: string - example: log_in_message - type: - type: string - example: in - shared: - type: boolean - example: true - Error: - title: Error object returned with 4XX HTTP Status - required: - - code - - message - type: object - properties: - code: - type: integer - format: int64 - message: - type: string - description: Error message. - description: - type: string - description: | - A detail description about the error message. - moreInfo: - type: string - description: | - Preferably an url with more details about the error. - error: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/components/schemas/ErrorListItem' - ErrorListItem: - title: Description of individual errors that may have occurred during a request. - required: - - code - - message - type: object - properties: - code: - type: string - message: - type: string - description: | - Description about individual errors occurred - description: - type: string - description: | - A detail description about the error message. - Environment: - title: Environment - required: - - endpoints - - name - - serverUrl - - showInApiConsole - - type - type: object - properties: - name: - type: string - example: default - displayName: - type: string - example: Default - type: - type: string - example: hybrid - serverUrl: - type: string - example: https://localhost:9443/services/ - showInApiConsole: - type: boolean - example: true - endpoints: - $ref: '#/components/schemas/EnvironmentEndpoints' - vhosts: - type: array - items: - $ref: '#/components/schemas/VHost' - EnvironmentList: - title: Environment List - type: object - properties: - count: - type: integer - description: | - Number of Environments returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Environment' - EnvironmentEndpoints: - title: Environment Endpoints - type: object - properties: - http: - type: string - description: HTTP environment URL - example: http://localhost:8280 - https: - type: string - description: HTTPS environment URL - example: https://localhost:8243 - ws: - type: string - description: WS environment URL - example: http://localhost:9099 - wss: - type: string - description: WSS environment URL - example: https://localhost:8099 - VHost: - title: Virtual Host - type: object - properties: - host: - type: string - example: mg.wso2.com - httpContext: - type: string - example: pets - httpPort: - type: integer - example: 80 - httpsPort: - type: integer - example: 443 - wsPort: - type: integer - example: 9099 - wssPort: - type: integer - example: 8099 - FileInfo: - title: File Information including meta data - type: object - properties: - relativePath: - type: string - description: relative location of the file (excluding the base context and - host of the Publisher API) - example: apis/01234567-0123-0123-0123-012345678901/thumbnail - mediaType: - type: string - description: media-type of the file - example: image/jpeg - APIMaxTps: - type: object - properties: - production: - type: integer - format: int64 - example: 1000 - sandbox: - type: integer - format: int64 - example: 1000 - APIEndpointSecurity: - type: object - properties: - type: - type: string - description: Accepts one of the following, basic or digest. - example: BASIC - enum: - - BASIC - - DIGEST - username: - type: string - example: admin - password: - type: string - example: password - APIBusinessInformation: - type: object - properties: - businessOwner: - maxLength: 120 - type: string - example: businessowner - businessOwnerEmail: - type: string - example: businessowner@wso2.com - pattern: '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$' - technicalOwner: - maxLength: 120 - type: string - example: technicalowner - technicalOwnerEmail: - type: string - example: technicalowner@wso2.com - - WebsubSubscriptionConfiguration: - type: object - properties: - secret: - type: string - description: Secret key to be used for subscription - signingAlgorithm: - type: string - description: The algorithm used for signing - signatureHeader: - type: string - description: The header uses to send the signature - - APICorsConfiguration: - type: object - properties: - corsConfigurationEnabled: - type: boolean - default: false - accessControlAllowOrigins: - type: array - items: + example: basic + description: Accepts one of the following, basic or digest. + enum: + - basic + - digest + username: type: string - accessControlAllowCredentials: - type: boolean - default: false - accessControlAllowHeaders: - type: array - items: + example: admin + password: type: string - accessControlAllowMethods: - type: array - items: - type: string - description: | - CORS configuration for the API - Endpoint: - title: Endpoints - type: object - properties: - id: - type: string - description: | - UUID of the Endpoint entry - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - description: | - name of the Endpoint entry - example: Endpoint 1 - endpointConfig: - type: object - properties: - endpointType: - type: string - example: FAIL_OVER - enum: - - SINGLE - - LOAD_BALANCED - - FAIL_OVER - list: - type: array - items: - $ref: '#/components/schemas/EndpointConfig' - endpointSecurity: - type: object - properties: - enabled: - type: boolean - example: false - type: - type: string - example: basic - username: - type: string - example: basic - password: - type: string - example: basic - maxTps: - type: integer - description: Endpoint max tps - format: int64 - example: 1000 - type: - type: string - example: http - EndpointConfig: - title: Endpoint Configuration - type: object - properties: - url: - type: string - description: | - Service url of the endpoint - example: http://localhost:8280 - timeout: - type: string - description: | - Time out of the endpoint - example: "1000" - attributes: - type: array - items: - type: object - properties: - name: - type: string - example: Suspension time - value: - type: string - example: 2s - EndpointList: - title: Endpoint List - type: object - properties: - count: - type: integer - description: | - Number of Endpoints returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Endpoint' - Scope: - title: Scope - required: - - name - type: object - properties: - id: - type: string - description: | - UUID of the Scope. Valid only for shared scopes. - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - name: - maxLength: 255 - minLength: 1 - type: string - description: | - name of Scope - example: apim:api_view - displayName: - maxLength: 255 - type: string - description: | - display name of Scope - example: api_view - description: - maxLength: 512 - type: string - description: | - description of Scope - example: This Scope can used to view Apis - bindings: - type: array - description: | - role bindings list of the Scope - example: - - admin - - Internal/creator - - Internal/publisher - items: - type: string - usageCount: - type: integer - description: | - usage count of Scope - readOnly: true - example: 3 - SharedScopeUsage: - title: SharedScopeUsage - required: - - id - - name - type: object - properties: - id: - type: string - description: | - UUID of the Scope. Valid only for shared scopes. - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - description: | - name of Scope - example: apim:api_view - usedApiList: - type: array - description: | - API list which have used the shared scope - items: - $ref: '#/components/schemas/SharedScopeUsedAPIInfo' - SharedScopeUsedAPIInfo: - title: API object using shared scope - required: - - context - - name - - version - type: object - properties: - name: - type: string - example: CalculatorAPI - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - type: string - description: | - If the provider value is not given user invoking the api will be used as the provider. - example: admin - usedResourceList: - type: array - description: | - Resource list which have used the shared scope within this API - items: - $ref: '#/components/schemas/SharedScopeUsedAPIResourceInfo' - SharedScopeUsedAPIResourceInfo: - title: API resource object using shared scope - type: object - properties: - target: - type: string - example: /add - verb: - type: string - example: POST - APIScope: - title: APIScope - required: - - scope - type: object - properties: - scope: - $ref: '#/components/schemas/Scope' - shared: - type: boolean - description: | - States whether scope is shared. This will not be honored when updating/adding scopes to APIs or when - adding/updating Shared Scopes. - example: true - APIOperations: - title: Operation - type: object - properties: - id: - type: string - example: postapiresource - target: - type: string - example: /order/{orderId} - verb: - type: string - example: POST - authType: - type: string - example: Application & Application User - default: Any - throttlingPolicy: - type: string - example: Unlimited - scopes: - type: array - example: [] - items: - type: string - usedProductIds: - type: array - example: [] - items: - type: string - amznResourceName: - type: string - example: "" - amznResourceTimeout: - type: integer - payloadSchema: - type: string - example: "" - uriMapping: - type: string - example: "" - ScopeList: - title: Scope List - type: object - properties: - count: - type: integer - description: | - Number of Scopes returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Scope' - pagination: - $ref: '#/components/schemas/Pagination' - ExternalStore: - title: External Store - type: object - properties: - id: - type: string - description: | - The external store identifier, which is a unique value. - example: Store123# - displayName: - type: string - description: | - The name of the external API Store that is displayed in the Publisher UI. - example: UKStore - type: - type: string - description: | - The type of the Store. This can be a WSO2-specific API Store or an external one. - example: wso2 - endpoint: - type: string - description: | - The endpoint URL of the external store - example: http://localhost:9764/store - APIExternalStore: - title: API External Store - type: object - properties: - id: - type: string - description: | - The external store identifier, which is a unique value. - example: Store123# - lastUpdatedTime: - type: string - description: | - The recent timestamp which a given API is updated in the external store. - example: 2019-09-09T13:57:16.229 - APIExternalStoreList: - title: API External Store List - type: object - properties: - count: - type: integer - description: | - Number of external stores returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/APIExternalStore' - ExternalStoreList: - title: External Store List - type: object - properties: - count: - type: integer - description: | - Number of external stores returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/ExternalStore' - Certificates: - title: Certificates - type: object - properties: - count: - type: integer - example: 1 - certificates: - type: array - items: - $ref: '#/components/schemas/CertMetadata' - pagination: - $ref: '#/components/schemas/Pagination' - description: Representation of a list of certificates - CertMetadata: - title: Certificate - type: object - properties: - alias: - type: string - example: wso2carbon - endpoint: - type: string - example: www.abc.com - description: Representation of the details of a certificate - CertificateInfo: - title: Certificate information - type: object - properties: - status: - type: string - example: Active - validity: - $ref: '#/components/schemas/CertificateValidity' - version: - type: string - example: V3 - subject: - type: string - example: CN=wso2.com, OU=wso2, O=wso2, L=Colombo, ST=Western, C=LK - CertificateValidity: - title: Certificate Valid period - type: object - properties: - from: - type: string - example: 12-12-2017 - to: - type: string - example: 01-01-2019 - ClientCertificates: - title: Client Certificates - type: object - properties: - count: - type: integer - example: 1 - certificates: - type: array - items: - $ref: '#/components/schemas/ClientCertMetadata' - pagination: - $ref: '#/components/schemas/Pagination' - description: Representation of a list of client certificates - ClientCertMetadata: - title: Client certificate meta data - type: object - properties: - alias: - type: string - example: wso2carbon - apiId: - type: string - example: 64eca60b-2e55-4c38-8603-e9e6bad7d809 - tier: - type: string - example: Gold - description: Meta data of certificate - Label: - title: Label - required: - - name - type: object - properties: - name: - type: string - example: marketing_store - description: - type: string - example: Public microgateway for marketing - access_urls: - type: array - example: https://localhost:9095 - items: - type: string - LabelList: - title: Label List - type: object - properties: - count: - type: integer - description: | - Number of Labels returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Label' - pagination: - $ref: '#/components/schemas/Pagination' - LifecycleState: - title: Lifecycle State - type: object - properties: - state: - type: string - example: Created - checkItems: - type: array - items: - type: object - properties: - name: - type: string - example: Deprecate old versions after publishing the API - value: - type: boolean - example: false - requiredStates: - type: array - example: [] - items: - type: string - availableTransitions: - type: array - items: - type: object - properties: - event: - type: string - example: Publish - targetState: - type: string - example: Published - LifecycleHistory: - title: Lifecycle history item list - type: object - properties: - count: - type: integer - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/LifecycleHistoryItem' - LifecycleHistoryItem: - title: Lifecycle history item - type: object - properties: - previousState: - type: string - example: Created - postState: - type: string - example: Published - user: - type: string - example: admin - updatedTime: - type: string - format: dateTime - example: 2019-02-31T23:59:60Z - WorkflowResponse: - title: workflow Response - required: - - workflowStatus - type: object - properties: - workflowStatus: - type: string - description: | - This attribute declares whether this workflow task is approved or rejected. - example: APPROVED - enum: - - CREATED - - APPROVED - - REJECTED - - REGISTERED - jsonPayload: - type: string - description: | - Attributes that returned after the workflow execution - example: null - lifecycleState: - $ref: '#/components/schemas/LifecycleState' - OpenAPIDefinitionValidationResponse: - title: OpenAPI Definition Validation Response - required: - - isValid - type: object - properties: - isValid: - type: boolean - description: | - This attribute declares whether this definition is valid or not. - example: true - content: - type: string - description: | - OpenAPI definition content. - info: - type: object - properties: - name: - type: string - example: PetStore - version: - type: string - example: 1.0.0 - context: - type: string - example: /petstore - description: - type: string - example: A sample API that uses a petstore as an example to demonstrate - swagger-2.0 specification - openAPIVersion: - type: string - example: 3.0.0 - endpoints: - type: array - description: | - contains host/servers specified in the OpenAPI file/URL - items: - type: string - example: https://localhost:9443/am/sample/pizzashack/v1/api/ - description: | - API definition information - errors: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/components/schemas/ErrorListItem' - WSDLValidationResponse: - title: WSDL Definition Validation Response - required: - - isValid - type: object - properties: - isValid: - type: boolean - description: | - This attribute declares whether this definition is valid or not. - example: true - errors: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/components/schemas/ErrorListItem' - wsdlInfo: - type: object - properties: - version: - type: string - description: | - WSDL version - example: "1.1" - endpoints: - type: array - description: | - A list of endpoints the service exposes - items: - type: object - properties: - name: - type: string - description: Name of the endpoint - example: StockQuoteSoap - location: - type: string - description: Endpoint URL - example: http://www.webservicex.net/stockquote.asmx - description: Summary of the WSDL including the basic information - GraphQLValidationResponse: - title: GraphQL API definition validation Response - required: - - errorMessage - - isValid - type: object - properties: - isValid: - type: boolean - description: | - This attribute declares whether this definition is valid or not. - example: true - errorMessage: - type: string - description: | - This attribute declares the validation error message - graphQLInfo: - type: object - properties: - operations: - type: array - items: - $ref: '#/components/schemas/APIOperations' - graphQLSchema: - $ref: '#/components/schemas/GraphQLSchema' - description: Summary of the GraphQL including the basic information - ApiEndpointValidationResponse: - title: API Endpoint url validation response - required: - - statusCode - - statusMessage - type: object - properties: - statusCode: - type: integer - description: HTTP status code - example: 200 - statusMessage: - type: string - description: string - example: OK - error: - type: string - description: | - If an error occurs, the error message will be set to this property. - If not, this will remain null. - example: null - ThreatProtectionPolicyList: - title: Threat Protection Policy List - type: object - properties: - list: - type: array - items: - $ref: '#/components/schemas/ThreatProtectionPolicy' - ThreatProtectionPolicy: - title: Threat Protection Policy Schema - required: - - name - - policy - - type - type: object - properties: - uuid: - type: string - description: Policy ID - name: - type: string - description: Name of the policy - type: - type: string - description: Type of the policy - policy: - type: string - description: policy as a json string - SearchResultList: - title: Unified Search Result List - type: object - properties: - count: - type: integer - description: | - Number of results returned. - example: 1 - list: - type: array - items: - type: object - pagination: - $ref: '#/components/schemas/Pagination' - SearchResult: - title: Search Result - required: - - name - type: object - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: TestAPI - type: - type: string - example: API - enum: - - DOC - - API - - APIProduct - transportType: - type: string - description: Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL - discriminator: - propertyName: name - APISearchResult: - title: API Result - allOf: - - $ref: '#/components/schemas/SearchResult' - - type: object - properties: - description: - type: string - description: A brief description about the API - example: A calculator API that supports basic operations - context: - type: string - description: A string that represents the context of the user's request - example: CalculatorAPI - version: - type: string - description: The version of the API - example: 1.0.0 - provider: - type: string - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - example: admin - status: - type: string - description: This describes in which status of the lifecycle the API is - example: CREATED - thumbnailUri: - type: string - example: /apis/01234567-0123-0123-0123-012345678901/thumbnail - APIProductSearchResult: - title: API Result - allOf: - - $ref: '#/components/schemas/SearchResult' - - type: object - properties: - description: - type: string - description: A brief description about the API - example: A calculator API that supports basic operations - context: - type: string - description: A string that represents the context of the user's request - example: CalculatorAPI - version: - type: string - description: The version of the API Product - example: 1.0.0 - provider: - type: string - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - example: admin - status: - type: string - description: This describes in which status of the lifecycle the APIPRODUCT - is - example: PUBLISHED - thumbnailUri: - type: string - example: /apis/01234567-0123-0123-0123-012345678901/thumbnail - APIMonetizationInfo: - title: API monetization object - required: - - enabled - type: object - properties: - enabled: - type: boolean - description: Flag to indicate the monetization status - example: true - properties: - type: object - additionalProperties: - type: string - description: Map of custom properties related to monetization - DocumentSearchResult: - title: Document Result - allOf: - - $ref: '#/components/schemas/SearchResult' - - type: object - properties: - docType: - type: string - example: HOWTO - enum: - - HOWTO - - SAMPLES - - PUBLIC_FORUM - - SUPPORT_FORUM - - API_MESSAGE_FORMAT - - SWAGGER_DOC - - OTHER - summary: - type: string - example: Summary of Calculator Documentation - sourceType: - type: string - example: INLINE - enum: - - INLINE - - URL - - FILE - sourceUrl: - type: string - example: "" - otherTypeName: - type: string - example: "" - visibility: - type: string - example: API_LEVEL - enum: - - OWNER_ONLY - - PRIVATE - - API_LEVEL - apiName: - type: string - description: The name of the associated API - example: TestAPI - apiVersion: - type: string - description: The version of the associated API - example: 1.0.0 - apiProvider: - type: string - example: admin - apiUUID: - type: string - associatedType: - type: string - MockResponsePayloadList: - title: Mock Response Payload list - type: object - properties: - list: - type: array - items: - $ref: '#/components/schemas/MockResponsePayloadInfo' - MockResponsePayloadInfo: - title: Mock Response Payload info object - type: object - properties: - path: - type: string - description: path of the resource - example: /menu - content: - type: string - description: new modified code - example: "var accept = \"\\\"\"+mc.getProperty('AcceptHeader')+\"\\\"\"\ - ;\nvar responseCode = mc.getProperty('query.param.responseCode');\nvar\ - \ responseCodeStr = \"\\\"\"+responseCode+\"\\\"\";\nvar responses = [];\n\ - \nif (!responses[200]) {\n responses [200] = [];\n}\nresponses[200][\"\ - application/json\"] = \n[ {\n \"price\" : \"string\",\n \"description\"\ - \ : \"string\",\n \"name\" : \"string\",\n \"image\" : \"string\"\n\ - } ]\n\n/*if (!responses[304]) {\n responses[304] = [];\n}\nresponses[304][\"\ - application/(json or xml)\"] = {}/<>*/\n\nif (!responses[406]) {\n responses\ - \ [406] = [];\n}\nresponses[406][\"application/json\"] = \n{\n \"message\"\ - \ : \"string\",\n \"error\" : [ {\n \"message\" : \"string\",\n \ - \ \"code\" : 0\n } ],\n \"description\" : \"string\",\n \"code\" :\ - \ 0,\n \"moreInfo\" : \"string\"\n}\n\nresponses[501] = [];\nresponses[501][\"\ - application/json\"] = {\n\"code\" : 501,\n\"description\" : \"Not Implemented\"\ - }\nresponses[501][\"application/xml\"] = 501Not\ - \ Implemented;\n\nif (!responses[responseCode])\ - \ {\n responseCode = 501;\n}\n\nif (responseCode == null) {\n responseCode\ - \ = 200;\n responseCodeStr = \"200\";\n}\n\nif (accept == null || !responses[responseCode][accept])\ - \ {\n accept = \"application/json\";\n}\n\nif (accept === \"application/json\"\ - ) {\n mc.setProperty('CONTENT_TYPE', 'application/json');\n mc.setProperty('HTTP_SC',\ - \ responseCodeStr);\n mc.setPayloadJSON(responses[responseCode][\"application/json\"\ - ]);\n} else if (accept === \"application/xml\") {\n mc.setProperty('CONTENT_TYPE',\ - \ 'application/xml');\n mc.setProperty('HTTP_SC', responseCodeStr);\n\ - \ mc.setPayloadXML(responses[responseCode][\"application/xml\"]);\n}" - verb: - type: string - example: POST - ResourcePolicyList: - title: Resource policy List - type: object - properties: - list: - type: array - items: - $ref: '#/components/schemas/ResourcePolicyInfo' - count: - type: integer - description: | - Number of policy resources returned. - example: 1 - ResourcePolicyInfo: - title: Resource policy Info object with conversion policy resource details. - type: object - properties: - id: - type: string - description: | - UUID of the resource policy registry artifact - readOnly: true - example: 01234567-0123-0123-0123-012345678901 - httpVerb: - type: string - description: HTTP verb used for the resource path - example: get - resourcePath: - type: string - description: A string that represents the resource path of the api for the - related resource policy - example: checkPhoneNumber - content: - type: string - description: The resource policy content - example:
- Settings: - title: SettingsDTO - type: object - properties: - devportalUrl: - type: string - description: The Developer Portal URL - example: https://localhost:9443/devportal - environment: - type: array - items: - $ref: '#/components/schemas/Environment' - scopes: - type: array - example: - - apim:api_create - - apim:api_publish - items: - type: string - monetizationAttributes: - type: array - example: [] - items: - $ref: '#/components/schemas/MonetizationAttribute' - securityAuditProperties: - type: object - properties: {} - externalStoresEnabled: - type: boolean - description: | - Is External Stores configuration enabled - example: true - docVisibilityEnabled: - type: boolean - description: | - Is Document Visibility configuration enabled - example: false - crossTenantSubscriptionEnabled: - type: boolean - description: | - Is Cross Tenant Subscriptions Enabled - example: false - default: false - deployments: - type: array - items: - $ref: '#/components/schemas/Deployments' - SecurityAuditAttribute: - title: SecurityAuditAttributeDTO - type: object - properties: - isGlobal: - type: boolean - example: false - overrideGlobal: - type: boolean - example: false - apiToken: - type: string - example: b1267ytf-b7gc-4aee-924d-ece81241efec - collectionId: - type: string - example: 456ef957-5a79-449f-83y3-9027945d3c60 - baseUrl: - type: string - WSDLInfo: - title: WSDL information of the API. This is only available if the API is a SOAP - API. - type: object - properties: - type: - type: string - description: Indicates whether the WSDL is a single WSDL or an archive in - ZIP format - enum: - - WSDL - - ZIP - Pagination: - title: Pagination - type: object - properties: - offset: - type: integer - example: 0 - limit: - type: integer - example: 1 - total: - type: integer - example: 10 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - MonetizationAttribute: - title: Monetization attribute object - type: object - properties: - required: - type: boolean - description: | - Is attribute required - example: true - name: - type: string - description: | - Name of the attribute - displayName: - type: string - description: | - Display name of the attribute - description: - type: string - description: | - Description of the attribute - hidden: - type: boolean - description: | - Is attribute hidden - default: - type: string - description: | - Default value of the attribute - Tenant: - title: Tenant - type: object - properties: - domain: - type: string - description: tenant domain - example: wso2.com - status: - type: string - description: current status of the tenant active/inactive - example: active - TenantList: - title: Tenant list - type: object - properties: - count: - type: integer - description: | - Number of tenants returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Tenant' - pagination: - $ref: '#/components/schemas/Pagination' - AlertTypesList: - title: Alert Types List - type: object - properties: - count: - type: integer - description: The number of alerts - example: 3 - alerts: - type: array - items: - $ref: '#/components/schemas/AlertType' - AlertType: - title: Alert Type - type: object - properties: - id: - type: integer - description: The alert Id - example: 1 - name: - type: string - description: The name of the alert. - example: AbnormalRequestTime - requireConfiguration: - type: boolean - description: Whether the alert type require additional configurations. - example: true - Alert: - title: Alert - type: object - properties: - id: - type: integer - description: The alert Id - example: 1 - name: - type: string - description: The name of the alert. - example: AbnormalRequestsPerMin - configuration: - type: array - items: - $ref: '#/components/schemas/AlertConfig' - AlertsInfo: - title: Alerts Info - type: object - properties: - alerts: - type: array - items: - $ref: '#/components/schemas/Alert' - emailList: - type: array - items: - type: string - AlertsInfoResponse: - title: Alerts Info Response - type: object - properties: - alerts: - type: array - items: - $ref: '#/components/schemas/Alert' - emailList: - type: array - items: - type: string - failedConfigurations: - type: array - items: - $ref: '#/components/schemas/AlertConfig' - AlertConfigList: - title: Alert Configuration List - type: object - properties: - count: - type: integer - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/AlertConfig' - AlertConfig: - title: Alert Configuration - type: object - properties: - configurationId: - type: string - description: The alert config subscription id. - example: UGl6emFTaGFja0FQSSsxLjAuMCtEZWZhdWx0QXBwbGljYXRpb24K - configuration: - type: object - additionalProperties: - type: string - description: The config parameters. - example: - apiName: PizzaShackAPI - apiVersion: 1.0.0 - applicationName: DefaultApplication - requestConunt: "12" - AlertConfigInfo: - title: Alert Configuration Info - type: object + example: password + gatewayEnvironments: + description: | + Comma separated list of gateway environments. + type: string + example: Production and Sandbox + sequences: + type: array + items: + $ref: '#/definitions/Sequence' + example: [] + subscriptionAvailability: + type: string + description: The subscription availability. Accepts one of the following. current_tenant, all_tenants or specific_tenants. + enum: + - current_tenant + - all_tenants + - specific_tenants + example: current_tenant + subscriptionAvailableTenants: + type: array + items: + type: string + example: ["tenant1", "tenant2"] additionalProperties: + type: object + description : Map of custom properties of API + accessControl: type: string - description: The config parameters. - example: - apiName: PizzaShackAPI - apiVersion: 1.0.0 - applicationName: DefaultApplication - requestConunt: "12" - APICategory: - title: API Category - required: - - name - type: object - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: Finance - description: - type: string - example: Finance related APIs - APICategoryList: - title: API Category List - type: object - properties: - count: - type: integer - description: | - Number of API categories returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/APICategory' - KeyManagerInfo: - title: Key Manager Info - required: - - name - - type - type: object - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: WSO2 IS - displayName: - type: string - description: | - display name of Keymanager - example: Keymanager1 - type: - type: string - example: IS - description: - type: string - example: This is a key manager for Developers - enabled: - type: boolean - example: true - additionalProperties: - type: array - items: - type: object - properties: {} - KeyManagerList: - title: Key Manager List - type: object - properties: - count: - type: integer - description: | - Number of Key managers returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/KeyManagerInfo' - DeploymentList: - title: Deployment List - type: object - properties: - count: - type: integer - description: | - Number of deployment clusters returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/Deployments' - Deployments: - title: Deployments - required: - - clusters - - name - type: object - properties: - name: - type: string - example: Kubernetes - clusters: - type: array - items: - $ref: '#/components/schemas/DeploymentClusterInfo' - DeploymentClusterInfo: - title: DeploymentClusterInfo - required: - - accessURL - - clusterName - - displayName - - properties - type: object - properties: - clusterName: - type: string - example: minikube - accessURL: - type: string - example: https://api.com - displayName: - type: string - example: kubernetes-minikube + description: | + Is the API is restricted to certain set of publishers or creators or is it visible to all the + publishers and creators. If the accessControl restriction is none, this API can be modified by all the + publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, + based on the restriction. enum: + - NONE + - RESTRICTED + accessControlRoles: + type: array + description: The user roles that are able to view/modify as API publisher or creator. + items: + type: string + example: [admin] + businessInformation: properties: - type: object - additionalProperties: + businessOwner: type: string - DeploymentStatusList: - title: DeploymentStatus List - type: object - properties: - count: - type: integer - description: | - Status of the deployments returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/DeploymentStatus' - DeploymentStatus: - title: DeploymentStatus - required: - - clusters - - type - type: object - properties: - type: - type: string - example: Kubernetes - clusters: - type: array - items: - $ref: '#/components/schemas/DeploymentClusterStatus' - DeploymentClusterStatus: - title: DeploymentClusterStatus - required: - - clusterName - - healthStatus - - podsRunning - type: object - properties: - clusterName: - type: string - example: Minikube - podsRunning: - type: integer - healthStatus: - type: array - items: - $ref: '#/components/schemas/PodStatus' - DeploymentEnvironments: - title: DeploymentEnvironments - required: - - clusterName - - type - type: object - properties: - type: - type: string - example: Kubernetes - clusterName: - type: array - example: - - minikube - items: + example: businessowner + businessOwnerEmail: type: string - PodStatus: - title: PodStatus + example: businessowner@wso2.com + technicalOwner: + type: string + example: technicalowner + technicalOwnerEmail: + type: string + example: technicalowner@wso2.com + corsConfiguration: + description: | + CORS configuration for the API + properties: + corsConfigurationEnabled: + type: boolean + default: false + accessControlAllowOrigins: + type: array + items: + type: string + accessControlAllowCredentials: + type: boolean + default: false + accessControlAllowHeaders: + type: array + items: + type: string + accessControlAllowMethods: + type: array + items: + type: string + +#----------------------------------------------------- +# The Application resource +#----------------------------------------------------- + Application: + title: Application + required: + - name + - throttlingTier + properties: + applicationId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorApp + subscriber: + type: string + example: admin + throttlingTier: + type: string + example: Unlimited + description: + type: string + example: Sample calculator application + groupId: + type: string + example: "" + +#----------------------------------------------------- +# The Document List resource +#----------------------------------------------------- + DocumentList: + title: Document List + properties: + count: + type: integer + description: | + Number of Documents returned. + example: 1 + next: + type: string + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" + previous: + type: string + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" + list: + type: array + items: + $ref: '#/definitions/Document' + +#----------------------------------------------------- +# The Document resource +#----------------------------------------------------- + Document: + title: Document + required: + - name + - type + - sourceType + - visibility + properties: + documentId: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: CalculatorDoc + type: + type: string + enum: + - HOWTO + - SAMPLES + - PUBLIC_FORUM + - SUPPORT_FORUM + - API_MESSAGE_FORMAT + - SWAGGER_DOC + - OTHER + example: HOWTO + summary: + type: string + example: "Summary of Calculator Documentation" + sourceType: + type: string + enum: + - INLINE + - URL + - FILE + example: INLINE + sourceUrl: + type: string + example: "" + otherTypeName: + type: string + example: "" + visibility: + type: string + enum: + - OWNER_ONLY + - PRIVATE + - API_LEVEL + example: API_LEVEL + +#----------------------------------------------------- +# The Mediation List resource +#----------------------------------------------------- + mediationList: + title: Mediation List + properties: + count: + type: integer + description: | + Number of mediation sequences returned. + example: 1 + next: + type: string + description: | + Link to the next subset of sequences qualified. + Empty if no more sequences are to be returned. + example: "" + previous: + type: string + description: | + Link to the previous subset of sequences qualified. + Empty if current subset is the first subset returned. + example: "" + list: + type: array + items: + $ref: '#/definitions/MediationInfo' + +#----------------------------------------------------- +# The MediationInfo resource +#----------------------------------------------------- + MediationInfo: + title: MediationInfo + required: + - name + - type + - id + properties: + name: + type: string + example: json_fault.xml + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + type: + type: string + enum: + - in + - out + - fault + example: in +#----------------------------------------------------- +# The Mediation resource +#----------------------------------------------------- + Mediation: + title: Mediation + required: + - name + - type + - config + properties: + id: + type: string + example: 01234567-0123-0123-0123-012345678901 + name: + type: string + example: json_fault.xml + type: + type: string + enum: + - in + - out + - fault + example: in + config: + type: string + example: ' + + + + ' + +#----------------------------------------------------- +# The MediationInfo resource +#----------------------------------------------------- + Wsdl: + title: Wsdl required: - name - - ready - - status - type: object properties: name: type: string - example: petStore-677bb7cc65-shb2f - ready: + example: admin--calculatorAPI2.0.wsdl + wsdlDefinition: type: string - example: 1/1 - status: - type: string - example: running - creationTimestamp: - type: string - example: 2020-05-12T06:12:00Z - AsyncAPISpecificationValidationResponse: - title: AsyncAPI Specification Validation Response - required: - - isValid - type: object - properties: - isValid: - type: boolean - description: - This attribute declares whether this definition is valid or not. - example: true - content: - type: string - description: - AsyncAPI specification content - info: - type: object - properties: - name: - type: string - example: Streetlights - version: - type: string - example: 1.0.0 - context: - type: string - example: /streetlights - description: - type: string - example: A sample API that uses a streetlights as an example to demonstrate AsyncAPI specifications - asyncAPIVersion: - type: string - example: 2.0 - endpoints: - type: array - description: - contains host/servers specified in the AsyncAPI file/URL - items: - type: string - example: "https://localhost:9443/am/sample/pizzashack/v1/api/" - description: - API definition information - errors: - type: array - description: - If there are more than one error list them out. - For example, list out validation error by each field. - items: - $ref: '#/components/schemas/ErrorListItem' - responses: - BadRequest: - description: Bad Request. Invalid request or validation error. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 400 - message: Bad Request - description: Invalid request or validation error - moreInfo: "" - error: [] - Conflict: - description: Conflict. Specified resource already exists. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 409 - message: Conflict - description: Specified resource already exists - moreInfo: "" - error: [] - Forbidden: - description: Forbidden. The request must be conditional but no condition has - been specified. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 403 - message: Forbidden - description: The request must be conditional but no condition has been - specified - moreInfo: "" - error: [] - InternalServerError: - description: Internal Server Error. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 500 - message: Internal Server Error - description: The server encountered an internal error. Please contact - administrator. - moreInfo: "" - error: [] - NotAcceptable: - description: Not Acceptable. The requested media type is not supported. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 406 - message: Not Acceptable - description: The requested media type is not supported - moreInfo: "" - error: [] - NotFound: - description: Not Found. The specified resource does not exist. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 404 - message: Not Found - description: The specified resource does not exist - moreInfo: "" - error: [] - PreconditionFailed: - description: Precondition Failed. The request has not been performed because - one of the preconditions is not met. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 412 - message: Precondition Failed - description: The request has not been performed because one of the preconditions - is not met - moreInfo: "" - error: [] - Unauthorized: - description: Unauthorized. The user is not authorized. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 401 - message: Unauthorized - description: The user is not authorized - moreInfo: "" - error: [] - UnsupportedMediaType: - description: Unsupported Media Type. The entity of the request was not in a - supported format. - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - example: - code: 415 - message: Unsupported media type - description: The entity of the request was not in a supported format - moreInfo: "" - error: [] - parameters: - replyLimit: - name: replyLimit - in: query - description: | - Maximum size of replies array to return. - schema: - type: integer - default: 25 - replyOffset: - name: replyOffset - in: query - description: | - Starting point within the complete list of replies. - schema: - type: integer - default: 0 - commentId: - name: commentId - in: path - description: | - Comment Id - required: true - schema: - type: string - parentCommentID: - name: replyTo - in: query - description: | - ID of the perent comment. - schema: - type: string - includeCommenterInfo: - name: includeCommenterInfo - in: query - description: | - Whether we need to display commentor details. - schema: - type: boolean - default : false - apiId: - name: apiId - in: path - description: | - **API ID** consisting of the **UUID** of the API. - required: true - schema: - type: string - endpointId: - name: endpointId - in: path - description: | - **Endpoint ID** consisting of the **UUID** of the Endpoint**. - required: true - schema: - type: string - apiId-Q: - name: apiId - in: query - description: | - **API ID** consisting of the **UUID** of the API. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - required: true - schema: - type: string - apiId-Q-Opt: - name: apiId - in: query - description: | - **API ID** consisting of the **UUID** of the API. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - schema: - type: string - labelType-Q: - name: labelType - in: query - description: | - **API ID** consisting of the **UUID** of the API. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - schema: - type: string - name: - name: name - in: path - description: | - Name of the API - required: true - schema: - type: string - version: - name: version - in: path - description: | - Version of the API - required: true - schema: - type: string - apiName-Q: - name: name - in: query - description: | - Name of the API - schema: - type: string - apiVersion-Q: - name: version - in: query - description: | - Version of the API - schema: - type: string - apiProvider-Q: - name: providerName - in: query - description: | - Provider name of the API - schema: - type: string - documentId: - name: documentId - in: path - description: | - Document Identifier - required: true - schema: - type: string - applicationId: - name: applicationId - in: path - description: | - **Application Identifier** consisting of the UUID of the Application. - required: true - schema: - type: string - subscriptionId: - name: subscriptionId - in: path - description: | - Subscription Id - required: true - schema: - type: string - mediationPolicyId: - name: mediationPolicyId - in: path - description: | - Mediation policy Id - required: true - schema: - type: string - resourcePolicyId: - name: resourcePolicyId - in: path - description: | - registry resource Id - required: true - schema: - type: string - subscriptionId-Q: - name: subscriptionId - in: query - description: | - Subscription Id - required: true - schema: - type: string - # API Revision Identifier - # Specified as part of the path expression - revisionId: - name: revisionId - in: path - description: | - Revision ID of an API - required: true - schema: - type: string - # API Revision Identifier - # Specified as part of the query string - revisionId-Q: - name: revisionId - in: query - description: | - Revision ID of an API - schema: +# The Tier List resource +#----------------------------------------------------- + TierList: + title: Tier List + properties: + count: + type: integer + description: | + Number of Tiers returned. + example: 1 + next: type: string - revisionNum-Q: - name: revisionNumber - in: query - description: | - Revision Number of an API - schema: + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/tiers/api?limit=1&offset=2" + previous: type: string - policyName: - name: policyName - in: path - description: | - Tier name - required: true - schema: + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/tiers/api?limit=1&offset=0" + list: + type: array + items: + $ref: '#/definitions/Tier' + +#----------------------------------------------------- +# The Tier resource +#----------------------------------------------------- + Tier: + title: Tier + required: + - name + - tierPlan + - requestCount + - unitTime + - stopOnQuotaReach + properties: + name: type: string - policyName-Q: - name: policyName - in: query - description: | - Name of the policy - required: true - schema: + example: Platinum + description: type: string - policyLevel: - name: policyLevel - in: path - description: | - List API or Application or Resource type policies. - required: true - schema: + example: "Allows 50 request(s) per minute." + tierLevel: type: string enum: - api - - subcription - policyLevel-Q: - name: policyLevel - in: query - description: | - List API or Application or Resource type policies. - required: true - schema: + - application + - resource + example: api + attributes: + description: | + Custom attributes added to the tier policy + type: object + additionalProperties: + type: string + example: {} + requestCount: + description: | + Maximum number of requests which can be sent within a provided unit time + type: integer + format: int64 + example: 50 + unitTime: + type: integer + format: int64 + example: 60000 + timeUnit: + type: string + example: "min" + tierPlan: + description: | + This attribute declares whether this tier is available under commercial or free type: string enum: - - api - - subcription - limit: - name: limit - in: query - description: | - Maximum size of resource array to return. - schema: - type: integer - default: 25 - Accept: - name: Accept - in: header - description: | - Media types acceptable for the response. Default is application/json. - schema: - type: string - default: application/json - offset: - name: offset - in: query - description: | - Starting point within the complete list of items qualified. - schema: - type: integer - default: 0 - If-None-Match: - name: If-None-Match - in: header - description: | - Validator for conditional requests; based on the ETag of the formerly retrieved - variant of the resource. - schema: - type: string - If-Match: - name: If-Match - in: header - description: | - Validator for conditional requests; based on ETag. - schema: - type: string - scopeName: - name: scopeId - in: path - description: | - Scope name - required: true - schema: - type: string - scopeId: - name: scopeId - in: path - description: | - Scope Id consisting the UUID of the shared scope - required: true - schema: - type: string - expand: - name: expand - in: query - description: | - Defines whether the returned response should contain full details of API - schema: + - FREE + - COMMERCIAL + example: FREE + stopOnQuotaReach: + description: | + By making this attribute to false, you are capabale of sending requests + even if the request count exceeded within a unit time type: boolean - threatProtectionPolicyId: - name: policyId - in: path - description: | - The UUID of a Policy - required: true - schema: + example: true + +#----------------------------------------------------- +# The Tier Permission resource +#----------------------------------------------------- + TierPermission: + title: tierPermission + required: + - permissionType + - roles + properties: + permissionType: type: string - roleId: - name: roleId - in: path - description: | - The Base 64 URL encoded role name with domain. If the given role is in secondary user-store, role ID should be - derived as Base64URLEncode({user-store-name}/{role-name}). If the given role is in PRIMARY user-store, role ID - can be derived as Base64URLEncode(role-name) - required: true - schema: + enum: + - allow + - deny + example: deny + roles: + type: array + items: + type: string + example: ["Internal/everyone"] + +#----------------------------------------------------- +# The Subscription List resource +#----------------------------------------------------- + SubscriptionList: + title: Subscription List + properties: + count: + type: integer + description: | + Number of Subscriptions returned. + example: 1 + next: type: string - requestedTenant: - name: X-WSO2-Tenant - in: header - description: | - For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be - retirieved from. - schema: + description: | + Link to the next subset of resources qualified. + Empty if no more resources are to be returned. + example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" + previous: type: string - apiProductId: - name: apiProductId - in: path - description: | - **API Product ID** consisting of the **UUID** of the API Product. Using the **UUID** in the API call is recommended. - required: true - schema: + description: | + Link to the previous subset of resources qualified. + Empty if current subset is the first subset returned. + example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" + list: + type: array + items: + $ref: '#/definitions/Subscription' + +#----------------------------------------------------- +# The Subscription resource +#----------------------------------------------------- + Subscription: + title: Subscription + required: + - applicationId + - apiIdentifier + - tier + properties: + subscriptionId: type: string - x-encoded: true - x-encoded: true - tenantDomain: - name: tenantDomain - in: path - description: | - The domain of a specific tenant - required: true - schema: + example: 01234567-0123-0123-0123-012345678901 + applicationId: type: string - alertType: - name: alertType - in: path - description: The alert type. - required: true - schema: + example: 01234567-0123-0123-0123-012345678901 + apiIdentifier: type: string - configurationId: - name: configurationId - in: path - description: The alert configuration id. - required: true - schema: + example: 01234567-0123-0123-0123-012345678901 + tier: type: string - tierQuotaType: - name: tierQuotaType - description: Filter the subscription base on tier quota type - in: query - schema: + example: Unlimited + status: type: string - requestBodies: - threatProtectionPolicy: - description: | - Threat protection policy request parameter - content: - application/json: - schema: - $ref: '#/components/schemas/ThreatProtectionPolicy' - required: true - securitySchemes: - OAuth2Security: - type: oauth2 - flows: - password: - tokenUrl: https://localhost:9443/oauth2/token - scopes: - openid: Authorize access to user details - apim:api_view: View API - apim:api_create: Create API - apim:api_delete: Delete API - apim:api_publish: Publish API - apim:subscription_view: View Subscription - apim:subscription_block: Block Subscription - apim:external_services_discover: Discover External Services - apim:threat_protection_policy_create: Create threat protection policies - apim:threat_protection_policy_manage: Update and delete threat protection policies - apim:document_create: Create API documents - apim:document_manage: Update and delete API documents - apim:mediation_policy_view: View mediation policies - apim:mediation_policy_create: Create mediation policies - apim:mediation_policy_manage: Update and delete mediation policies - apim:client_certificates_view: View client certificates - apim:client_certificates_add: Add client certificates - apim:client_certificates_update: Update and delete client certificates - apim:ep_certificates_view: View backend endpoint certificates - apim:ep_certificates_add: Add backend endpoint certificates - apim:ep_certificates_update: Update and delete backend endpoint certificates - apim:publisher_settings: Retrieve store settings - apim:pub_alert_manage: Get/ subscribe/ configure publisher alerts - apim:shared_scope_manage: Manage shared scopes - apim:app_import_export: Import and export applications related operations - apim:api_import_export: Import and export APIs related operations - apim:api_product_import_export: Import and export API Products related operations + enum: + - BLOCKED + - PROD_ONLY_BLOCKED + - UNBLOCKED + - ON_HOLD + - REJECTED + example: UNBLOCKED + +#----------------------------------------------------- +# The Extended Subscription resource +#----------------------------------------------------- + ExtendedSubscription: + title: Subscription with Ext. Workflow Reference + required: + - workflowId + allOf: + - $ref: '#/definitions/Subscription' + - properties: + workflowId: + type: string + example: 01234567-0123-0123-0123-012345678901 + +#----------------------------------------------------- +# The Sequence resource +#----------------------------------------------------- + Sequence: + title: Sequence + required: + - name + properties: + name: + type: string + example: log_in_message + type: + type: string + example: in + id: + type: string + example: 69ea3fa6-55c6-472e-896d-e449dd34a824 + shared: + type: boolean + example: true + +#----------------------------------------------------- +# The Error resource +#----------------------------------------------------- + Error: + title: Error object returned with 4XX HTTP status + required: + - code + - message + properties: + code: + type: integer + format: int64 + message: + type: string + description: Error message. + description: + type: string + description: | + A detail description about the error message. + moreInfo: + type: string + description: | + Preferably an url with more details about the error. + error: + type: array + description: | + If there are more than one error list them out. + For example, list out validation errors by each field. + items: + $ref: '#/definitions/ErrorListItem' + +#----------------------------------------------------- +# The Error List Item resource +#----------------------------------------------------- + ErrorListItem: + title: Description of individual errors that may have occurred during a request. + required: + - code + - message + properties: + code: + type: string + message: + type: string + description: | + Description about individual errors occurred + +#----------------------------------------------------- +# The Environment resource +#----------------------------------------------------- + Environment: + title: Environment + required: + - name + - type + - serverUrl + - endpoints + - showInApiConsole + properties: + name: + type: string + example: Production and Sandbox + type: + type: string + example: hybrid + serverUrl: + type: string + example: "https://localhost:9443/services/" + showInApiConsole: + type: boolean + example: true + endpoints: + $ref: '#/definitions/EnvironmentEndpoints' + +#----------------------------------------------------- +# The Environment List resource +#----------------------------------------------------- + EnvironmentList: + title: Environment List + properties: + count: + type: integer + description: | + Number of Environments returned. + example: 1 + list: + type: array + items: + $ref: '#/definitions/Environment' + + +#----------------------------------------------------- +# The Environment Endpoint resource +#----------------------------------------------------- + EnvironmentEndpoints : + title: Environment Endpoints + properties: + http: + type: string + description: HTTP environment URL + example: "http://localhost:8280" + https: + type: string + description: HTTPS environment URL + example: "https://localhost:8243" + +#----------------------------------------------------- +# The File Information resource +#----------------------------------------------------- + FileInfo : + title: File Information including meta data + properties: + relativePath: + type: string + description: relative location of the file (excluding the base context and host of the Publisher API) + example: "apis/01234567-0123-0123-0123-012345678901/thumbnail" + mediaType: + type: string + description: media-type of the file + example: "image/jpeg" + + +#----------------------------------------------------- +# The workflow response resource +#----------------------------------------------------- + Workflow: + title: workflow + required: + - status + properties: + status: + description: | + This attribute declares whether this workflow task is approved or rejected. + type: string + enum: + - APPROVED + - REJECTED + example: APPROVED + attributes: + description: | + Custom attributes to complete the workflow task + type: object + additionalProperties: + type: string + example: {} + description: + type: string + example: "Approve workflow request." \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index ce938982e9..b2b587bcd1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -43,22 +43,10 @@ org.eclipse.osgi org.eclipse.osgi - - - javax.ws.rs - javax.ws.rs - - org.eclipse.osgi org.eclipse.osgi.services - - - javax.ws.rs - javax.ws.rs - - org.testng @@ -67,166 +55,68 @@ org.wso2.tomcat tomcat - - - javax.ws.rs - javax.ws.rs - - org.wso2.tomcat tomcat-servlet-api - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon org.wso2.carbon.core - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon org.wso2.carbon.logging - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon org.wso2.carbon.utils - - - javax.ws.rs - javax.ws.rs - - org.apache.axis2.wso2 axis2 - - - javax.ws.rs - javax.ws.rs - - com.google.code.gson gson - - - javax.ws.rs - javax.ws.rs - - org.wso2.orbit.org.scannotation scannotation - - - javax.ws.rs - javax.ws.rs - - javax.ws.rs jsr311-api - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon.governance org.wso2.carbon.governance.api - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon.governance org.wso2.carbon.governance.lcm - - - javax.ws.rs - javax.ws.rs - - javax.ws.rs javax.ws.rs-api - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api provided - 9.0.5 - - - javax.ws.rs - javax.ws.rs - - org.wso2.carbon.apimgt org.wso2.carbon.apimgt.impl - 9.0.5 provided - - - javax.ws.rs - javax.ws.rs - - com.h2database.wso2 @@ -260,61 +150,75 @@ org.wso2.carbon.apimgt.webapp.publisher.* - com.google.gson;version="2.3",com.google.gson.reflect; - version="2.3",io.swagger.annotations,javax.servlet;version="2.6",javax.xml,javax.xml.bind,javax.xml.bind.annotat - ion,javax.xml.parsers,org.apache.catalina;version="9.0",org.apache.ca - talina.core;version="9.0",org.apache.commons.logging;version="1.2",org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}",org.scannotation;version="1.0",org.scannotation.archiveiterator;ve - rsion="1.0",org.w3c.dom,org.wso2.carbon.apimgt.annotations.api,org.ws - o2.carbon.apimgt.api,org.wso2.carbon.apimgt.api.model,org.wso2.carbon - .apimgt.impl,org.wso2.carbon.apimgt.webapp.publisher,org.wso2.carbon. - apimgt.webapp.publisher.config,org.wso2.carbon.apimgt.webapp.publishe - r.dto,org.wso2.carbon.apimgt.webapp.publisher.exception,org.wso2.carb - on.apimgt.webapp.publisher.lifecycle.listener,org.wso2.carbon.apimgt. - webapp.publisher.lifecycle.util,org.wso2.carbon.base;version="1.0",or - g.wso2.carbon.context;version="4.6",org.wso2.carbon.core;version="4.6 - ",org.wso2.carbon.core.util;version="4.6",org.wso2.carbon.registry.co - re.service;version="1.0",org.wso2.carbon.user.api;version="1.0",org.w - so2.carbon.user.core.service;version="4.6",org.wso2.carbon.user.core. - tenant;version="4.6",org.wso2.carbon.utils;version="4.6",org.wso2.car - bon.utils.multitenancy;version="4.6" + com.google.gson;version="2.3", + com.google.gson.reflect;version="2.3", + io.swagger.annotations, + javax.servlet;version="2.6", + javax.xml, + javax.xml.bind, + javax.xml.bind.annotation, + javax.xml.parsers, + org.apache.catalina;version="9.0", + org.apache.catalina.core;version="9.0", + org.apache.commons.logging;version="1.2", + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.scannotation;version="1.0", + org.scannotation.archiveiterator;version="1.0", + org.w3c.dom, + org.wso2.carbon.apimgt.annotations.api, + org.wso2.carbon.apimgt.api, + org.wso2.carbon.apimgt.api.model, + org.wso2.carbon.apimgt.impl, + org.wso2.carbon.apimgt.webapp.publisher, + org.wso2.carbon.apimgt.webapp.publisher.config, + org.wso2.carbon.apimgt.webapp.publisher.dto, + org.wso2.carbon.apimgt.webapp.publisher.exception, + org.wso2.carbon.apimgt.webapp.publisher.lifecycle.listener, + org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util, + org.wso2.carbon.base;version="1.0", + org.wso2.carbon.context;version="4.6", + org.wso2.carbon.core;version="4.6", + org.wso2.carbon.core.util;version="4.6", + org.wso2.carbon.registry.core.service;version="1.0", + org.wso2.carbon.user.api;version="1.0", + org.wso2.carbon.user.core.service;version="4.6", + org.wso2.carbon.user.core.tenant;version="4.6", + org.wso2.carbon.utils;version="4.6", + org.wso2.carbon.utils.multitenancy;version="4.6" - jsr311-api;scope=compile|runtime;inline=false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + org.jacoco + jacoco-maven-plugin + + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/site + + + + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index a6b98ad438..d1312714c1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -44,9 +44,6 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -//import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*; -//import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; - /** * This class represents the concrete implementation of the APIPublisherService that corresponds to providing all * API publishing related operations. @@ -54,8 +51,6 @@ import java.util.Set; public class APIPublisherServiceImpl implements APIPublisherService { private static final String UNLIMITED_TIER = "Unlimited"; private static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox"; - private static final String CONTENT_TYPE = "application/json"; - private static final String PUBLISHED_STATUS = "PUBLISHED"; private static final String CREATED_STATUS = "CREATED"; private static final String PUBLISH_ACTION = "Publish"; public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); @@ -118,7 +113,6 @@ public class APIPublisherServiceImpl implements APIPublisherService { String context = config.getContext(); context = context.startsWith("/") ? context : ("/" + context); api.setContext(context + "/" + config.getVersion()); -// api.setContext(context); api.setStatus(CREATED_STATUS); api.setWsdlUrl(null); api.setResponseCache("Disabled"); @@ -172,8 +166,6 @@ public class APIPublisherServiceImpl implements APIPublisherService { api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_CURRENT_TENANT); api.setVisibility(APIConstants.API_PRIVATE_VISIBILITY); } - // String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() + - // "\",\"config\":null},\"endpoint_type\":\"http\"}"; String endpointConfig = "{ \"endpoint_type\": \"http\", \"sandbox_endpoints\": { \"url\": \" " + config.getEndpoint() + "\" }, \"production_endpoints\": { \"url\": \" "+ config.getEndpoint()+"\" } }"; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index 9acc17232f..afc5ec6998 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -18,7 +18,6 @@ */ package org.wso2.carbon.apimgt.webapp.publisher.internal; -//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.apimgt.webapp.publisher.APIConfig; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.registry.core.service.RegistryService; @@ -37,8 +36,6 @@ public class APIPublisherDataHolder { private RegistryService registryService; private boolean isServerStarted; private Stack unpublishedApis = new Stack<>(); - // private IntegrationClientService integrationClientService; - private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder(); private APIPublisherDataHolder() { @@ -117,12 +114,4 @@ public class APIPublisherDataHolder { this.unpublishedApis = unpublishedApis; } - // public IntegrationClientService getIntegrationClientService() { - // return integrationClientService; - // } - - // public void setIntegrationClientService( - // IntegrationClientService integrationClientService) { - // this.integrationClientService = integrationClientService; - // } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java index a714d97aa8..dbdd874810 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler; @@ -45,7 +44,6 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRegistryService" * unbind="unsetRegistryService" - */ public class APIPublisherServiceComponent { @@ -116,14 +114,4 @@ public class APIPublisherServiceComponent { APIPublisherDataHolder.getInstance().setRegistryService(null); } - // protected void setIntegrationClientService(IntegrationClientService integrationClientService) { - // if (integrationClientService != null && log.isDebugEnabled()) { - // log.debug("integrationClientService initialized"); - // } - // APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService); - // } - // - // protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { - // APIPublisherDataHolder.getInstance().setIntegrationClientService(null); - // } } diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index fca4d2100a..eea40219af 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -34,13 +34,10 @@ http://wso2.org - - org.wso2.carbon.apimgt.webapp.publisher org.wso2.carbon.apimgt.application.extension org.wso2.carbon.apimgt.application.extension.api org.wso2.carbon.apimgt.annotations - diff --git a/pom.xml b/pom.xml index bfa525b9df..4f443c2add 100644 --- a/pom.xml +++ b/pom.xml @@ -912,6 +912,16 @@ org.wso2.carbon.apimgt.keymgt ${carbon.api.mgt.version} + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.api + ${carbon.api.mgt.version} + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.impl + ${carbon.api.mgt.version} + From 7108b15549f7ec40a1c9dbd58c9d259fd2bf19fb Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 10:56:16 +0530 Subject: [PATCH 22/49] cleaned up components/application-mgt --- .../pom.xml | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index f861513e29..e54526735e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -51,64 +51,6 @@ Application Management Core Bundle org.wso2.carbon.device.application.mgt.core.internal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", org.apache.commons.logging, @@ -145,8 +87,6 @@ org.apache.commons.validator.routines apk-parser;scope=compile|runtime;inline=false - - !org.wso2.carbon.device.application.mgt.core.internal.*, org.wso2.carbon.device.application.mgt.core.* @@ -410,10 +350,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension - - - - From 584dbd7894c72700cc65af4b5432e9c55758ff5f Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 11:02:18 +0530 Subject: [PATCH 23/49] cleaned up components/certificate-mgt --- .../pom.xml | 25 ------------------- .../pom.xml | 19 -------------- 2 files changed, 44 deletions(-) diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 888eda3b79..f77e066ce5 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -133,11 +133,6 @@ - - - - - org.springframework spring-web @@ -159,26 +154,11 @@ - - - - - - - - - - junit junit test - - - - - org.wso2.carbon org.wso2.carbon.logging @@ -221,11 +201,6 @@ - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 94d2a8fec1..743227b322 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -133,10 +133,6 @@ - - - - org.springframework spring-web @@ -147,12 +143,6 @@ cxf-bundle-jaxrs provided - - - - - - commons-codec.wso2 commons-codec @@ -163,10 +153,6 @@ - - - - junit junit @@ -216,11 +202,6 @@ - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations From 056987141b90e14e1600b716536cd14a3213bbef Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 12:30:38 +0530 Subject: [PATCH 24/49] cleaned up components/device-mgt --- .../pom.xml | 11 ------ .../DeviceManagementConfigServiceImpl.java | 4 +- .../org.wso2.carbon.device.mgt.api/pom.xml | 36 ----------------- .../api/DeviceEventManagementService.java | 4 ++ .../service/api/GeoLocationBasedService.java | 3 ++ .../service/impl/DeviceAgentServiceImpl.java | 3 -- .../DeviceEventManagementServiceImpl.java | 29 +++----------- .../impl/GeoLocationBasedServiceImpl.java | 20 ++-------- .../CredentialManagementResponseBuilder.java | 1 - .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 39 +++++-------------- .../org.wso2.carbon.device.mgt.common/pom.xml | 9 ----- .../org.wso2.carbon.device.mgt.core/pom.xml | 29 -------------- .../impl/DeviceInformationManagerImpl.java | 17 +++----- .../DeviceManagementProviderServiceImpl.java | 7 +++- .../mgt/core/util/DeviceManagerUtil.java | 6 ++- components/device-mgt/pom.xml | 3 -- .../pom.xml | 12 +++--- features/device-mgt/pom.xml | 2 +- pom.xml | 12 +++--- 19 files changed, 56 insertions(+), 191 deletions(-) diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index 4eada72d20..0629418662 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -155,17 +155,6 @@ cxf-bundle-jaxrs provided - - - - - - - - - - - javax.ws.rs jsr311-api diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java index f9ee5e913d..9ccbecda3d 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java @@ -200,8 +200,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); KeyManagerConfigurations kmConfig = deviceManagementConfig.getKeyManagerConfigurations(); AppRegistrationCredentials credentials = DeviceManagerUtil.getApplicationRegistrationCredentials( - System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HOST), - System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HTTPS_PORT), + System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HOST), + System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HTTPS_PORT), kmConfig.getAdminUsername(), kmConfig.getAdminPassword()); AccessTokenInfo accessTokenForAdmin = DeviceManagerUtil.getAccessTokenForDeviceOwner( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 86b7e6e035..38bc2c001a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -155,32 +155,11 @@ cxf-bundle-jaxrs provided - - - - - - - - - - - - - - - - commons-httpclient.wso2 commons-httpclient provided - - - - - org.wso2.carbon org.wso2.carbon.utils @@ -211,11 +190,6 @@ org.wso2.carbon.device.mgt.common provided - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.extensions @@ -362,11 +336,6 @@ org.wso2.carbon.analytics.api provided - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension @@ -413,11 +382,6 @@ org.wso2.carbon.event.stream.persistence.stub provided - - - - - org.powermock powermock-module-testng diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java index fc0ce9c794..205f1b8ee2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java @@ -67,6 +67,7 @@ import javax.ws.rs.core.Response; @Consumes(MediaType.APPLICATION_JSON) public interface DeviceEventManagementService { + //todo:amalka // @POST // @Path("/{type}") // @ApiOperation( @@ -178,6 +179,7 @@ public interface DeviceEventManagementService { "ios, and windows.", required = false) @PathParam("type")String deviceType); + //todo:amalka // @GET // @Path("/{type}/{deviceId}") // @ApiOperation( @@ -240,6 +242,7 @@ public interface DeviceEventManagementService { // @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) // @QueryParam("limit") int limit); + //todo:amalka // @GET // @Path("last-known/{type}/{deviceId}") // @ApiOperation( @@ -296,6 +299,7 @@ public interface DeviceEventManagementService { // @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) // @QueryParam("limit") int limit); + //todo:amalka // @GET // @Path("filter/{type}/{parameter}") // @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java index 8b3071f1ef..4a3e994f70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java @@ -97,6 +97,7 @@ public interface GeoLocationBasedService { /** * Retrieve Analytics for the device type */ + //todo:amalka // @GET // @Path("stats/{deviceType}/{deviceId}") // @ApiOperation( @@ -602,6 +603,7 @@ public interface GeoLocationBasedService { /** * Retrieve Geo alerts history */ + //todo:amalka // @GET // @Path("alerts/history/{deviceType}/{deviceId}") // @ApiOperation( @@ -671,6 +673,7 @@ public interface GeoLocationBasedService { /** * Retrieve Geo alerts history for geo clusters */ + //todo:amalka // @GET // @Path("alerts/history") // @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java index 52702536d1..47126e22da 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceAgentServiceImpl.java @@ -26,7 +26,6 @@ import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; @@ -36,7 +35,6 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidConfigurationException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; @@ -52,7 +50,6 @@ import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto; import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; -import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index f5a7dacfd1..eda7ee4822 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -4,29 +4,13 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.client.Stub; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -//import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -//import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; -//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; -//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; -//import org.wso2.carbon.analytics.dataservice.commons.SortByField; -//import org.wso2.carbon.analytics.dataservice.commons.SortType; -//import org.wso2.carbon.analytics.datasource.commons.Record; -//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -//import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException; -//import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; -//import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable; -//import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord; import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AttributeType; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.DeviceTypeEvent; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventAttributeList; -import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventRecords; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.TransportType; import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceEventManagementService; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; @@ -43,21 +27,14 @@ import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; -import javax.validation.Valid; import javax.ws.rs.DELETE; 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; import java.rmi.RemoteException; import java.util.ArrayList; -import java.util.Calendar; -import java.util.Comparator; -import java.util.HashSet; import java.util.List; -import java.util.Set; /** @@ -81,6 +58,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe private static final String MQTT_CONTENT_VALIDATOR = "default"; private static final String TIMESTAMP_FIELD_NAME = "_timestamp"; + //todo:amalka // private static AnalyticsDataAPI getAnalyticsDataAPI() { // PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); // AnalyticsDataAPI analyticsDataAPI = @@ -195,6 +173,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe /** * Deploy Event Stream, Receiver, Publisher and Store Configuration. */ + //todo:amalka // @POST // @Path("/{type}") // @Override @@ -349,6 +328,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe /** * Returns device specific data for the give period of time. */ + //todo:amalka // @GET // @Path("/{type}/{deviceId}") // @Override @@ -403,6 +383,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe * Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point. * Limit parameter needs to be zero or positive. */ + //todo:amalka // @GET // @Path("/last-known/{type}/{deviceId}") // @Override @@ -453,6 +434,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe * Returns the filterd device list. Devices are filterd using the paramter given and the timestamp of the record. * parameter should given as a range. */ + //todo:amalka // @GET // @Path("filter/{type}/{parameter}") // @Override @@ -613,6 +595,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe } } + //todo:amalka // private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes) // throws RemoteException, UserStoreException, JWTClientException, // EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java index 9075dceddd..30ea94954c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java @@ -25,15 +25,6 @@ import com.google.gson.Gson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; -//import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -//import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; -//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; -//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; -//import org.wso2.carbon.analytics.dataservice.commons.SortByField; -//import org.wso2.carbon.analytics.dataservice.commons.SortType; -//import org.wso2.carbon.analytics.datasource.commons.Record; -//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; @@ -46,7 +37,6 @@ import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationExceptio import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.geo.service.Alert; import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException; -import org.wso2.carbon.device.mgt.common.geo.service.Event; import org.wso2.carbon.device.mgt.common.geo.service.GeoFence; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; @@ -57,18 +47,13 @@ import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; import org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy.GeoHashLengthStrategy; import org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy.ZoomGeoHashLengthStrategy; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.EventAction; import org.wso2.carbon.device.mgt.jaxrs.beans.GeofenceWrapper; import org.wso2.carbon.device.mgt.jaxrs.service.api.GeoLocationBasedService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; -import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -82,9 +67,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * The api for @@ -93,6 +76,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class); + //todo:amalka // @Path("stats/{deviceType}/{deviceId}") // @GET // @Consumes("application/json") @@ -471,6 +455,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { } } + //todo:amalka // @Path("alerts/history/{deviceType}/{deviceId}") // @GET // @Consumes("application/json") @@ -521,6 +506,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { // } // } + //todo:amalka // @Path("alerts/history") // @GET // @Consumes("application/json") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java index 16d4102176..19a8e59979 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java @@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index fd8b0d9f59..49a734cdee 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -45,31 +45,28 @@ import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; -//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; -import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; +import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; -//import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.MonitoringOperation; +import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshotWrapper; -import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationProviderService; -import org.wso2.carbon.device.mgt.common.exceptions.BadRequestException; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshotWrapper; +import org.wso2.carbon.device.mgt.common.exceptions.BadRequestException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.UnAuthorizedException; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; @@ -373,24 +370,6 @@ public class DeviceMgtAPIUtils { return privacyComplianceProvider; } - -// public static IntegrationClientService getIntegrationClientService() { -// if (integrationClientService == null) { -// synchronized (DeviceMgtAPIUtils.class) { -// if (integrationClientService == null) { -// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); -// integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null); -// if (integrationClientService == null) { -// String msg = "IntegrationClientService is not initialized"; -// log.error(msg); -// throw new IllegalStateException(msg); -// } -// } -// } -// } -// return integrationClientService; -// } - /** * Initializing and accessing method for OTPManagementService. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index d896782b1a..dc6240b236 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -50,7 +50,6 @@ javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", com.fasterxml.jackson.annotation;version="${jackson-annotations.version}", - io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional, com.google.gson @@ -96,14 +95,6 @@ org.wso2.orbit.com.fasterxml.jackson.core jackson-annotations - - - - - - - - com.google.code.gson gson diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index ae28f57c44..68e174db3f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -90,7 +90,6 @@ org.wso2.carbon.core, org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.user.api, org.wso2.carbon.user.core.*, org.wso2.carbon.registry.core.service, @@ -104,8 +103,6 @@ org.wso2.carbon.ndatasource.core, org.wso2.carbon.ntask.core.*, org.wso2.carbon.ntask.common, - - org.apache.commons.collections;version="${commons-collections.version.range}", org.wso2.carbon.email.sender.*, io.swagger.annotations.*;resolution:=optional, @@ -166,32 +163,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common - - - - - - - - - - - - - - - - - - - - - - - - - - org.wso2.carbon org.wso2.carbon.logging diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index 396df0f61f..e1ce6c4f9c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -22,22 +22,17 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; -import org.wso2.carbon.device.mgt.common.device.details.DeviceData; import org.wso2.carbon.device.mgt.common.device.details.DeviceDetailsWrapper; +import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.EventPublishingException; import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; -import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.core.config.tenant.PlatformConfigurationManagementServiceImpl; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; @@ -46,18 +41,14 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManag import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO; import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; - -import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.report.mgt.Constants; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil; -import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; import java.util.HashMap; import java.util.List; @@ -178,6 +169,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { deviceInfo.getAvailableRAMMemory(), deviceInfo.isPluggedIn() }; + //todo:amalka // DeviceManagerUtil.getEventPublisherService().publishEvent( // DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // ); @@ -193,6 +185,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceDetailsMgtException("Error occurred while updating the last update timestamp of the " + "device", e); + //todo:amalka // } catch (DataPublisherConfigurationException e) { // throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); } finally { @@ -389,6 +382,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { deviceLocation.getBearing(), deviceLocation.getDistance() }; + //todo:amalka // DeviceManagerUtil.getEventPublisherService().publishEvent( // LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // ); @@ -403,6 +397,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { } catch (DeviceManagementException e) { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceDetailsMgtException("Error occurred while getting the device information.", e); + //todo:amalka // } catch (DataPublisherConfigurationException e) { // DeviceManagementDAOFactory.rollbackTransaction(); // throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 52a169ef61..dba8d2b88e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -49,7 +49,6 @@ import org.apache.http.protocol.HTTP; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.common.ActivityPaginationRequest; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceEnrollmentInfoNotification; @@ -163,6 +162,8 @@ import java.util.Map; import java.util.Properties; import java.util.stream.Collectors; +//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; + public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService, PluginInitializationListener { @@ -1964,6 +1965,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv operation.getStatus() != null ? operation.getStatus().toString() : null, operation.getOperationResponse() }; + //todo:amalka // DeviceManagerUtil.getEventPublisherService().publishEvent( // OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // ); @@ -1973,6 +1975,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String msg = "Error occurred while reading configs."; log.error(msg, e); throw new OperationManagementException(msg, e); + //todo:amalka } //catch (DataPublisherConfigurationException e) { // String msg = "Error occurred while publishing event."; // log.error(msg, e); @@ -2006,6 +2009,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv operation.getStatus() != null ? operation.getStatus().toString() : null, operation.getOperationResponse() }; + //todo:amalka // DeviceManagerUtil.getEventPublisherService().publishEvent( // OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // ); @@ -2015,6 +2019,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String msg = "Error occurred while reading configs."; log.error(msg, e); throw new OperationManagementException(msg, e); + //todo:amalka } //catch (DataPublisherConfigurationException e) { // String msg = "Error occurred while publishing event."; // log.error(msg, e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 13593baf12..0a2932e930 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -50,7 +50,6 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.caching.impl.CacheImpl; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -//import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials; import org.wso2.carbon.device.mgt.common.ApplicationRegistration; import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException; @@ -67,11 +66,11 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationProviderService; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; import org.wso2.carbon.device.mgt.common.geo.service.GeofenceData; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; @@ -129,6 +128,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.IntStream; +//import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; + public final class DeviceManagerUtil { private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); @@ -595,6 +596,7 @@ public final class DeviceManagerUtil { return Caching.getCacheManagerFactory().getCacheManager(DeviceManagementConstants.DM_CACHE_MANAGER); } + //todo:amalka // public static EventsPublisherService getEventPublisherService() { // PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); // EventsPublisherService eventsPublisherService = diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 709e09d6bc..adb86890c8 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -36,11 +36,8 @@ org.wso2.carbon.device.mgt.core org.wso2.carbon.device.mgt.common org.wso2.carbon.device.mgt.extensions - org.wso2.carbon.device.mgt.ui org.wso2.carbon.device.mgt.api - org.wso2.carbon.device.mgt.url.printer - io.entgra.carbon.device.mgt.config.api diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 5dcaac8a0f..4472e7200f 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -39,11 +39,11 @@ org.wso2.carbon.device.mgt.server.feature zip - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.ui.feature - zip - + + + + + javax.servlet.jsp javax.servlet.jsp-api @@ -80,7 +80,7 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.server.feature:${carbon.device.mgt.version} - org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.ui.feature:${carbon.device.mgt.version} + javax.servlet.jsp:javax.servlet.jsp-api diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 1c4c45ab71..37bcec882b 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -35,7 +35,7 @@ org.wso2.carbon.device.mgt.basics.feature org.wso2.carbon.device.mgt.server.feature - org.wso2.carbon.device.mgt.ui.feature + org.wso2.carbon.device.mgt.api.feature org.wso2.carbon.device.mgt.feature org.wso2.carbon.device.mgt.extensions.feature diff --git a/pom.xml b/pom.xml index 4f443c2add..a6156c75b0 100644 --- a/pom.xml +++ b/pom.xml @@ -310,12 +310,12 @@ zip ${carbon.device.mgt.version} - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.ui.feature - zip - ${carbon.device.mgt.version} - + + + + + + org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.application.extension From 8590268db48a397b7151d870d9646f52990be4c3 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 12:33:04 +0530 Subject: [PATCH 25/49] cleaned up components/heartbeat-management/ --- .../pom.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml index 65b62fca38..2aab7d1cdd 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml @@ -61,12 +61,6 @@ org.wso2.carbon.utils.*, org.wso2.carbon.ndatasource.core, org.w3c.dom, - - - - - - org.apache.commons.io, org.apache.axis2.transport.mail, org.apache.commons.collections, @@ -149,14 +143,6 @@ org.apache.axis2.wso2 axis2 - - - - - - - - commons-io.wso2 commons-io From bf074061f17c03d65ed322dc814bd67a9a0fc043 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 12:36:01 +0530 Subject: [PATCH 26/49] cleaned up components/identity-extensions --- .../org.wso2.carbon.device.mgt.oauth.extensions/pom.xml | 9 ++------- .../handlers/grant/AccessTokenGrantHandler.java | 5 +++-- .../handlers/grant/ExtendedJWTGrantHandler.java | 8 ++++++-- .../handlers/grant/ExtendedSAML2BearerGrantHandler.java | 5 +++-- .../pom.xml | 4 ++-- components/identity-extensions/pom.xml | 2 -- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 27de8ac3a6..ae46c74805 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -87,11 +87,10 @@ org.wso2.carbon.device.mgt.oauth.extensions.* - + org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}", org.apache.commons.lang, org.apache.commons.logging, - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.osgi.service.component, org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.application.common;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.application.mgt.*;version="${carbon.identity.framework.version.range}", @@ -114,10 +113,6 @@ org.apache.oltu.oauth2.common.validators, org.apache.commons.lang3.tuple, - - - - diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java index 4cc7881344..1153cb0561 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator; import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; @@ -57,8 +58,8 @@ public class AccessTokenGrantHandler extends AbstractAuthorizationGrantHandler { } @Override - public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { - return super.validateScope(tokReqMsgCtx); + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { + return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); } @Override diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java index f6560e76eb..006317f179 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedJWTGrantHandler.java @@ -20,10 +20,14 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler; import org.wso2.carbon.identity.oauth2.model.RequestParameter; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; /** * This sets up user with tenant aware username. @@ -34,8 +38,8 @@ public class ExtendedJWTGrantHandler extends JWTBearerGrantHandler { private static final String TENANT_DOMAIN_KEY = "tenantDomain"; @Override - public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { - return super.validateScope(tokReqMsgCtx); + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { + return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); } @Override diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java index 2193d2d3ed..5caededdaf 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/handlers/grant/ExtendedSAML2BearerGrantHandler.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; @@ -34,8 +35,8 @@ public class ExtendedSAML2BearerGrantHandler extends SAML2BearerGrantHandler { private static Log log = LogFactory.getLog(ExtendedSAML2BearerGrantHandler.class); @Override - public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { - return super.validateScope(tokReqMsgCtx); + public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { + return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); } @Override diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index abcf3859a3..4adb6539ab 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -109,8 +109,8 @@ org.apache.commons.httpclient, org.apache.commons.logging, org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.osgi.framework, + org.osgi.service.component, org.wso2.carbon.core.security, org.wso2.carbon.core.services.authentication, org.wso2.carbon.utils.multitenancy, diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index de175d9dba..bbf1f08a4e 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -33,8 +33,6 @@ http://wso2.org - - org.wso2.carbon.identity.jwt.client.extension From 1f2b1e84e6971c4ef86a1ee5fc531ff4bdb5a424 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 12:46:56 +0530 Subject: [PATCH 27/49] cleaned up components/policy-mgt --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index a6156c75b0..22525c77c5 100644 --- a/pom.xml +++ b/pom.xml @@ -226,11 +226,6 @@ org.wso2.carbon.policy.mgt.core ${carbon.device.mgt.version} - - org.wso2.carbon.devicemgt - org.wso2.carbon.complex.policy.decision.point - ${carbon.device.mgt.version} - org.wso2.carbon.devicemgt org.wso2.carbon.policy.decision.point From 95695e850de2a2e0a547a0e19ca81343264ca242 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 12:48:50 +0530 Subject: [PATCH 28/49] cleaned up components/transport-mgt --- .../pom.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml index edc6bfedb2..8a8ae5ee3c 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml @@ -96,21 +96,6 @@ cxf-bundle-jaxrs provided - - - - - - - - - - - - - - - javax.servlet javax.servlet-api From 73df5e2fedc7bfb428448e65c416872d784148c0 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 13:06:30 +0530 Subject: [PATCH 29/49] cleaned up components/ui-request-interceptor --- .../io.entgra.ui.request.interceptor/pom.xml | 20 +++++-------------- .../ui/request/interceptor/LoginHandler.java | 13 +++--------- .../interceptor/SsoLoginCallbackHandler.java | 2 +- .../request/interceptor/SsoLoginHandler.java | 6 +++--- .../ui/request/interceptor/UserHandler.java | 8 +++++--- .../request/interceptor/util/HandlerUtil.java | 19 ++---------------- 6 files changed, 19 insertions(+), 49 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml index 783643a999..d41942e3f6 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml @@ -103,6 +103,11 @@ org.wso2.carbon.apimgt.application.extension provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + provided + org.springframework spring-web @@ -113,21 +118,6 @@ cxf-bundle-jaxrs provided - - - - - - - - - - - - - - - javax.servlet javax.servlet-api diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index 5a664552b8..cd0ff14a20 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -24,6 +24,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import io.entgra.ui.request.interceptor.beans.AuthData; +import io.entgra.ui.request.interceptor.beans.ProxyResponse; import io.entgra.ui.request.interceptor.exceptions.LoginException; import io.entgra.ui.request.interceptor.util.HandlerConstants; import io.entgra.ui.request.interceptor.util.HandlerUtil; @@ -34,17 +35,12 @@ import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; -import org.apache.http.protocol.HTTP; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; -import org.wso2.carbon.authenticator.stub.AuthenticationAdmin; -import org.wso2.carbon.authenticator.stub.Login; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.ui.request.interceptor.beans.ProxyResponse; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -81,7 +77,8 @@ public class LoginHandler extends HttpServlet { //setting session to expiry in 5 minutes httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT)); //todo: amalka do we need this remote call? - JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); + JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession( + uiConfigUrl, gatewayUrl, httpSession, resp); JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); @@ -140,11 +137,7 @@ public class LoginHandler extends HttpServlet { HttpServletResponse resp, JsonArray scopes) throws LoginException { JsonParser jsonParser = new JsonParser(); try { -// JsonElement jClientAppResult = jsonParser.parse(clientAppResult); if (clientId != null && clientSecret != null) { -// JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); -// String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); -// String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); String encodedClientApp = Base64.getEncoder() .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java index 641aa6d990..8ee6ec776b 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -61,7 +61,7 @@ public class SsoLoginCallbackHandler extends HttpServlet { String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + HandlerConstants.COLON + iotsCorePort; - HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT); + HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index 23e76b81ae..1ade046d43 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -101,7 +101,7 @@ public class SsoLoginHandler extends HttpServlet { */ private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { try { - File userMgtConf = new File("repository/conf/user-mgt.xml"); + File userMgtConf = new File("conf/user-mgt.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(userMgtConf); @@ -136,7 +136,7 @@ public class SsoLoginHandler extends HttpServlet { JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); // Register the client application - HttpPost apiRegEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.APP_REG_ENDPOINT); + HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); encodedAdminCredentials = Base64.getEncoder() .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes()); apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + @@ -262,7 +262,7 @@ public class SsoLoginHandler extends HttpServlet { * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ private ProxyResponse getTokenResult(String encodedClientApp) throws IOException { - HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT); + HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java index 67b2834516..d6ef958a5c 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/UserHandler.java @@ -33,6 +33,8 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -72,9 +74,9 @@ public class UserHandler extends HttpServlet { HttpPost introspectionEndpoint = new HttpPost(serverUrl + HandlerConstants.INTROSPECT_ENDPOINT); introspectionEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - //todo:amalka - String username = "admin"; - String password = "admin"; + DeviceManagementConfig dmc = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + String username = dmc.getKeyManagerConfigurations().getAdminUsername(); + String password = dmc.getKeyManagerConfigurations().getAdminPassword(); introspectionEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() .encodeToString((username + HandlerConstants.COLON + password).getBytes())); StringEntity introspectionPayload = new StringEntity("token=" + accessToken, diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java index bc864c03ee..4582468a0c 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java @@ -23,8 +23,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.sun.org.apache.xml.internal.serialize.OutputFormat; -import com.sun.org.apache.xml.internal.serialize.XMLSerializer; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -38,12 +36,12 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.xml.serialize.OutputFormat; +import org.apache.xml.serialize.XMLSerializer; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; import io.entgra.ui.request.interceptor.beans.ProxyResponse; -import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; -import org.wso2.carbon.context.PrivilegedCarbonContext; import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; @@ -82,7 +80,6 @@ public class HandlerUtil { HandlerConstants.INTERNAL_ERROR_CODE)); return proxyResponse; } else { - int statusCode = response.getStatusLine().getStatusCode(); try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) { StringBuilder result = new StringBuilder(); @@ -403,16 +400,4 @@ public class HandlerUtil { return stringOutput; } - - public static APIManagementProviderService getAPIManagementProviderService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - APIManagementProviderService apiManagementProviderService = - (APIManagementProviderService) ctx.getOSGiService(APIManagementProviderService.class, null); - if (apiManagementProviderService == null) { - String msg = "API management provider service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return apiManagementProviderService; - } } From 0d8750f0a7493c89d40fc0d50f30f5fe3b92491a Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 13:07:47 +0530 Subject: [PATCH 30/49] cleaned up components/webapp-authenticator-framework --- .../pom.xml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 64e71e342d..2d3df3e061 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -63,15 +63,15 @@ javax.xml.bind.annotation, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.validation, - - - + org.apache.catalina, + org.apache.catalina.connector, + org.apache.catalina.util, org.apache.commons.logging, - - - - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.apache.coyote, + org.apache.tomcat.util.buf, + org.apache.tomcat.util.http, + org.osgi.service.component, + org.osgi.framework, org.w3c.dom, org.wso2.carbon.context, org.wso2.carbon.core.util, @@ -79,7 +79,7 @@ org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}", org.wso2.carbon.identity.oauth2.*; version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}", - + org.wso2.carbon.tomcat.ext.valves, org.wso2.carbon.user.api, org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.tenant, @@ -106,8 +106,8 @@ org.apache.commons.pool.impl, org.apache.http.conn, org.apache.http.impl.conn, - - + javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}", + javax.xml.stream, org.apache.axiom.*; version="${axiom.osgi.version.range}", org.wso2.carbon.registry.core.*, org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}", From 291565127252f02546e374a9eaf697ad30fa07ab Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 10 May 2021 13:23:36 +0530 Subject: [PATCH 31/49] cleaned up features --- .../pom.xml | 6 +- .../conf/webapp-publisher-config.xml | 2 +- features/apimgt-extensions/pom.xml | 2 - .../pom.xml | 49 --------------- .../apis/admin--OAuth2TokenManagement.xml | 1 - .../admin--UserManagementValidateUser.xml | 1 - .../pom.xml | 2 - .../pom.xml | 6 -- features/device-mgt/pom.xml | 2 - .../pom.xml | 8 --- pom.xml | 61 ++----------------- 11 files changed, 8 insertions(+), 132 deletions(-) diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index 401ad66f4e..a934c7dc4c 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -107,9 +107,9 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.client:${project.version} - - - + + org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.generated.client:${project.version} + diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml index ff54fb9cb8..067a6af7f8 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf/webapp-publisher-config.xml @@ -24,7 +24,7 @@ - https://localhost:9443 + https://${iot.core.host}:${iot.core.https.port} true diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 956fdf8d49..3561b8c4d6 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -35,10 +35,8 @@ http://wso2.org - org.wso2.carbon.apimgt.webapp.publisher.feature org.wso2.carbon.apimgt.application.extension.feature - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index 845938c469..f315096d69 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -43,34 +43,6 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -127,27 +99,6 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:${carbon.device.mgt.version} - - - - - - - - - - - - - - - - - - - - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml index 23c74aaedb..637f40f776 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--OAuth2TokenManagement.xml @@ -20,7 +20,6 @@ - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml index 7d26b7b857..ec61d66eec 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/apis/admin--UserManagementValidateUser.xml @@ -20,7 +20,6 @@ - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index 0222243bf9..00d4a96a0b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -87,8 +87,6 @@ org.wso2.carbon.core.server:${carbon.kernel.version} - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 4472e7200f..f986e520a0 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -39,11 +39,6 @@ org.wso2.carbon.device.mgt.server.feature zip - - - - - javax.servlet.jsp javax.servlet.jsp-api @@ -80,7 +75,6 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.server.feature:${carbon.device.mgt.version} - javax.servlet.jsp:javax.servlet.jsp-api diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 37bcec882b..528051da15 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -35,11 +35,9 @@ org.wso2.carbon.device.mgt.basics.feature org.wso2.carbon.device.mgt.server.feature - org.wso2.carbon.device.mgt.api.feature org.wso2.carbon.device.mgt.feature org.wso2.carbon.device.mgt.extensions.feature - diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml index 6d17103c21..de26779b16 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml @@ -73,14 +73,6 @@ org.codehaus.woodstox wstx-asl - - - - - - - - diff --git a/pom.xml b/pom.xml index 22525c77c5..e902abd70c 100644 --- a/pom.xml +++ b/pom.xml @@ -54,11 +54,6 @@ features/jwt-client features/device-mgt-extensions features/transport-mgt - - - - - @@ -241,16 +236,6 @@ org.wso2.carbon.apimgt.webapp.publisher ${carbon.device.mgt.version} - - - - - - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.annotations @@ -282,11 +267,6 @@ org.wso2.carbon.device.mgt.analytics.data.publisher ${carbon.device.mgt.version} - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.server.feature @@ -305,12 +285,6 @@ zip ${carbon.device.mgt.version} - - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.apimgt.application.extension @@ -326,12 +300,6 @@ org.wso2.carbon.apimgt.application.extension.api ${carbon.device.mgt.version} - - - - - - org.wso2.carbon.devicemgt org.wso2.carbon.device.application.mgt.server.feature @@ -479,7 +447,8 @@ javax.servlet - javax.servlet-api + javax.servlet-api + @@ -828,7 +797,7 @@ org.wso2.carbon org.wso2.carbon.logging - 4.4.9 + ${org.wso2.carbon.logging.version} org.wso2.carbon @@ -1159,17 +1128,6 @@ - - - - - - - - - - - org.apache.cxf cxf-rt-rs-extension-providers @@ -1353,21 +1311,11 @@ gson ${google.gson.version} - - org.wso2.orbit.com.squareup.okhttp - okhttp - ${okhttp.wso2.version} - com.squareup.okhttp3 okhttp ${squareup.okhttp3.version} - - org.wso2.orbit.com.squareup.okio - okio - ${okio.wso2.version} - com.squareup.okio okio @@ -2085,6 +2033,7 @@ 5.1.2 1.3 3.1.3 + 4.4.9 [1.6.1.wso2v11, 1.7.0) @@ -2193,8 +2142,6 @@ 1.3 2.3.1 4.6.0 - 4.2.0.wso2v1 - 2.4.0.wso2v1 1.13.0 9.3.1 1.1.1 From 6c947962d6a19a420908064f5cb66d60638398c7 Mon Sep 17 00:00:00 2001 From: Kaveesha Date: Wed, 12 May 2021 15:00:56 +0530 Subject: [PATCH 32/49] Update item bean class to get documentation link from xml --- .../carbon/device/mgt/common/policy/mgt/ui/Item.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/ui/Item.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/ui/Item.java index faf97d7e11..43927eb876 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/ui/Item.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/ui/Item.java @@ -27,6 +27,7 @@ public class Item { private String label; private String tooltip; + private String docLink; private String key; private String value; private boolean isRequired; @@ -65,6 +66,16 @@ public class Item { this.tooltip = tooltip; } + @XmlElement(name = "DocLink") + public String getDocLink() { + return docLink; + } + + public void setDocLink(String docLink) { + this.docLink = docLink; + } + + @XmlElement(name = "Key", required = true) public String getKey() { return key; From 6cfdf85c1d4938b8a45fa49dae5c10dedcc409c2 Mon Sep 17 00:00:00 2001 From: vigneshan Date: Wed, 12 May 2021 21:53:43 +0530 Subject: [PATCH 33/49] Update invoker handler to append tenant-id for reporting backend get api calls --- .../io/entgra/ui/request/interceptor/InvokerHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java index 51a6c06674..d56202d8e2 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java @@ -48,6 +48,7 @@ import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.InputStreamBody; import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.context.CarbonContext; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -110,6 +111,11 @@ public class InvokerHandler extends HttpServlet { HttpGet getRequest = new HttpGet(generateBackendRequestURL(req)); copyRequestHeaders(req, getRequest, false); getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); + if (apiEndpoint.equals(System.getProperty("iot.reporting.webapp.host"))) { + getRequest.setHeader("Tenant-Id", String.valueOf( + CarbonContext.getThreadLocalCarbonContext().getTenantId() + )); + } ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); if (HandlerConstants.TOKEN_IS_EXPIRED.equals(proxyResponse.getExecutorResponse())) { proxyResponse = retryRequestWithRefreshedToken(req, resp, getRequest); From a12be72a1317f3b578f85bc4e84c4ae9f1bec6c2 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 14 May 2021 10:34:41 +0530 Subject: [PATCH 34/49] updated to kernel 4.6.2 --- .../pom.xml | 29 +++++----- .../APIManagementProviderService.java | 21 -------- .../APIManagementProviderServiceImpl.java | 53 ++++--------------- .../publisher/APIPublisherServiceImpl.java | 4 +- .../pom.xml | 2 +- .../org.wso2.carbon.device.mgt.core/pom.xml | 2 - .../ui/request/interceptor/LoginHandler.java | 2 +- pom.xml | 45 +++++++--------- 8 files changed, 44 insertions(+), 114 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 3f0f92602b..0282a89040 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -73,11 +73,6 @@ org.wso2.carbon.identity.jwt.client.extension provided - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core - provided - @@ -109,28 +104,28 @@ org.apache.commons.lang;version="[2.6,3)", org.apache.commons.logging;version="[1.2,2)", - org.json.simple,org.osgi.framework;version="${imp.package.version.osgi.framework}", - org.osgi.service.component;version="${imp.package.version.osgi.service}", - org.wso2.carbon.apimgt.api;version="[9.0,10)", - org.wso2.carbon.apimgt.api.dto;version="[9.0,10)", - org.wso2.carbon.apimgt.api.model;version="[9.0,10)", + org.json.simple, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.wso2.carbon.apimgt.api;version="${carbon.api.mgt.version.range}", + org.wso2.carbon.apimgt.api.dto;version="${carbon.api.mgt.version.range}", + org.wso2.carbon.apimgt.api.model;version="${carbon.api.mgt.version.range}", org.wso2.carbon.apimgt.application.extension.bean, org.wso2.carbon.apimgt.application.extension.dto, org.wso2.carbon.apimgt.application.extension.exception, - org.wso2.carbon.apimgt.impl;version="[9.0,10)", - org.wso2.carbon.apimgt.impl.utils;version="[9.0,10)", - org.wso2.carbon.context;version="[4.6,5)", - org.wso2.carbon.device.mgt.core.config.ui;version="[4.1,5)", + org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}", + org.wso2.carbon.apimgt.impl.utils;version="${carbon.api.mgt.version.range}", + org.wso2.carbon.context;version="${carbon.kernel.version.range}", org.wso2.carbon.identity.jwt.client.extension, org.wso2.carbon.identity.jwt.client.extension.dto, org.wso2.carbon.identity.jwt.client.extension.exception, org.wso2.carbon.identity.jwt.client.extension.service, org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", - org.wso2.carbon.registry.indexing.service;version="[4.7,5)", + org.wso2.carbon.registry.indexing.service;version="${carbon.registry.imp.pkg.version.range}", org.wso2.carbon.user.api;version="[1.0,2)", - org.wso2.carbon.user.core.service;version="[4.6,5)", - org.wso2.carbon.user.core.tenant;version="[4.6,5)" + org.wso2.carbon.user.core.service;version="${carbon.kernel.version.range}", + org.wso2.carbon.user.core.tenant;version="${carbon.kernel.version.range}" !org.wso2.carbon.apimgt.application.extension.internal, diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java index d1bc3911b6..7405737237 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java @@ -50,27 +50,6 @@ public interface APIManagementProviderService { String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException; - /** - * Generate and retreive application keys. if the application does exist then - * create it and subscribe to apis that are grouped with the tags. - * - * @param apiApplicationName name of the application. - * @param tags tags of the apis that application needs to be subscribed. - * @param keyType of the application. - * @param username to whom the application is created - * @param isAllowedAllDomains application is allowed to all the tenants - * @param validityTime validity period of the application - * @param scopes scopes - * @return consumerkey and secrete of the created application. - * @throws APIManagerException - */ - ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, - String tags[], - String keyType, - String username, - boolean isAllowedAllDomains, - String validityTime, String scopes) throws APIManagerException; - /** * Remove APIM Application. */ diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3b46ace15f..40d13f7eda 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -42,8 +42,6 @@ import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; -import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager; import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; @@ -101,7 +99,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe */ @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, boolean isAllowedAllDomains, String validityTime, String scopes) + String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); @@ -125,14 +123,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application = new Application(applicationName, subscriber); application.setTier(ApiApplicationConstants.DEFAULT_TIER); application.setGroupId(""); - applicationId = apiConsumer.addApplication(application, username); + apiConsumer.addApplication(application, username); + application = apiConsumer.getApplicationsByName(username, applicationName, ""); } else { - applicationId = application.getId(); subscriber = apiConsumer.getSubscriber(username); } Set subscribedAPIs = - apiConsumer.getSubscribedAPIsByApplicationId(subscriber, applicationId, ""); + apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); log.info("Already subscribed API count: " + subscribedAPIs.size()); @@ -160,9 +158,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } if (!subscriptionExist && !tempApiIds.contains(id)) { - ApiTypeWrapper apiTypeWrapper = new ApiTypeWrapper(apiInfo); + ApiTypeWrapper apiTypeWrapper = apiConsumer.getAPIorAPIProductByUUID( + apiInfo.getUuid(), tenantDomain); apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); - apiConsumer.addSubscription(apiTypeWrapper, username, applicationId, ""); + + apiConsumer.addSubscription(apiTypeWrapper, username, application); tempApiIds.add(id); } } @@ -210,31 +210,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + "\"username\":\"" + username + "\"}"; - // if scopes not defined - if (StringUtils.isEmpty(scopes)) { - UIConfigurationManager uiConfigurationManager = UIConfigurationManager.getInstance(); - UIConfiguration uiConfiguration = uiConfigurationManager.getUIConfig(); - List scopeList = uiConfiguration.getScopes(); - - if (scopeList != null && scopeList.size() > 0) { - StringBuilder builder = new StringBuilder(); - for (String scope : scopeList) { - String tmpScope = scope + " "; - builder.append(tmpScope); - } - scopes = builder.toString(); - } - - if (StringUtils.isEmpty(scopes)) { - scopes = scopes.trim(); - } else { - scopes = "default"; - } - } - Map keyDetails = apiConsumer .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", - allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, scopes, "", + allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", jsonString, keyManagerId, tenantDomain); if (keyDetails != null) { @@ -252,19 +230,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } - /** - * {@inheritDoc} - */ - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime) - throws APIManagerException { - return this.generateAndRetrieveApplicationKeys(applicationName, tags, keyType, username, - isAllowedAllDomains, validityTime, null); - } - @Override public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, String validityPeriod) throws APIManagerException { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index d1312714c1..b1c7769768 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -50,7 +50,7 @@ import java.util.Set; */ public class APIPublisherServiceImpl implements APIPublisherService { private static final String UNLIMITED_TIER = "Unlimited"; - private static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox"; + private static final String API_PUBLISH_ENVIRONMENT = "Default"; private static final String CREATED_STATUS = "CREATED"; private static final String PUBLISH_ACTION = "Publish"; public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); @@ -179,7 +179,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { accessControlAllowHeaders.add("Content-Type"); accessControlAllowHeaders.add("SOAPAction"); accessControlAllowHeaders.add("apikey"); - accessControlAllowHeaders.add("testKey"); + accessControlAllowHeaders.add("Internal-Key"); List accessControlAllowMethods = new ArrayList<>(); accessControlAllowMethods.add("GET"); accessControlAllowMethods.add("PUT"); diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 81ac96adc5..2a60c2797e 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -140,7 +140,7 @@ org.wso2.carbon.context, org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.push.notification, - org.wso2.carbon.device.mgt.core.service, + org.wso2.carbon.device.mgt.core.*, org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core.exception, org.wso2.carbon.core, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 68e174db3f..30a8d6fa76 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -119,9 +119,7 @@ org.wso2.carbon.device.mgt.core.* - javax.ws.rs-api, scribe;scope=compile|runtime;inline=false, - javassist;inline=false * diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index cd0ff14a20..8843f507cc 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -102,7 +102,7 @@ public class LoginHandler extends HttpServlet { ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( HandlerConstants.PUBLISHER_APPLICATION_NAME, tagsAsStringArray, HandlerConstants.PRODUCTION_KEY, username, false, - ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, scopeString); + ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD); if (apiApplicationKey != null && getTokenAndPersistInSession(apiApplicationKey.getConsumerKey(), apiApplicationKey.getConsumerSecret(), req, resp, scopes)) { diff --git a/pom.xml b/pom.xml index e902abd70c..e3e7998167 100644 --- a/pom.xml +++ b/pom.xml @@ -661,10 +661,6 @@ commons-httpclient.wso2 commons-httpclient - - commons-httpclient.wso2 - commons-httpclient - org.wso2.carbon org.wso2.carbon.registry.api @@ -2028,8 +2024,8 @@ 2.2.1 6.1.1 - 4.6.1 - [4.6.0, 5.0.0) + 4.6.2 + [4.5.0, 5.0.0) 5.1.2 1.3 3.1.3 @@ -2057,9 +2053,9 @@ 4.8.2 - 3.6.100.v20120522-1841 + 3.6.200.v20130402-1505 3.3.100.v20120522-1822 - 3.9.1.v20130814-1242 + 3.9.1.v20140110-1610 1.2.140.wso2v3 @@ -2075,19 +2071,19 @@ 5.18.187 [5.2.0, 7.0.0) 6.4.111 - 5.4.6 + 5.5.2 1.0.31 [1.0.31, 2.0.0) - [5.7.0, 6.0.0) - [5.2.0, 7.0.0) - [5.1.0, 7.0.0) + [5.14.0, 6.0.0) + [6.0.0, 7.0.0) + [5.3.0, 6.0.0) - 4.6.11 + 4.9.10 - 4.7.23 + 4.8.21 1.2.11-wso2v10 @@ -2098,7 +2094,7 @@ 4.1.16-SNAPSHOT - 4.6.21 + 4.7.35 1.4.0.wso2v1 [1.4.0,2.0.0) 2.4.0.wso2v1 @@ -2106,8 +2102,8 @@ [2.6.0,3.0.0) - 9.0.5 - (6.0.0,10.0.0] + 9.0.174 + [9.0.0, 10.0.0) 5.1.37 @@ -2117,7 +2113,7 @@ 2.1.23 - 4.7.38 + 4.7.39 ${carbon.registry.version} [4.7.0, 5.0.0) @@ -2135,12 +2131,9 @@ 2.3.0.wso2v2 - - 2.26.1.wso2v3 - 3.0.0.wso2v1 1.3 - 2.3.1 + 2.8.5 4.6.0 1.13.0 9.3.1 @@ -2191,12 +2184,12 @@ 2.0.1 1.5.10 - 1.5.10 + 1.6.1 4.0.1 1.0.10 - 2.6.1.wso2v1 + 2.9.8.wso2v1 2.6.1.wso2v3 2.8.2.wso2v1 1.2.0.wso2v1 @@ -2220,7 +2213,7 @@ 1.7 - 2.1.7-wso2v7 + 2.1.7-wso2v227 1.5.11.wso2v15 @@ -2258,7 +2251,7 @@ 1.0 1.13.1 - 5.1.2.RELEASE + 5.1.13.RELEASE 2.7.18 [1.6.0, 2.0.0) From 5ac273f362841f64ac0541460cb413d65d6c3ff0 Mon Sep 17 00:00:00 2001 From: Farheen99 Date: Sun, 16 May 2021 20:31:20 +0530 Subject: [PATCH 35/49] Add code changes to read a new xml element named scope from android.xml file --- .../type/template/config/OperationMetadata.java | 12 ++++++++++++ .../feature/ConfigurationBasedFeatureManager.java | 4 ++++ .../request/interceptor/util/HandlerConstants.java | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/OperationMetadata.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/OperationMetadata.java index 81a4139d8e..9fc9715f4d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/OperationMetadata.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/OperationMetadata.java @@ -58,6 +58,7 @@ import java.util.List; "method", "contentType", "permission", + "scope", "filterList" }) public class OperationMetadata { @@ -74,6 +75,9 @@ public class OperationMetadata { @XmlElement(name = "permission") private String permission; + @XmlElement(name = "scope") + private String scope; + @XmlElementWrapper(name = "filters") @XmlElement(name = "filter") private List filterList; @@ -110,6 +114,14 @@ public class OperationMetadata { this.permission = permission; } + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + public List getFilterList() { return filterList; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java index 1043628369..95c702041f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java @@ -63,6 +63,7 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { private static final String OPERATION_META = "operationMeta"; private static final String CONTENT_TYPE = "contentType"; private static final String PERMISSION = "permission"; + private static final String SCOPE = "scope"; private static final String ICON = "icon"; private static final String FILTERS = "filters"; private static final String PATH_PARAMS = "pathParams"; @@ -108,6 +109,9 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { if (StringUtils.isNotEmpty(metadata.getPermission())) { operationMeta.put(PERMISSION, metadata.getPermission()); } + if (StringUtils.isNotEmpty(metadata.getScope())) { + operationMeta.put(SCOPE, metadata.getScope()); + } if (metadata.getFilterList() != null && metadata.getFilterList().size() > 0) { operationMeta.put(FILTERS, metadata.getFilterList()); } diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index b94309be57..acddc17ce9 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -80,5 +80,5 @@ public class HandlerConstants { public static final String IOT_GW_HOST_ENV_VAR = "iot.gateway.host"; public static final String IOT_GW_HTTP_PORT_ENV_VAR = "iot.gateway.http.port"; public static final String IOT_GW_HTTPS_PORT_ENV_VAR = "iot.gateway.https.port"; - public static final String USER_SCOPES = "user-scopes"; + public static final String USER_SCOPES = "userScopes"; } From 2f73bcb0c7a635d3b7c077dcb73faddb3b4f10a6 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Mon, 17 May 2021 12:04:21 +0530 Subject: [PATCH 36/49] Support AE with QR code based enrollment Fixes https://gitlab.com/entgra/emm-proprietary-plugins/-/merge_requests/601 --- .../src/main/resources/conf/mdm-ui-config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index a0ba89e8b7..3a425274f1 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -177,6 +177,7 @@ perm:metadata:view perm:metadata:create perm:metadata:update + perm:android:google-account device-mgt From d5c85980e1555b3360636502899a4b3c9c661a60 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 17 May 2021 12:25:32 +0530 Subject: [PATCH 37/49] move appmgt db creation, application-extension synapse apis, cdm datasource config --- .../src/main/resources/p2.inf | 4 +- .../api/_API_Application_Registration_.xml | 63 ++++++++++++++++++ .../sequences/_api_registration_fault_.xml | 22 +++++++ .../pom.xml | 37 +++++++++++ .../src/main/resources/p2.inf | 1 + .../conf/datasources/cdm-datasources.xml | 65 +++++++++++++++++++ .../src/main/resources/p2.inf | 1 + 7 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/api/_API_Application_Registration_.xml create mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/sequences/_api_registration_fault_.xml create mode 100755 features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/p2.inf b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/p2.inf index 1d8124571f..61654c2892 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/p2.inf +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/p2.inf @@ -1,3 +1,5 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.application.extension_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.application.extension_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.application.extension_${feature.version}/synapse-configs/default/api/_API_Application_Registration_.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/_API_Application_Registration_.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.application.extension_${feature.version}/synapse-configs/default/sequences/_api_registration_fault_.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/sequences/_api_registration_fault_.xml,overwrite:true);\ diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/api/_API_Application_Registration_.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/api/_API_Application_Registration_.xml new file mode 100644 index 0000000000..7e25c01342 --- /dev/null +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/api/_API_Application_Registration_.xml @@ -0,0 +1,63 @@ + + + + + + + + + + 60000 + fault + + + + + + + + + + + + + + + + + + 60000 + fault + + + + + + + + + + + + + + + + + + 60000 + fault + + + + + + + + + + + + + + \ No newline at end of file diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/sequences/_api_registration_fault_.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/sequences/_api_registration_fault_.xml new file mode 100644 index 0000000000..335a9abaf3 --- /dev/null +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/src/main/resources/synapse-configs/default/sequences/_api_registration_fault_.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml index d8a8448fac..dc53590a67 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml @@ -60,6 +60,10 @@ cxf-rt-frontend-jaxrs ${cxf.version} + + com.h2database.wso2 + h2-database-engine + @@ -108,6 +112,39 @@ + + org.apache.maven.plugins + maven-antrun-plugin + + + create-app-mgt-schema + package + + run + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.maven carbon-p2-plugin diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf index a12c244131..1a8247162f 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf @@ -1,4 +1,5 @@ instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/database/,target:${installFolder}/../../../repository/database/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/conf/application-mgt.xml,target:${installFolder}/../../conf/application-mgt.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/conf/datasources/application-mgt-datasources.xml,target:${installFolder}/../../conf/datasources/application-mgt-datasources.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/dbscripts/cdm/application-mgt,target:${installFolder}/../../../dbscripts/cdm/application-mgt,overwrite:true);\ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml new file mode 100755 index 0000000000..78db49688e --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml @@ -0,0 +1,65 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + DM_DS + The datasource used for CDM + + jdbc/DM_DS + + + + jdbc:h2:./repository/database/WSO2DM_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000 + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + DM_ARCHIVAL_DS + The archival datasource used for CDM + + jdbc/DM_ARCHIVAL_DS + + + + jdbc:h2:./repository/database/WSO2DM_ARCHIVAL_DS;DB_CLOSE_ON_EXIT=FALSE + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf index 09ec420214..d373520aa0 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf @@ -1,4 +1,5 @@ instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/datasources/cdm-datasources.xml,target:${installFolder}/../../conf/datasources/cdm-datasources.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/mdm-ui-config.xml,target:${installFolder}/../../conf/mdm-ui-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/license-config.xml,target:${installFolder}/../../conf/etc/license-config.xml,overwrite:true);\ From 23b25fb54089ff4576dd4976255fd89b9e2f8105 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Tue, 18 May 2021 14:50:05 +0530 Subject: [PATCH 38/49] Templated configs --- .../conf/etc/webapp-publisher-config.xml.j2 | 56 ++++ .../src/main/resources/p2.inf | 1 + .../repository/conf/application-mgt.xml.j2 | 231 +++++++++++++ .../application-mgt-datasources.xml.j2 | 59 ++++ .../src/main/resources/p2.inf | 1 + .../repository/conf/certificate-config.xml.j2 | 47 +++ .../src/main/resources/p2.inf | 3 +- .../repository/conf/cdm-config.xml.j2 | 315 ++++++++++++++++++ .../conf/datasources/cdm-datasources.xml.j2 | 87 +++++ .../repository/conf/license-config.xml.j2 | 63 ++++ .../repository/conf/mdm-ui-config.xml.j2 | 211 ++++++++++++ .../conf/remote-appmanager-config.xml.j2 | 32 ++ .../src/main/resources/p2.inf | 3 +- .../datasources/heart-beat-datasources.xml.j2 | 57 ++++ .../repository/conf/heart-beat-config.xml.j2 | 61 ++++ .../src/main/resources/p2.inf | 1 + .../conf/email-sender-config.xml.j2 | 38 +++ .../src/main/resources/p2.inf | 3 +- .../repository/conf/sms-config.xml.j2 | 48 +++ .../src/main/resources/p2.inf | 1 + 20 files changed, 1314 insertions(+), 4 deletions(-) create mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-publisher-config.xml.j2 create mode 100644 features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 create mode 100644 features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/application-mgt-datasources.xml.j2 create mode 100755 features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/certificate-config.xml.j2 create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 create mode 100755 features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2 create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/license-config.xml.j2 create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 create mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/remote-appmanager-config.xml.j2 create mode 100644 features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/heart-beat-datasources.xml.j2 create mode 100644 features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/heart-beat-config.xml.j2 create mode 100644 features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/conf_templates/templates/repository/conf/email-sender-config.xml.j2 create mode 100644 features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-publisher-config.xml.j2 b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-publisher-config.xml.j2 new file mode 100644 index 0000000000..d8a0413ec8 --- /dev/null +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-publisher-config.xml.j2 @@ -0,0 +1,56 @@ + + + + + + + + {% if webapp_publisher_configs.host is defined %} + {{webapp_publisher_configs.host}} + {% else %} + https://${iot.core.host}:${iot.core.https.port} + {% endif %} + + + {% if webapp_publisher_configs.publish_api is defined %} + {{webapp_publisher_configs.publish_api}} + {% else %} + true + {% endif %} + + + {% if webapp_publisher_configs.enable_update_api is defined %} + {{webapp_publisher_configs.enable_update_api}} + {% else %} + true + {% endif %} + + + + default + {% if webapp_publisher_configs.profiles is defined %} + {%- for profile in webapp_publisher_configs.profiles -%} + {{profile}} + {% endfor %} + {% endif %} + + \ No newline at end of file diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/p2.inf b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/p2.inf index 3d6782a96f..8b5d94e410 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/p2.inf +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/src/main/resources/p2.inf @@ -1,2 +1,3 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.webapp.publisher_${feature.version}/conf/webapp-publisher-config.xml,target:${installFolder}/../../conf/etc/webapp-publisher-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.webapp.publisher_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 new file mode 100644 index 0000000000..8774964271 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 @@ -0,0 +1,231 @@ + + + + + + jdbc/APPM_DS + + + + {% if application_mgt_conf.extension.application_manager is defined %} + {{application_mgt_conf.extension.application_manager}} + {% else %} + org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl + {% endif %} + + + {% if application_mgt_conf.extension.review_manager is defined %} + {{application_mgt_conf.extension.review_manager}} + {% else %} + org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl + {% endif %} + + + {% if application_mgt_conf.extension.life_cycle_state_manager is defined %} + {{application_mgt_conf.extension.life_cycle_state_manager}} + {% else %} + org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManager + {% endif %} + + + {% if application_mgt_conf.extension.subscription_manager is defined %} + {{application_mgt_conf.extension.subscription_manager}} + {% else %} + org.wso2.carbon.device.application.mgt.core.impl.SubscriptionManagerImpl + {% endif %} + + + {% if application_mgt_conf.extension.application_storage_manager is defined %} + {{application_mgt_conf.extension.application_storage_manager}} + {% if application_mgt_conf.extension.application_storage_manager.parameter_options is defined %} + + {% for property_name,property_value in application_mgt_conf.extension.application_storage_manager.parameter_options.items() %} + {{property_value}} + {% endfor %} + + {% endif %} + {% else %} + org.wso2.carbon.device.application.mgt.core.impl.ApplicationStorageManagerImpl + + repository/resources/apps/ + 6 + + {% endif %} + + + + + + + + + + true + true + true + /app-mgt/life-cycle/application/create + + In-Review + + + + /app-mgt/life-cycle/application/review + + Rejected + Approved + Created + + + + /app-mgt/life-cycle/application/approve + + In-Review + Published + + + + true + /app-mgt/life-cycle/application/reject + + In-Review + + + + true + /app-mgt/life-cycle/application/publish + + Blocked + Deprecated + + + + /app-mgt/life-cycle/application/block + + Published + Deprecated + + + + /app-mgt/life-cycle/application/deprecate + + Published + Retired + + + + true + /app-mgt/life-cycle/application/retire + + + + + EMM + IoT + Art & Design + Auto & Vehicles + Beauty + Books & Reference + Business + Comics + Communications + Dating + Education + Entertainment + Events + Finance + Food & Drink + Health & Fitness + House & Home + Libraries & Demo + Lifestyle + Maps & Navigation + Medical + Music & Audio + News & Magazines + Parenting + Personalization + Photography + Productivity + Shopping + Social + Sports + Tools + Travel & Local + Video Players & Editors + Weather + GooglePlaySyncedApp + {% if application_mgt_conf.app_categories is defined %} + {%- for app_category in application_mgt_conf.app_categories -%} + {{app_category}} + {% endfor %} + {% endif %} + + + + {% if application_mgt_conf.rating_conf.min_rating_value is defined %} + {{application_mgt_conf.rating_conf.min_rating_value}} + {% else %} + 1 + {% endif %} + {% if application_mgt_conf.rating_conf.max_rating_value is defined %} + {{application_mgt_conf.rating_conf.max_rating_value}} + {% else %} + 10 + {% endif %} + + + + {% if application_mgt_conf.mdm_conf.artifact_download_protocol is defined %} + {{application_mgt_conf.mdm_conf.artifact_download_protocol}} + {% else %} + http + {% endif %} + + {% if application_mgt_conf.mdm_conf.artifact_download_endpoint is defined %} + {{application_mgt_conf.mdm_conf.artifact_download_endpoint}} + {% else %} + /api/application-mgt/v1.0/artifact + {% endif %} + + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/application-mgt-datasources.xml.j2 b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/application-mgt-datasources.xml.j2 new file mode 100644 index 0000000000..a25faf6511 --- /dev/null +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/application-mgt-datasources.xml.j2 @@ -0,0 +1,59 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + + APPM_DS + The datasource used for CDM Application Management + + jdbc/APPM_DS + + + + {% if database.app_mgt is defined %} + {{database.app_mgt.url}} + {{database.app_mgt.username}} + {{database.app_mgt.password}} + {{database.app_mgt.driver}} + {{database.app_mgt.validationQuery}} + {% for property_name,property_value in database.app_mgt.pool_options.items() %} + <{{property_name}}>{{property_value}} + {% endfor %} + {% else %} + jdbc:h2:./repository/database/WSO2DM_APPM_DB;DB_CLOSE_ON_EXIT=FALSE + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + {% endif %} + + + + + + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf index 1a8247162f..360d6ef9f9 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/p2.inf @@ -3,6 +3,7 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/conf/application-mgt.xml,target:${installFolder}/../../conf/application-mgt.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/conf/datasources/application-mgt-datasources.xml,target:${installFolder}/../../conf/datasources/application-mgt-datasources.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/dbscripts/cdm/application-mgt,target:${installFolder}/../../../dbscripts/cdm/application-mgt,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.server_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ instructions.unconfigure = \ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/application-mgt-datasources.xml);\ diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/certificate-config.xml.j2 b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/certificate-config.xml.j2 new file mode 100755 index 0000000000..2ffad144e2 --- /dev/null +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/certificate-config.xml.j2 @@ -0,0 +1,47 @@ + + + + {% if certificate_conf.certificate_keystore is defined %} + + {{certificate_conf.certificate_keystore.location}} + + {{certificate_conf.certificate_keystore.type}} + + {{certificate_conf.certificate_keystore.password}} + + {{certificate_conf.certificate_keystore.cacert_alias}} + + {{certificate_conf.certificate_keystore.cacert_password}} + + {{certificate_conf.certificate_keystore.racert_alias}} + + {{certificate_conf.certificate_keystore.racert_password}} + {% else %} + + ${carbon.home}/repository/resources/security/wso2certs.jks + + JKS + + wso2carbon + + cacert + + cacert + + racert + + racert + {% endif %} + + + + + + + jdbc/DM_DS + + + + + 10 + \ No newline at end of file diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/p2.inf b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/p2.inf index ef6d64fc87..345f751daa 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/p2.inf +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/p2.inf @@ -1,4 +1,5 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/conf/wso2certs.jks,target:${installFolder}/../../resources/security/wso2certs.jks,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/conf/certificate-config.xml,target:${installFolder}/../../conf/certificate-config.xml,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts,overwrite:true);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 new file mode 100644 index 0000000000..214ad3f8a8 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -0,0 +1,315 @@ + + + + + + + + jdbc/DM_DS + + + + + {% if device_mgt_conf.push_notification_conf is defined %} + {{device_mgt_conf.push_notification_conf.scheduler_batch_size}} + {{device_mgt_conf.push_notification_conf.scheduler_batch_delay_mills}} + {{device_mgt_conf.push_notification_conf.scheduler_task_initial_delay}} + {{device_mgt_conf.push_notification_conf.scheduler_task_enabled}} + {% else %} + 1000 + 60000 + 60000 + true + {% endif %} + + org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider + {% if device_mgt_conf.push_notification_conf.push_notification_providers is defined %} + {%- for push_notification_provider in device_mgt_conf.push_notification_conf.push_notification_providers -%} + {{push_notification_provider}} + {% endfor %} + {% endif %} + + + + {% if device_mgt_conf.pull_notification_conf is defined %} + {{device_mgt_conf.pull_notification_conf.enabled}} + {% else %} + false + {% endif %} + + + {% if device_mgt_conf.identity_conf is defined %} + {{device_mgt_conf.identity_conf.server_url}} + {{device_mgt_conf.identity_conf.admin_username}} + {{device_mgt_conf.identity_conf.admin_password}} + {% else %} + https://localhost:9443 + admin + admin + {% endif %} + + + {% if device_mgt_conf.key_manager_conf is defined %} + {{device_mgt_conf.key_manager_conf.server_url}} + {{device_mgt_conf.key_manager_conf.admin_username}} + {{device_mgt_conf.key_manager_conf.admin_password}} + {% else %} + https://localhost:9443 + admin + admin + {% endif %} + + + {% if device_mgt_conf.policy_conf is defined %} + {{device_mgt_conf.policy_conf.monitoring_class}} + {{device_mgt_conf.policy_conf.monitoring_enable}} + {{device_mgt_conf.policy_conf.monitoring_frequency}} + {{device_mgt_conf.policy_conf.max_retries}} + {{device_mgt_conf.policy_conf.min_retries_to_mark_unreachable}} + {{device_mgt_conf.policy_conf.min_retries-to_mark_inactive}} + + + + {{device_mgt_conf.policy_conf.policy.evaluation_point}} + {{device_mgt_conf.policy_conf.cache_enable}} + {% else %} + org.wso2.carbon.policy.mgt + true + 60000 + 5 + 8 + 20 + + + + Simple + true + {% endif %} + + + + {% if device_mgt_conf.pagination_conf is defined %} + {{device_mgt_conf.pagination_conf.device_list_page_size}} + {{device_mgt_conf.pagination_conf.group_list_page_size}} + {{device_mgt_conf.pagination_conf.notification_list_page_size}} + {{device_mgt_conf.pagination_conf.activity_list_page_size}} + {{device_mgt_conf.pagination_conf.operation_list_page_size}} + {{device_mgt_conf.pagination_conf.topic_list_page_size}} + {{device_mgt_conf.pagination_conf.metadata_list_page_size}} + {% else %} + 20 + 20 + 20 + 20 + 20 + 20 + 20 + {% endif %} + + + + {% if device_mgt_conf.device_status_task_config is defined %} + {{device_mgt_conf.device_status_task_config.enable}} + {% else %} + true + {% endif %} + + + + {% if device_mgt_conf.device_cache_conf is defined %} + {{device_mgt_conf.device_cache_conf.enable}} + {{device_mgt_conf.device_cache_conf.expiry_time}} + + {{device_mgt_conf.device_cache_conf.capacity}} + {% else %} + true + 600 + + 10000 + {% endif %} + + + {% if device_mgt_conf.geo_fence_cache_conf is defined %} + {{device_mgt_conf.geo_fence_cache_conf.enable}} + {{device_mgt_conf.geo_fence_cache_conf.expiry_time}} + {{device_mgt_conf.geo_fence_cache_conf.capacity}} + {% else %} + true + 600 + 10000 + {% endif %} + + + {% if device_mgt_conf.event_operation_task_conf is defined %} + {{device_mgt_conf.event_operation_task_conf.enable}} + {% else %} + true + {% endif %} + + + {% if device_mgt_conf.certificate_cache_conf is defined %} + {{device_mgt_conf.certificate_cache_conf.enable}} + {{device_mgt_conf.certificate_cache_conf.expiry_time}} + {% else %} + true + 86400 + {% endif %} + + + + + jdbc/DM_ARCHIVAL_DS + + + + {% if device_mgt_conf.archival_conf.archival_task is defined %} + {{device_mgt_conf.archival_conf.archival_task.enabled}} + {{device_mgt_conf.archival_conf.archival_task.archival_pending_operations}} + + DM_DB + ARCHIVAL_DB + + {{device_mgt_conf.archival_conf.archival_task.task_class}} + + {{device_mgt_conf.archival_conf.archival_task.cron_expression}} + + {{device_mgt_conf.archival_conf.archival_task.retention_period}} + {{device_mgt_conf.archival_conf.archival_task.execution_batch_size}} + + {{device_mgt_conf.archival_conf.archival_task.purging_task.enabled}} + {{device_mgt_conf.archival_conf.archival_task.purging_task.task_class}} + + {{device_mgt_conf.archival_conf.archival_task.purging_task.cron_expression}} + + {{device_mgt_conf.archival_conf.archival_task.purging_task.retention_period}} + + {% else %} + false + false + + DM_DB + ARCHIVAL_DB + + org.wso2.carbon.device.mgt.core.task.impl.ArchivalTask + + 0 0 0 1/1 * ? * + + 30 + 1000 + + false + org.wso2.carbon.device.mgt.core.task.impl.ArchivedDataDeletionTask + + 0 0 3 1/1 * ? * + + 365 + + {% endif %} + + + + {% if device_mgt_conf.geo_location_conf is defined %} + {{device_mgt_conf.geo_location_conf.enabled}} + {% else %} + false + {% endif %} + + + false + false + + false + + + + + * + + + + + + {% if device_mgt_conf.remote_session_conf is defined %} + {{device_mgt_conf.remote_session_conf.enabled}} + {{device_mgt_conf.remote_session_conf.remote_session_server_url}} + {{device_mgt_conf.remote_session_conf.max_http_connection_per_host}} + {{device_mgt_conf.remote_session_conf.max_total_http_connections}} + {{device_mgt_conf.remote_session_conf.max_messages_per_second}} + {{device_mgt_conf.remote_session_conf.session_idle_timeout}} + {{device_mgt_conf.remote_session_conf.max_message_buffer.size}} + {% else %} + true + ws://localhost:9763 + 2 + 100 + 20 + 15 + 640 + {% endif %} + + {% if device_mgt_conf.default_groups_conf is defined %} + {{device_mgt_conf.default_groups_conf}} + {% else %} + BYOD,COPE + {% endif %} + + {% if device_mgt_conf.enrolement_notification_conf is defined %} + {{device_mgt_conf.enrolement_notification_conf.enabled}} + {{device_mgt_conf.enrolement_notification_conf.notify_through_extension}} + {{device_mgt_conf.enrolement_notification_conf.extension_class}} + {{device_mgt_conf.enrolement_notification_conf.notify_internal_host}} + {% else %} + false + false + org.wso2.carbon.device.mgt.common.enrollment.notification.EnrollmentNotifier + http://localhost:8280 + {% endif %} + + + {% if device_mgt_conf.default_roles is defined %} + {{device_mgt_conf.default_roles.enabled}} + {% else %} + false + {% endif %} + + + test_role + + /permission/admin/Login + + + + + + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2 new file mode 100755 index 0000000000..e9105a8d3e --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2 @@ -0,0 +1,87 @@ + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + DM_DS + The datasource used for CDM + + jdbc/DM_DS + + + + {% if database.device_mgt is defined %} + {{database.device_mgt.url}} + {{database.device_mgt.username}} + {{database.device_mgt.password}} + {{database.device_mgt.driver}} + {{database.device_mgt.validationQuery}} + {% for property_name,property_value in database.device_mgt.pool_options.items() %} + <{{property_name}}>{{property_value}} + {% endfor %} + {% else %} + jdbc:h2:./repository/database/WSO2DM_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000 + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + {% endif %} + + + + + DM_ARCHIVAL_DS + The archival datasource used for CDM + + jdbc/DM_ARCHIVAL_DS + + + + {% if database.device_mgt_archival is defined %} + {{database.device_mgt_archival.url}} + {{database.device_mgt_archival.username}} + {{database.device_mgt_archival.password}} + {{database.device_mgt_archival.driver}} + {{database.device_mgt_archival.validationQuery}} + {% for property_name,property_value in database.device_mgt_archival.pool_options.items() %} + <{{property_name}}>{{property_value}} + {% endfor %} + {% else %} + jdbc:h2:./repository/database/WSO2DM_ARCHIVAL_DS;DB_CLOSE_ON_EXIT=FALSE + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + {% endif %} + + + + + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/license-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/license-config.xml.j2 new file mode 100644 index 0000000000..ab2e462b42 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/license-config.xml.j2 @@ -0,0 +1,63 @@ + + + + + + + wso2 + android + 1.0.0 + 1.0.0 + 01-01-2014 + 31-12-2035 + + + + wso2 + ios + 1.0.0 + 1.0.0 + 01-01-2014 + 31-12-2035 + + + + wso2 + windows + 1.0.0 + 1.0.0 + 01-01-2014 + 31-12-2035 + + + {% if license_conf.licenses is defined %} + {%- for license in license_conf.licenses -%} + + {{license.provider}} + {{license.name}} + {{license.version}} + {{license.language}} + {{license.valid_from}} + {{license.valid-to}} + {{license.text}} + + {% endfor %} + {% endif %} + + \ No newline at end of file diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 new file mode 100644 index 0000000000..64ccc89949 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 @@ -0,0 +1,211 @@ + + + + + {% if mdm_ui_conf.enable_oauth is defined %} + {{mdm_ui_conf.enable_oauth}} + {% else %} + true + {% endif %} + {% if mdm_ui_conf.enable_sso is defined %} + {{mdm_ui_conf.enable_sso}} + {% else %} + false + {% endif %} + + + application_management + device_management + subscription_management + review_management + {% if mdm_ui_conf.app_registration.tags is defined %} + {%- for tag in mdm_ui_conf.app_registration.tags -%} + {{tag}} + {% endfor %} + {% endif %} + + {% if mdm_ui_conf.app_registration.allow_to_all_domains is defined %} + {{mdm_ui_conf.app_registration.allow_to_all_domains}} + {% else %} + true + {% endif %} + + + perm:app:review:view + perm:app:review:update + perm:app:publisher:view + perm:app:publisher:update + perm:app:store:view + perm:app:subscription:install + perm:app:subscription:uninstall + perm:admin:app:review:update + perm:admin:app:review:view + perm:admin:app:publisher:update + perm:admin:app:review:update + perm:admin:app:subscription:view + perm:device-types:types + perm:enterprise:modify + perm:enterprise:view + perm:android-work:customer + perm:android-work:admin + perm:application-command:modify + perm:sign-csr + perm:admin:devices:view + perm:admin:topics:view + perm:roles:add + perm:roles:add-users + perm:roles:update + perm:roles:permissions + perm:roles:details + perm:roles:view + perm:roles:create-combined-role + perm:roles:delete + perm:dashboard:vulnerabilities + perm:dashboard:non-compliant-count + perm:dashboard:non-compliant + perm:dashboard:by-groups + perm:dashboard:device-counts + perm:dashboard:feature-non-compliant + perm:dashboard:count-overview + perm:dashboard:filtered-count + perm:dashboard:details + perm:get-activity + perm:devices:delete + perm:devices:applications + perm:devices:effective-policy + perm:devices:compliance-data + perm:devices:features + perm:devices:operations + perm:devices:search + perm:devices:details + perm:devices:update + perm:devices:view + perm:view-configuration + perm:manage-configuration + perm:policies:remove + perm:policies:priorities + perm:policies:deactivate + perm:policies:get-policy-details + perm:policies:manage + perm:policies:activate + perm:policies:update + perm:policies:changes + perm:policies:get-details + perm:users:add + perm:users:details + perm:users:count + perm:users:delete + perm:users:roles + perm:users:user-details + perm:users:credentials + perm:users:search + perm:users:is-exist + perm:users:update + perm:users:send-invitation + perm:admin-users:view + perm:admin:devices:update-enrollment + perm:groups:devices + perm:groups:update + perm:groups:add + perm:groups:device + perm:groups:devices-count + perm:groups:remove + perm:groups:groups + perm:groups:groups-view + perm:groups:share + perm:groups:count + perm:groups:roles + perm:groups:devices-remove + perm:groups:devices-add + perm:groups:assign + perm:device-types:configs + perm:device-types:features + perm:device-types:types + perm:applications:install + perm:applications:uninstall + perm:admin-groups:count + perm:admin-groups:view + perm:admin-groups:add + perm:notifications:mark-checked + perm:notifications:view + perm:admin:certificates:delete + perm:admin:certificates:details + perm:admin:certificates:view + perm:admin:certificates:add + perm:admin:certificates:verify + perm:admin + perm:devicetype:deployment + perm:device-types:events + perm:device-types:events:view + perm:admin:device-type + perm:admin:device-type:view + perm:admin:device-type:configs + perm:device:enroll + perm:geo-service:analytics-view + perm:geo-service:alerts-manage + appm:read + perm:devices:permanent-delete + perm:android:manage-configuration + perm:android:view-configuration + perm:user:permission-view + perm:ios:view-configuration + perm:ios:manage-configuration + perm:ios:dep-view + perm:ios:dep-add + perm:windows:view-configuration + perm:windows:manage-configuration + perm:android:lock-devices + perm:android:unlock-devices + perm:android:location + perm:android:clear-password + perm:android:control-camera + perm:android:enterprise-wipe + perm:android:wipe + perm:android:ring + perm:android:applications + perm:android:reboot + perm:android:change-LockTask + perm:android:mute + perm:android:configure-display-message + perm:android:send-app-restrictions + perm:android:file-transfer + perm:android:set-webclip + perm:android:set-password-policy + perm:android:change-lock-code + perm:android:upgrade-firmware + perm:android:send-notification + perm:geo-service:geo-fence + perm:metadata:view + perm:metadata:create + perm:metadata:update + {% if mdm_ui_conf.scopes is defined %} + {%- for scope in mdm_ui_conf.scopes -%} + {{scope}} + {% endfor %} + {% endif %} + + + {% if mdm_ui_conf.sso_conf is defined %} + {{mdm_ui_conf.sso_conf.issuer}} + {% else %} + device-mgt + {% endif %} + + + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/remote-appmanager-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/remote-appmanager-config.xml.j2 new file mode 100644 index 0000000000..5f752a4983 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/remote-appmanager-config.xml.j2 @@ -0,0 +1,32 @@ + + + + + {% if app_management_conf is defined %} + {{app_management_conf.enable}} + {{app_management_conf.app_manager_url}} + {{app_management_conf.consumer_key}} + {{app_management_conf.consumer_secret}} + {% else %} + true + http:/www.google.com + http:/www.google.com + http:/www.google.com + {% endif %} + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf index d373520aa0..5ebad17202 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/p2.inf @@ -8,5 +8,4 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/email-templates);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/apis/admin--OAuth2TokenManagement.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--OAuth2TokenManagement.xml,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/apis/admin--UserManagementValidateUser.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--UserManagementValidateUser.xml,overwrite:true);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/heart-beat-datasources.xml.j2 b/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/heart-beat-datasources.xml.j2 new file mode 100644 index 0000000000..524f28c42a --- /dev/null +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/heart-beat-datasources.xml.j2 @@ -0,0 +1,57 @@ + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + HeartBeat_DS + The datasource Server Heart Beat + + jdbc/HeartBeat_DS + + + + {% if database.heart_beat is defined %} + {{database.heart_beat.url}} + {{database.heart_beat.username}} + {{database.heart_beat.password}} + {{database.heart_beat.driver}} + {{database.heart_beat.validationQuery}} + {% for property_name,property_value in database.heart_beat.pool_options.items() %} + <{{property_name}}>{{property_value}} + {% endfor %} + {% else %} + jdbc:mysql://localhost:3306/heart_beat + root + root + com.mysql.jdbc.Driver + 50 + 60000 + true + SELECT 1 + 30000 + {% endif %} + + + + + + diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/heart-beat-config.xml.j2 b/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/heart-beat-config.xml.j2 new file mode 100644 index 0000000000..8d2776fc38 --- /dev/null +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/conf_templates/templates/repository/conf/heart-beat-config.xml.j2 @@ -0,0 +1,61 @@ + + + + + + + + + jdbc/HeartBeat_DS + + + {% if heart_beat_beacon_conf is defined %} + {{heart_beat_beacon_conf.enable}} + {{heart_beat_beacon_conf.notifier_initial_delay_in_seconds}} + {{heart_beat_beacon_conf.notifier_frequency_in_seconds}} + {{heart_beat_beacon_conf.time_skew_in_seconds}} + {{heart_beat_beacon_conf.sever_timeout_interval_in_seconds}} + {% else %} + false + 30 + 300 + 5 + 600 + {% endif %} + diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/p2.inf b/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/p2.inf index 6add373677..55584ad49a 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/p2.inf +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/src/main/resources/p2.inf @@ -2,6 +2,7 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/conf/heart-beat-config.xml,target:${installFolder}/../../conf/heart-beat-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/dbscripts/heart-beat/,target:${installFolder}/../../../dbscripts/heart-beat,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ instructions.unconfigure = \ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/heart-beat-datasources.xml);\ diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/conf_templates/templates/repository/conf/email-sender-config.xml.j2 b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/conf_templates/templates/repository/conf/email-sender-config.xml.j2 new file mode 100644 index 0000000000..f59e8fbf53 --- /dev/null +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/conf_templates/templates/repository/conf/email-sender-config.xml.j2 @@ -0,0 +1,38 @@ + + + + {% if email_sender_conf is defined %} + {{email_sender_conf.min_threads}} + + {{email_sender_conf.max_threads}} + + {{email_sender_conf.keep_alive_duration}} + + {{email_sender_conf.thread_queue_capacity}} + {% else %} + 8 + + 100 + + 20 + + 1000 + {% endif %} + + diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/p2.inf b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/p2.inf index d4dadf6a1e..03d6cc09f9 100644 --- a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/p2.inf +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/p2.inf @@ -1,3 +1,4 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.email.sender_${feature.version}/conf/email-sender-config.xml,target:${installFolder}/../../conf/etc/email-sender-config.xml,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.email.sender_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.email.sender_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.email.sender_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 new file mode 100644 index 0000000000..7f8cd7359b --- /dev/null +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 @@ -0,0 +1,48 @@ + + + + + + + + + + + sample + +94 + 160 + + + {% if sms_conf.gateways is defined %} + {%- for gateway in sms_conf.gateways -%} + + + sample + +94 + 160 + {% for property_name,property_value in gateway.properties_options.items() %} + {{property_value}} + {% endfor %} + + + {% endfor %} + {% endif %} + + diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/p2.inf b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/p2.inf index af486db59b..958e75d3ab 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/p2.inf +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/p2.inf @@ -1,4 +1,5 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.transport.mgt.sms.handler.server_${feature.version}/conf/sms-config.xml,target:${installFolder}/../../conf/sms-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.transport.mgt.sms.handler.server_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ instructions.unconfigure = \ From 0162753d6aa3f71d4d503ef300d81788cf03f562 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Wed, 19 May 2021 11:16:22 +0530 Subject: [PATCH 39/49] Fixed SSO --- .../APIManagementProviderServiceImpl.java | 1 + .../ui/request/interceptor/LoginHandler.java | 72 +++++++------------ .../interceptor/SsoLoginCallbackHandler.java | 5 +- .../request/interceptor/SsoLoginHandler.java | 10 ++- .../interceptor/util/HandlerConstants.java | 4 +- .../src/main/resources/conf/mdm-ui-config.xml | 2 +- .../repository/conf/mdm-ui-config.xml.j2 | 2 +- .../src/main/resources/p2.inf | 1 + .../resources/payloads/get-app-request.xml | 8 +++ .../resources/payloads/update-app-request.xml | 55 ++++++++++++++ 10 files changed, 107 insertions(+), 53 deletions(-) create mode 100644 features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/get-app-request.xml create mode 100644 features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index 40d13f7eda..99dde8d4b3 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -123,6 +123,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application = new Application(applicationName, subscriber); application.setTier(ApiApplicationConstants.DEFAULT_TIER); application.setGroupId(""); + application.setTokenType("OAUTH"); apiConsumer.addApplication(application, username); application = apiConsumer.getApplicationsByName(username, applicationName, ""); } else { diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index 8843f507cc..ed106923b5 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -24,7 +24,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import io.entgra.ui.request.interceptor.beans.AuthData; -import io.entgra.ui.request.interceptor.beans.ProxyResponse; import io.entgra.ui.request.interceptor.exceptions.LoginException; import io.entgra.ui.request.interceptor.util.HandlerConstants; import io.entgra.ui.request.interceptor.util.HandlerUtil; @@ -35,12 +34,8 @@ import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; -import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; -import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; -import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; -import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; -import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; -import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.apache.http.protocol.HTTP; +import io.entgra.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -49,9 +44,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; -import java.util.ArrayList; import java.util.Base64; -import java.util.List; @MultipartConfig @WebServlet("/login") @@ -76,38 +69,28 @@ public class LoginHandler extends HttpServlet { httpSession = req.getSession(true); //setting session to expiry in 5 minutes httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT)); - //todo: amalka do we need this remote call? + JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession( uiConfigUrl, gatewayUrl, httpSession, resp); JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); - List list = new ArrayList(); - for(int i=0; i < tags.size(); i++) { - list.add(tags.get(i).getAsString()); + HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); + apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() + .encodeToString((username + HandlerConstants.COLON + password).getBytes())); + apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); + apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload( + tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, username, password)); + + ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); + + if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { + HandlerUtil.handleError(resp, clientAppResponse); + return; } - - String[] tagsAsStringArray = list.toArray(new String[list.size()]); - - String scopeString = HandlerUtil.getScopeString(scopes); - - if (scopeString != null) { - scopeString = scopeString.trim(); - } else { - scopeString = "default"; - } - - APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); - ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( - HandlerConstants.PUBLISHER_APPLICATION_NAME, - tagsAsStringArray, HandlerConstants.PRODUCTION_KEY, username, false, - ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD); - - if (apiApplicationKey != null && getTokenAndPersistInSession(apiApplicationKey.getConsumerKey(), - apiApplicationKey.getConsumerSecret(), req, resp, scopes)) { - log.info("tenantDomain : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - log.info("username : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); + if (clientAppResponse.getCode() == HttpStatus.SC_CREATED && getTokenAndPersistInSession(req, resp, + clientAppResponse.getData(), scopes)) { ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); HandlerUtil.handleSuccess(resp, proxyResponse); @@ -120,8 +103,6 @@ public class LoginHandler extends HttpServlet { log.error("Error occurred while parsing the response. ", e); } catch (LoginException e) { log.error("Error occurred while getting token data. ", e); - } catch (APIManagerException e) { - log.error("Error occurred while creating application. ", e); } } @@ -129,15 +110,19 @@ public class LoginHandler extends HttpServlet { * Generates token from token endpoint and persists them inside the session * * @param req - {@link HttpServletRequest} -// * @param clientAppResult - clientAppResult + * @param clientAppResult - clientAppResult * @param scopes - scopes defied in the application-mgt.xml * @throws LoginException - login exception throws when getting token result */ - private boolean getTokenAndPersistInSession(String clientId, String clientSecret, HttpServletRequest req, - HttpServletResponse resp, JsonArray scopes) throws LoginException { + private boolean getTokenAndPersistInSession(HttpServletRequest req, HttpServletResponse resp, + String clientAppResult, JsonArray scopes) throws LoginException { JsonParser jsonParser = new JsonParser(); try { - if (clientId != null && clientSecret != null) { + JsonElement jClientAppResult = jsonParser.parse(clientAppResult); + if (jClientAppResult.isJsonObject()) { + JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); + String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); + String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); String encodedClientApp = Base64.getEncoder() .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); @@ -189,9 +174,6 @@ public class LoginHandler extends HttpServlet { if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { iotsCorePort = System.getProperty("iot.core.http.port"); } - - String keyManagerPort = System.getProperty("iot.keymanager.https.port"); - username = req.getParameter("username"); password = req.getParameter("password"); gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") @@ -199,8 +181,8 @@ public class LoginHandler extends HttpServlet { uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + HandlerConstants.COLON + iotsCorePort + HandlerConstants.UI_CONFIG_ENDPOINT; keyManagerUrl = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + - System.getProperty("iot.keymanager.host") + HandlerConstants.COLON + keyManagerPort; - + System.getProperty("iot.keymanager.host") + HandlerConstants.COLON + + System.getProperty("iot.keymanager.https.port"); if (username == null || password == null) { String msg = "Invalid login request. Username or Password is not received for login request."; log.error(msg); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java index 8ee6ec776b..e047b5ba73 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -60,8 +60,11 @@ public class SsoLoginCallbackHandler extends HttpServlet { + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + HandlerConstants.COLON + iotsCorePort; + String keyManagerUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty("iot.keymanager.host") + HandlerConstants.COLON + + System.getProperty("iot.keymanager.https.port"); - HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); + HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index 1ade046d43..78b874ac68 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -69,6 +69,7 @@ public class SsoLoginHandler extends HttpServlet { private static String adminPassword; private static String gatewayUrl; private static String iotsCoreUrl; + private static String keyManagerUrl; private static String encodedAdminCredentials; private static String encodedClientApp; private static String applicationId; @@ -101,7 +102,7 @@ public class SsoLoginHandler extends HttpServlet { */ private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { try { - File userMgtConf = new File("conf/user-mgt.xml"); + File userMgtConf = new File("repository/conf/user-mgt.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(userMgtConf); @@ -123,6 +124,9 @@ public class SsoLoginHandler extends HttpServlet { iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") + HandlerConstants.COLON + iotsCorePort; String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; + keyManagerUrl = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty("iot.keymanager.host") + HandlerConstants.COLON + + System.getProperty("iot.keymanager.https.port"); httpSession = req.getSession(false); if (httpSession != null) { @@ -211,7 +215,7 @@ public class SsoLoginHandler extends HttpServlet { ProxyResponse updateApplicationGrantTypesEndpointResponse = HandlerUtil.execute(updateApplicationGrantTypesEndpoint); // Update app as a SaaS app - this.updateSaasApp(applicationName); + this.updateSaasApp(applicationId); if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { HandlerUtil.handleError(resp, updateApplicationGrantTypesEndpointResponse); @@ -262,7 +266,7 @@ public class SsoLoginHandler extends HttpServlet { * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ private ProxyResponse getTokenResult(String encodedClientApp) throws IOException { - HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); + HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index bedf62385c..636c5aceeb 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -25,7 +25,7 @@ public class HandlerConstants { public static final String TOKEN_ENDPOINT = "/oauth2/token"; public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect"; public static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize"; - public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/store/v0.12/applications/"; + public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/devportal/v2/applications/"; public static final String IDENTITY_APP_MGT_ENDPOINT = "/services/IdentityApplicationManagementService.IdentityApplicationManagementServiceHttpsSoap11Endpoint"; public static final String LOGIN_PAGE = "/login"; public static final String SSO_LOGIN_CALLBACK = "/ssoLoginCallback"; @@ -67,7 +67,7 @@ public class HandlerConstants { public static final String OTP_HEADER = "one-time-token"; - public static final String AX_PREFIX = "ax2317:"; + public static final String AX_PREFIX = "ax2251:"; public static final String PAYLOADS_DIR = "repository/resources/payloads"; public static final String SOAP_ACTION_HEADER = "SOAPAction"; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 5bbf9e040b..a0ba89e8b7 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -19,7 +19,7 @@ true - false + true application_management diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 index 64ccc89949..d15f23de86 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 @@ -26,7 +26,7 @@ {% if mdm_ui_conf.enable_sso is defined %} {{mdm_ui_conf.enable_sso}} {% else %} - false + true {% endif %} diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/p2.inf b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/p2.inf index 7887868228..d44e4112ef 100644 --- a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/p2.inf +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/p2.inf @@ -4,3 +4,4 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.ui.request.interceptor_${feature.version}/webapps/ui-request-handler.war,target:${installFolder}/../../deployment/server/webapps/store-ui-request-handler.war,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.ui.request.interceptor_${feature.version}/webapps/ui-request-handler.war,target:${installFolder}/../../deployment/server/webapps/entgra-ui-request-handler.war,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.ui.request.interceptor_${feature.version}/webapps/ui-request-handler.war,target:${installFolder}/../../deployment/server/webapps/mdm-reports-ui-request-handler.war,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.ui.request.interceptor_${feature.version}/payloads/,target:${installFolder}/../../resources/payloads/,overwrite:true);\ diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/get-app-request.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/get-app-request.xml new file mode 100644 index 0000000000..45c2042031 --- /dev/null +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/get-app-request.xml @@ -0,0 +1,8 @@ + + + + + ${applicationName} + + + diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml new file mode 100644 index 0000000000..4f608a9e55 --- /dev/null +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml @@ -0,0 +1,55 @@ + + + + + + + ${applicationId} + ${applicationName} + + ${description} + + + + ${inboundAuthKey} + ${inboundAuthType} + ${inboundConfigType} + + + + + + ${tenantDomain} + ${userName} + ${userStoreDomain} + + ${saasApp} + + + displayName + ${displayName} + + + + + + + From e5fb17aceb98ccc8b5b843db65484a61fd33e414 Mon Sep 17 00:00:00 2001 From: charithag Date: Wed, 19 May 2021 17:12:50 +0530 Subject: [PATCH 40/49] Add geo view API --- .../device/mgt/jaxrs/beans/GeoCluster.java | 84 ++++++++ .../service/api/GeoLocationBasedService.java | 124 +++++++++++- .../impl/GeoLocationBasedServiceImpl.java | 86 +++++++- .../impl/GeoLocationBasedServiceImplTest.java | 16 +- .../mgt/common/geo/service/GeoCluster.java | 66 ++++++ .../mgt/common/geo/service/GeoCoordinate.java | 39 ++++ .../mgt/common/geo/service/GeoQuery.java | 139 +++++++++++++ .../carbon/device/mgt/core/dao/DeviceDAO.java | 14 +- .../core/dao/impl/AbstractDeviceDAOImpl.java | 189 ++++++++++++++---- .../impl/device/SQLServerDeviceDAOImpl.java | 8 +- .../device/mgt/core/geo/GeoCluster.java | 65 ------ .../mgt/core/geo/geoHash/GeoCoordinate.java | 21 -- .../core/geo/geoHash/GeoHashGenerator.java | 32 ++- .../GeoHashLengthStrategy.java | 22 +- .../ZoomGeoHashLengthStrategy.java | 61 ++++-- .../GeoLocationProviderServiceImpl.java | 151 +++++++------- .../core/geo/task/EventCreateCallback.java | 1 + .../geo/task/EventOperationTaskException.java | 3 +- .../task/GeoFenceEventOperationManager.java | 8 +- .../DeviceManagementProviderService.java | 8 +- .../DeviceManagementProviderServiceImpl.java | 16 +- 21 files changed, 875 insertions(+), 278 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/GeoCluster.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCluster.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCoordinate.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoQuery.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/GeoCluster.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoCoordinate.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/GeoCluster.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/GeoCluster.java new file mode 100644 index 0000000000..4316e35b51 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/GeoCluster.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018-2021, 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 org.wso2.carbon.device.mgt.jaxrs.beans; + +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; + +public class GeoCluster { + private final GeoCoordinate coordinates; + private final GeoCoordinate southWestBound; + private final GeoCoordinate northEastBound; + private final long count; + private final String geohashPrefix; + private final String deviceIdentification; + private final String deviceName; + private final String deviceType; + private final String lastSeen; + + public GeoCluster(GeoCoordinate coordinates, GeoCoordinate southWestBound, GeoCoordinate northEastBound, + long count, String geohashPrefix, String deviceIdentification, String deviceName, + String deviceType, String lastSeen) { + this.coordinates = coordinates; + this.southWestBound = southWestBound; + this.northEastBound = northEastBound; + this.count = count; + this.geohashPrefix = geohashPrefix; + this.deviceIdentification = deviceIdentification; + this.deviceName = deviceName; + this.deviceType = deviceType; + this.lastSeen = lastSeen; + } + + public String getGeohashPrefix() { + return geohashPrefix; + } + + public long getCount() { + return count; + } + + public GeoCoordinate getCoordinates() { + return coordinates; + } + + public GeoCoordinate getSouthWestBound() { + return southWestBound; + } + + public GeoCoordinate getNorthEastBound() { + return northEastBound; + } + + public String getDeviceIdentification() { + return deviceIdentification; + } + + public String getDeviceName() { + return deviceName; + } + + public String getDeviceType() { + return deviceType; + } + + public String getLastSeen() { + return lastSeen; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java index 5e55acdc77..a2a6979803 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GeoLocationBasedService.java @@ -16,7 +16,6 @@ * under the License. */ - package org.wso2.carbon.device.mgt.jaxrs.service.api; import io.swagger.annotations.Api; @@ -32,6 +31,7 @@ import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.Tag; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.geo.service.Alert; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.GeofenceWrapper; @@ -41,7 +41,6 @@ import javax.validation.Valid; import javax.validation.constraints.Size; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; @@ -51,7 +50,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.util.ArrayList; +import java.util.List; @SwaggerDefinition( info = @Info( @@ -208,6 +207,7 @@ public interface GeoLocationBasedService { message = "Internal Server Error. \n Error on retrieving stats", response = Response.class) }) + @Deprecated Response getGeoDeviceLocations( @ApiParam( name = "deviceType", @@ -244,6 +244,124 @@ public interface GeoLocationBasedService { defaultValue ="2") @QueryParam("zoom") int zoom); + @Path("stats/geo-view") + @GET + @Consumes("application/json") + @Produces("application/json") + @ApiOperation( + consumes = "application/json", + produces = "application/json", + httpMethod = "GET", + value = "Getting geo view of devices", + notes = "Get the details of the devices that are within the map. The map area is enclosed with four " + + "coordinates in the shape of a square or rectangle. This is done by defining two points of the " + + "map. The other two points are automatically created using the given points. " + + "You can define the zoom level or scale of the map too.", + response = Response.class, + tags = "Geo Service Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "OK.", + response = Response.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid parameters found.", + response = Response.class), + @ApiResponse( + code = 401, + message = "Unauthorized. \n Unauthorized request."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error on retrieving stats", + response = Response.class) + }) + Response getGeoDeviceView( + @ApiParam( + name = "minLat", + value = "Define the minimum latitude of the geofence.", + required = true, + defaultValue ="79.85213577747345") + @QueryParam("minLat") double minLat, + @ApiParam( + name = "maxLat", + value = "Define the maximum latitude of the geofence.", + required = true, + defaultValue ="79.85266149044037") + @QueryParam("maxLat") double maxLat, + @ApiParam( + name = "minLong", + value = "Define the minimum longitude of the geofence.", + required = true, + defaultValue ="6.909673257977737") + @QueryParam("minLong") double minLong, + @ApiParam( + name = "maxLong", + value = "Define the maximum longitude of the geofence", + required = true, + defaultValue ="6.909673257977737") + @QueryParam("maxLong") double maxLong, + @ApiParam( + name = "zoom", + value = "Define the level to zoom or scale the map. You can define any value between 1 to 14.", + required = true, + defaultValue ="2") + @QueryParam("zoom") int zoom, + @ApiParam( + name = "deviceType", + value = "Optional Device type name.") + @QueryParam("deviceType") List deviceTypes, + @ApiParam( + name = "deviceIdentifier", + value = "Optional Device Identifier.") + @QueryParam("deviceIdentifier") List deviceIdentifiers, + @ApiParam( + name = "status", + value = "Optional Device status.") + @QueryParam("status") List statuses, + @ApiParam( + name = "ownership", + value = "Optional Device ownership.") + @QueryParam("ownership") List ownerships, + @ApiParam( + name = "owner", + value = "Optional Device owner.") + @QueryParam("owner") List owners, + @ApiParam( + name = "noClusters", + value = "Optional include devices only.") + @QueryParam("noClusters") boolean noClusters, + @ApiParam( + name = "createdBefore", + value = "Optional Device created before timestamp.") + @QueryParam("createdBefore") long createdBefore, + @ApiParam( + name = "createdAfter", + value = "Optional Device created after timestamp..") + @QueryParam("createdAfter") long createdAfter, + @ApiParam( + name = "updatedBefore", + value = "Optional Device updated before timestamp.") + @QueryParam("updatedBefore") long updatedBefore, + @ApiParam( + name = "updatedAfter", + value = "Optional Device updated after timestamp.") + @QueryParam("updatedAfter") long updatedAfter); /** * Create Geo alerts diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java index b2c28d8f1e..793b83c46c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImpl.java @@ -38,6 +38,7 @@ import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; @@ -47,13 +48,14 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.geo.service.Alert; import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException; import org.wso2.carbon.device.mgt.common.geo.service.Event; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; import org.wso2.carbon.device.mgt.common.geo.service.GeoFence; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; +import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery; import org.wso2.carbon.device.mgt.common.geo.service.GeofenceData; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; import org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy.GeoHashLengthStrategy; import org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy.ZoomGeoHashLengthStrategy; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; @@ -81,7 +83,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -91,7 +96,7 @@ import java.util.Map; */ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { - private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class); + private static final Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class); @Path("stats/{deviceType}/{deviceId}") @GET @@ -155,6 +160,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { @GET @Consumes("application/json") @Produces("application/json") + @Deprecated public Response getGeoDeviceLocations( @QueryParam("deviceType") String deviceType, @QueryParam("minLat") double minLat, @@ -162,6 +168,64 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { @QueryParam("minLong") double minLong, @QueryParam("maxLong") double maxLong, @QueryParam("zoom") int zoom) { + GeoHashLengthStrategy geoHashLengthStrategy = new ZoomGeoHashLengthStrategy(); + GeoCoordinate southWest = new GeoCoordinate(minLat, minLong); + GeoCoordinate northEast = new GeoCoordinate(maxLat, maxLong); + int geohashLength = geoHashLengthStrategy.getGeohashLength(southWest, northEast, zoom); + DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService(); + GeoQuery geoQuery = new GeoQuery(southWest, northEast, geohashLength); + if (deviceType != null) { + geoQuery.setDeviceTypes(Collections.singletonList(deviceType)); + } + List geoClusters = new ArrayList<>(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + try { + List newClusters = deviceManagementService.findGeoClusters(geoQuery); + org.wso2.carbon.device.mgt.jaxrs.beans.GeoCluster geoCluster; + String deviceIdentification = null; + String deviceName = null; + String lastSeen = null; + for (GeoCluster gc : newClusters) { + if (gc.getDevice() != null) { + deviceIdentification = gc.getDevice().getDeviceIdentifier(); + deviceName = gc.getDevice().getName(); + deviceType = gc.getDevice().getType(); + lastSeen = simpleDateFormat.format(new Date(gc.getDevice() + .getEnrolmentInfo().getDateOfLastUpdate())); + } + geoCluster = new org.wso2.carbon.device.mgt.jaxrs.beans.GeoCluster(gc.getCoordinates(), + gc.getSouthWestBound(), gc.getNorthEastBound(), gc.getCount(), gc.getGeohashPrefix(), + deviceIdentification, deviceName, deviceType, lastSeen); + geoClusters.add(geoCluster); + } + } catch (DeviceManagementException e) { + String msg = "Error occurred while retrieving geo clusters query: " + new Gson().toJson(geoQuery); + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); + } + return Response.ok().entity(geoClusters).build(); + } + + @Path("stats/geo-view") + @GET + @Consumes("application/json") + @Produces("application/json") + public Response getGeoDeviceView( + @QueryParam("minLat") double minLat, + @QueryParam("maxLat") double maxLat, + @QueryParam("minLong") double minLong, + @QueryParam("maxLong") double maxLong, + @QueryParam("zoom") int zoom, + @QueryParam("deviceType") List deviceTypes, + @QueryParam("deviceIdentifier") List deviceIdentifiers, + @QueryParam("status") List statuses, + @QueryParam("ownership") List ownerships, + @QueryParam("owner") List owners, + @QueryParam("noClusters") boolean noClusters, + @QueryParam("createdBefore") long createdBefore, + @QueryParam("createdAfter") long createdAfter, + @QueryParam("updatedBefore") long updatedBefore, + @QueryParam("updatedAfter") long updatedAfter) { GeoHashLengthStrategy geoHashLengthStrategy = new ZoomGeoHashLengthStrategy(); GeoCoordinate southWest = new GeoCoordinate(minLat, minLong); @@ -169,15 +233,25 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService { int geohashLength = geoHashLengthStrategy.getGeohashLength(southWest, northEast, zoom); DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService(); List geoClusters; + GeoQuery geoQuery = new GeoQuery(southWest, northEast, geohashLength); + geoQuery.setDeviceTypes(deviceTypes); + geoQuery.setDeviceIdentifiers(deviceIdentifiers); + geoQuery.setStatuses(statuses); + geoQuery.setOwners(owners); + geoQuery.setOwnerships(ownerships); + geoQuery.setNoClusters(noClusters); + geoQuery.setCreatedBefore(createdBefore); + geoQuery.setCreatedAfter(createdAfter); + geoQuery.setUpdatedBefore(updatedBefore); + geoQuery.setUpdatedAfter(updatedAfter); try { - geoClusters = deviceManagementService.findGeoClusters(deviceType, southWest, northEast, geohashLength); + geoClusters = deviceManagementService.findGeoClusters(geoQuery); } catch (DeviceManagementException e) { - String msg = "Error occurred while retrieving geo clusters "; + String msg = "Error occurred while retrieving geo clusters for query: " + new Gson().toJson(geoQuery); log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); } return Response.ok().entity(geoClusters).build(); - } @Path("alerts/{alertType}/{deviceType}/{deviceId}") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java index d19e835848..ebb965fc80 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java @@ -7,8 +7,9 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.service.api.GeoLocationBasedService; @@ -33,8 +34,9 @@ public class GeoLocationBasedServiceImplTest { @Test(description = "This method tests the behaviour of getGeoDeviceLocations when there are no devices" + "in the given map boundaries") public void testGetGeoDeviceLocations1() throws DeviceManagementException { + GeoQuery geoQuery = new GeoQuery(Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt()); Mockito.doReturn(new ArrayList()).when(deviceManagementProviderService) - .findGeoClusters(null, Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt()); + .findGeoClusters(geoQuery); Response response = geoLocationBasedService.getGeoDeviceLocations(null, 0.4, 15, 75.6, 90.1, 6); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), @@ -47,12 +49,14 @@ public class GeoLocationBasedServiceImplTest { List geoClusters = new ArrayList<>(); geoClusters.add(new GeoCluster(new GeoCoordinate(1.5, 80.7), new GeoCoordinate(1.1, 79.5), new GeoCoordinate(1.9, 82.1), 3, - "tb32", "aegtew234", "test1", "android", "1234")); + "tb32", null)); geoClusters.add(new GeoCluster(new GeoCoordinate(10.2, 86.1), new GeoCoordinate(9.8, 84.7), new GeoCoordinate(11.1, 88.1), 4, - "t1gd", "swerty12s", "t2test", "android", "1234")); + "t1gd", null)); + + GeoQuery geoQuery = new GeoQuery(Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt()); Mockito.doReturn(geoClusters).when(deviceManagementProviderService) - .findGeoClusters(null, Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt()); + .findGeoClusters(geoQuery); Response response = geoLocationBasedService.getGeoDeviceLocations(null, 0.4, 15, 75.6, 90.1, 6); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCluster.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCluster.java new file mode 100644 index 0000000000..d2bcdc8931 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCluster.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018-2021, 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 org.wso2.carbon.device.mgt.common.geo.service; + +import org.wso2.carbon.device.mgt.common.Device; + +public class GeoCluster { + + private final GeoCoordinate coordinates; + private final GeoCoordinate southWestBound; + private final GeoCoordinate northEastBound; + private final long count; + private final String geohashPrefix; + private final Device device; + + public GeoCluster(GeoCoordinate coordinates, GeoCoordinate southWestBound, GeoCoordinate northEastBound, + long count, String geohashPrefix, Device device) { + this.coordinates = coordinates; + this.southWestBound = southWestBound; + this.northEastBound = northEastBound; + this.count = count; + this.geohashPrefix = geohashPrefix; + this.device = device; + } + + public String getGeohashPrefix() { + return geohashPrefix; + } + + public long getCount() { + return count; + } + + public GeoCoordinate getCoordinates() { + return coordinates; + } + + public GeoCoordinate getSouthWestBound() { + return southWestBound; + } + + public GeoCoordinate getNorthEastBound() { + return northEastBound; + } + + public Device getDevice() { + return device; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCoordinate.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCoordinate.java new file mode 100644 index 0000000000..c83d18b1ac --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoCoordinate.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2021, 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 org.wso2.carbon.device.mgt.common.geo.service; + +public class GeoCoordinate { + + private final double latitude; + private final double longitude; + + public GeoCoordinate(double latitude, double longitude) { + this.latitude = latitude; + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public double getLongitude() { + return longitude; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoQuery.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoQuery.java new file mode 100644 index 0000000000..f50e5ae700 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/geo/service/GeoQuery.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2018-2021, 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 org.wso2.carbon.device.mgt.common.geo.service; + +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; + +import java.util.List; + +public class GeoQuery { + + private final GeoCoordinate southWest; + private final GeoCoordinate northEast; + private final int geohashLength; + private List deviceTypes; + private List deviceIdentifiers; + private List statuses; + private List ownerships; + private List owners; + private boolean noClusters; + private long createdBefore; + private long createdAfter; + private long updatedBefore; + private long updatedAfter; + + public GeoQuery(GeoCoordinate southWest, GeoCoordinate northEast, int geohashLength) { + this.southWest = southWest; + this.northEast = northEast; + this.geohashLength = geohashLength; + } + + public GeoCoordinate getSouthWest() { + return southWest; + } + + public GeoCoordinate getNorthEast() { + return northEast; + } + + public int getGeohashLength() { + return geohashLength; + } + + public List getDeviceTypes() { + return deviceTypes; + } + + public void setDeviceTypes(List deviceTypes) { + this.deviceTypes = deviceTypes; + } + + public List getDeviceIdentifiers() { + return deviceIdentifiers; + } + + public void setDeviceIdentifiers(List deviceIdentifiers) { + this.deviceIdentifiers = deviceIdentifiers; + } + + public List getStatuses() { + return statuses; + } + + public void setStatuses(List statuses) { + this.statuses = statuses; + } + + public List getOwnerships() { + return ownerships; + } + + public void setOwnerships(List ownerships) { + this.ownerships = ownerships; + } + + public List getOwners() { + return owners; + } + + public void setOwners(List owners) { + this.owners = owners; + } + + public boolean isNoClusters() { + return noClusters; + } + + public void setNoClusters(boolean noClusters) { + this.noClusters = noClusters; + } + + public long getCreatedBefore() { + return createdBefore; + } + + public void setCreatedBefore(long createdBefore) { + this.createdBefore = createdBefore; + } + + public long getCreatedAfter() { + return createdAfter; + } + + public void setCreatedAfter(long createdAfter) { + this.createdAfter = createdAfter; + } + + public long getUpdatedBefore() { + return updatedBefore; + } + + public void setUpdatedBefore(long updatedBefore) { + this.updatedBefore = updatedBefore; + } + + public long getUpdatedAfter() { + return updatedAfter; + } + + public void setUpdatedAfter(long updatedAfter) { + this.updatedAfter = updatedAfter; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 82aded2490..77b9d76c5c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -46,9 +46,10 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.DevicePropertyInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceData; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot; import org.wso2.carbon.device.mgt.common.device.details.DeviceMonitoringData; +import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery; import org.wso2.carbon.device.mgt.core.dto.DeviceType; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; import java.sql.SQLException; import java.util.Date; @@ -555,14 +556,11 @@ public interface DeviceDAO { * This method is used to retrieve the details of geoclusters formed relatively to the zoom level and map * boundaries. * - * @param deviceType Optional device type name. - * @param southWest the coordinates of southWest corner of the map. - * @param northEast the coordinates of northEast corner of the map. - * @param tenantId tenant id. + * @param geoQuery the query to determine the geo data. + * @param tenantId tenant id. * @return returns a list of enrolment info objects. */ - List findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast, - int geohashLength,int tenantId) throws DeviceManagementDAOException; + List findGeoClusters(GeoQuery geoQuery, int tenantId) throws DeviceManagementDAOException; /** * This method is used to identify whether given device ids are exist or not. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 749a31e0bb..bf387744e2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -48,13 +48,14 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.DevicePropertyInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceData; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot; import org.wso2.carbon.device.mgt.common.device.details.DeviceMonitoringData; +import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dto.DeviceType; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; import java.sql.Connection; import java.sql.PreparedStatement; @@ -64,6 +65,7 @@ import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; @@ -1850,62 +1852,161 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { return tenants; } - public List findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast, - int geohashLength, int tenantId) throws DeviceManagementDAOException { + public List findGeoClusters(GeoQuery geoQuery, int tenantId) throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; ResultSet rs = null; List geoClusters = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT AVG(DEVICE_LOCATION.LATITUDE) AS LATITUDE,AVG(DEVICE_LOCATION.LONGITUDE) AS LONGITUDE," + - " MIN(DEVICE_LOCATION.LATITUDE) AS MIN_LATITUDE, MAX(DEVICE_LOCATION.LATITUDE) AS MAX_LATITUDE," + - " MIN(DEVICE_LOCATION.LONGITUDE) AS MIN_LONGITUDE," + - " MAX(DEVICE_LOCATION.LONGITUDE) AS MAX_LONGITUDE," + - " SUBSTRING(DEVICE_LOCATION.GEO_HASH,1,?) AS GEOHASH_PREFIX, COUNT(*) AS COUNT," + - " MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION," + - " MIN(DEVICE.NAME) AS NAME," + - " MIN(DEVICE_TYPE.NAME) AS TYPE, " + - " MIN(DEVICE.LAST_UPDATED_TIMESTAMP) AS LAST_UPDATED_TIMESTAMP " + - "FROM DM_DEVICE_LOCATION AS DEVICE_LOCATION,DM_DEVICE AS DEVICE, DM_DEVICE_TYPE AS DEVICE_TYPE " + - "WHERE DEVICE_LOCATION.LATITUDE BETWEEN ? AND ? AND " + - "DEVICE_LOCATION.LONGITUDE BETWEEN ? AND ? AND " + - "DEVICE.TENANT_ID=? AND " + - "DEVICE.ID=DEVICE_LOCATION.DEVICE_ID AND DEVICE.DEVICE_TYPE_ID=DEVICE_TYPE.ID"; - if (deviceType != null && !deviceType.isEmpty()) { - sql += " AND DEVICE_TYPE.NAME=?"; + String sql = "SELECT AVG(DEVICE_LOCATION.LATITUDE) AS LATITUDE, " + + "AVG(DEVICE_LOCATION.LONGITUDE) AS LONGITUDE, " + + "MIN(DEVICE_LOCATION.LATITUDE) AS MIN_LATITUDE, " + + "MAX(DEVICE_LOCATION.LATITUDE) AS MAX_LATITUDE, " + + "MIN(DEVICE_LOCATION.LONGITUDE) AS MIN_LONGITUDE, " + + "MAX(DEVICE_LOCATION.LONGITUDE) AS MAX_LONGITUDE, " + + "SUBSTRING(DEVICE_LOCATION.GEO_HASH,1,?) AS GEOHASH_PREFIX, " + + "COUNT(DEVICE_LOCATION.ID) AS COUNT, " + + "MIN(DEVICE.ID) AS DEVICE_ID, " + + "MIN(DEVICE.NAME) AS DEVICE_NAME, " + + "MIN(DEVICE.DESCRIPTION) AS DESCRIPTION, " + + "MIN(DEVICE_TYPE.NAME) AS DEVICE_TYPE, " + + "MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION, " + + "MIN(ENROLMENT.ID) AS ENROLMENT_ID, " + + "MIN(ENROLMENT.OWNER) AS OWNER, " + + "MIN(ENROLMENT.OWNERSHIP) AS OWNERSHIP, " + + "MIN(ENROLMENT.IS_TRANSFERRED) AS IS_TRANSFERRED, " + + "MIN(ENROLMENT.DATE_OF_ENROLMENT) AS DATE_OF_ENROLMENT, " + + "MIN(ENROLMENT.DATE_OF_LAST_UPDATE) AS DATE_OF_LAST_UPDATE, " + + "MIN(ENROLMENT.STATUS) AS STATUS " + + "FROM DM_DEVICE_LOCATION AS DEVICE_LOCATION, DM_DEVICE AS DEVICE, " + + "DM_DEVICE_TYPE AS DEVICE_TYPE, DM_ENROLMENT AS ENROLMENT " + + "WHERE DEVICE_LOCATION.LATITUDE BETWEEN ? AND ? " + + "AND DEVICE_LOCATION.LONGITUDE BETWEEN ? AND ? "; + if (geoQuery.getDeviceTypes() != null && !geoQuery.getDeviceTypes().isEmpty()) { + sql += "AND DEVICE_TYPE.NAME IN ("; + sql += String.join(", ", + Collections.nCopies(geoQuery.getDeviceTypes().size(), "?")); + sql += ") "; } - sql += " GROUP BY GEOHASH_PREFIX"; + if (geoQuery.getDeviceIdentifiers() != null && !geoQuery.getDeviceIdentifiers().isEmpty()) { + sql += "AND DEVICE.DEVICE_IDENTIFICATION IN ("; + sql += String.join(", ", + Collections.nCopies(geoQuery.getDeviceIdentifiers().size(), "?")); + sql += ") "; + } + if (geoQuery.getOwners() != null && !geoQuery.getOwners().isEmpty()) { + sql += "AND ENROLMENT.OWNER IN ("; + sql += String.join(", ", + Collections.nCopies(geoQuery.getOwners().size(), "?")); + sql += ") "; + } + if (geoQuery.getOwnerships() != null && !geoQuery.getOwnerships().isEmpty()) { + sql += "AND ENROLMENT.OWNERSHIP IN ("; + sql += String.join(", ", + Collections.nCopies(geoQuery.getOwnerships().size(), "?")); + sql += ") "; + } + if (geoQuery.getStatuses() != null && !geoQuery.getStatuses().isEmpty()) { + sql += "AND ENROLMENT.STATUS IN ("; + sql += String.join(", ", + Collections.nCopies(geoQuery.getStatuses().size(), "?")); + sql += ") "; + } else { + sql += "AND ENROLMENT.STATUS != 'REMOVED' "; + } + if (geoQuery.getCreatedBefore() != 0 || geoQuery.getCreatedAfter() != 0) { + sql += "AND ENROLMENT.DATE_OF_ENROLMENT BETWEEN ? AND ? "; + } + if (geoQuery.getUpdatedBefore() != 0 || geoQuery.getUpdatedAfter() != 0) { + sql += "AND ENROLMENT.DATE_OF_LAST_UPDATE BETWEEN ? AND ? "; + } + sql += "AND DEVICE.ID = DEVICE_LOCATION.DEVICE_ID AND DEVICE.DEVICE_TYPE_ID = DEVICE_TYPE.ID " + + "AND DEVICE.ID = ENROLMENT.DEVICE_ID " + + "AND DEVICE.TENANT_ID = ? AND DEVICE.TENANT_ID = ENROLMENT.TENANT_ID GROUP BY GEOHASH_PREFIX"; stmt = conn.prepareStatement(sql); - stmt.setInt(1, geohashLength); - stmt.setDouble(2, southWest.getLatitude()); - stmt.setDouble(3, northEast.getLatitude()); - stmt.setDouble(4, southWest.getLongitude()); - stmt.setDouble(5, northEast.getLongitude()); - stmt.setDouble(6, tenantId); - if (deviceType != null && !deviceType.isEmpty()) { - stmt.setString(7, deviceType); + + int index = 1; + stmt.setInt(index++, geoQuery.getGeohashLength()); + stmt.setDouble(index++, geoQuery.getSouthWest().getLatitude()); + stmt.setDouble(index++, geoQuery.getNorthEast().getLatitude()); + stmt.setDouble(index++, geoQuery.getSouthWest().getLongitude()); + stmt.setDouble(index++, geoQuery.getNorthEast().getLongitude()); + if (geoQuery.getDeviceTypes() != null) { + for (String s: geoQuery.getDeviceTypes()) { + stmt.setString(index++, s); + } } + if (geoQuery.getDeviceIdentifiers() != null) { + for (String s: geoQuery.getDeviceIdentifiers()) { + stmt.setString(index++, s); + } + } + if (geoQuery.getOwners() != null) { + for (String s: geoQuery.getOwners()) { + stmt.setString(index++, s); + } + } + if (geoQuery.getOwnerships() != null) { + for (String s: geoQuery.getOwnerships()) { + stmt.setString(index++, s); + } + } + if (geoQuery.getStatuses() != null) { + for (Status s: geoQuery.getStatuses()) { + stmt.setString(index++, s.toString()); + } + } + + if (geoQuery.getCreatedBefore() != 0 || geoQuery.getCreatedAfter() != 0) { + stmt.setTimestamp(index++, new Timestamp(geoQuery.getCreatedAfter())); + if (geoQuery.getCreatedBefore() == 0) { + stmt.setTimestamp(index++, new Timestamp(System.currentTimeMillis())); + } else { + stmt.setTimestamp(index++, new Timestamp(geoQuery.getCreatedBefore())); + } + } + if (geoQuery.getUpdatedBefore() != 0 || geoQuery.getUpdatedAfter() != 0) { + stmt.setTimestamp(index++, new Timestamp(geoQuery.getUpdatedAfter())); + if (geoQuery.getUpdatedBefore() == 0) { + stmt.setTimestamp(index++, new Timestamp(System.currentTimeMillis())); + } else { + stmt.setTimestamp(index++, new Timestamp(geoQuery.getUpdatedBefore())); + } + } + stmt.setInt(index, tenantId); + rs = stmt.executeQuery(); + + double latitude; + double longitude; + double minLatitude; + double maxLatitude; + double minLongitude; + double maxLongitude; + long count; + String geohashPrefix; + Device device; while (rs.next()) { - double latitude = rs.getDouble("LATITUDE"); - double longitude = rs.getDouble("LONGITUDE"); - double min_latitude = rs.getDouble("MIN_LATITUDE"); - double max_latitude = rs.getDouble("MAX_LATITUDE"); - double min_longitude = rs.getDouble("MIN_LONGITUDE"); - double max_longitude = rs.getDouble("MAX_LONGITUDE"); - String device_identification = rs.getString("DEVICE_IDENTIFICATION"); - String device_name = rs.getString("NAME"); - String device_type = rs.getString("TYPE"); - String last_seen = rs.getString("LAST_UPDATED_TIMESTAMP"); - long count = rs.getLong("COUNT"); - String geohashPrefix = rs.getString("GEOHASH_PREFIX"); + latitude = rs.getDouble("LATITUDE"); + longitude = rs.getDouble("LONGITUDE"); + minLatitude = rs.getDouble("MIN_LATITUDE"); + maxLatitude = rs.getDouble("MAX_LATITUDE"); + minLongitude = rs.getDouble("MIN_LONGITUDE"); + maxLongitude = rs.getDouble("MAX_LONGITUDE"); + count = rs.getLong("COUNT"); + geohashPrefix = rs.getString("GEOHASH_PREFIX"); + if (count == 1) { + device = DeviceManagementDAOUtil.loadDevice(rs); + } else { + device = null; + } geoClusters.add(new GeoCluster(new GeoCoordinate(latitude, longitude), - new GeoCoordinate(min_latitude, min_longitude), new GeoCoordinate(max_latitude, max_longitude), - count, geohashPrefix, device_identification, device_name, device_type, last_seen)); + new GeoCoordinate(minLatitude, minLongitude), new GeoCoordinate(maxLatitude, maxLongitude), + count, geohashPrefix, device)); } } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving information of " + + throw new DeviceManagementDAOException("Error occurred while retrieving information of " + "Geo Clusters", e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 4e87d8ab61..8911beca49 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.core.dao.impl.device; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Count; @@ -29,8 +28,8 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; import org.wso2.carbon.device.mgt.core.report.mgt.Constants; import java.sql.Connection; @@ -1133,6 +1132,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { } } + //TODO: Override for MSSQL + /* @Override public List findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast, int geohashLength, int tenantId) throws DeviceManagementDAOException { @@ -1207,4 +1208,5 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { } return geoClusters; } + */ } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/GeoCluster.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/GeoCluster.java deleted file mode 100644 index e4838aaf6e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/GeoCluster.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.wso2.carbon.device.mgt.core.geo; - -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; - -public class GeoCluster { - private GeoCoordinate coordinates; - private GeoCoordinate southWestBound; - private GeoCoordinate northEastBound; - private long count; - private String geohashPrefix; - private String deviceIdentification; - private String deviceName; - private String deviceType; - private String lastSeen; - - - public GeoCluster(GeoCoordinate coordinates, GeoCoordinate southWestBound, GeoCoordinate northEastBound, long count, - String geohashPrefix, String deviceIdentification, String deviceName, String deviceType, String lastSeen){ - this.coordinates=coordinates; - this.southWestBound=southWestBound; - this.northEastBound=northEastBound; - this.count=count; - this.geohashPrefix=geohashPrefix; - this.deviceIdentification=deviceIdentification; - this.deviceName=deviceName; - this.deviceType=deviceType; - this.lastSeen = lastSeen; - - } - - public String getGeohashPrefix() { - return geohashPrefix; - } - - public long getCount() { - return count; - } - - public GeoCoordinate getCoordinates() { - return coordinates; - } - - public GeoCoordinate getSouthWestBound() { - return southWestBound; - } - - public GeoCoordinate getNorthEastBound() { - return northEastBound; - } - - public String getDeviceIdentification() { - return deviceIdentification; - } - - public String getDeviceName() { - return deviceName; - } - - public String getDeviceType() { return deviceType; - } - - public String getLastSeen() { - return lastSeen; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoCoordinate.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoCoordinate.java deleted file mode 100644 index 45ca28f0d4..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoCoordinate.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.wso2.carbon.device.mgt.core.geo.geoHash; - - - -public class GeoCoordinate { - private double latitude; - private double longitude; - - public GeoCoordinate(double latitude, double longitude){ - this.latitude=latitude; - this.longitude=longitude; - } - - public double getLatitude() { - return latitude; - } - - public double getLongitude() { - return longitude; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoHashGenerator.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoHashGenerator.java index 21d3ac85e9..557e4ebfe9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoHashGenerator.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/GeoHashGenerator.java @@ -1,15 +1,33 @@ +/* + * Copyright (c) 2018-2021, 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 org.wso2.carbon.device.mgt.core.geo.geoHash; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; - -import java.util.HashMap; -import java.util.Map; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; public class GeoHashGenerator { + private static final String BASE_32 = "0123456789bcdefghjkmnpqrstuvwxyz"; private static final int GEOHASH_LENGTH = 16; - private GeoHashGenerator(){}; + private GeoHashGenerator() { + } private static int divideRangeByValue(double value, double[] range) { double mid = middle(range); @@ -36,7 +54,6 @@ public class GeoHashGenerator { } public static String encodeGeohash(double latitude, double longitude) { - int geohashLength=GEOHASH_LENGTH; double[] latRange = new double[]{-90.0, 90.0}; double[] lonRange = new double[]{-180.0, 180.0}; boolean isEven = true; @@ -44,7 +61,7 @@ public class GeoHashGenerator { int base32CharIndex = 0; StringBuilder geohash = new StringBuilder(); - while (geohash.length() < geohashLength) { + while (geohash.length() < GEOHASH_LENGTH) { if (isEven) { base32CharIndex = (base32CharIndex << 1) | divideRangeByValue(longitude, lonRange); } else { @@ -85,8 +102,7 @@ public class GeoHashGenerator { isEvenBit = !isEvenBit; } } - GeoCoordinate coordinates = new GeoCoordinate(middle(latRange),middle(lonRange)); - return coordinates; + return new GeoCoordinate(middle(latRange), middle(lonRange)); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/GeoHashLengthStrategy.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/GeoHashLengthStrategy.java index f6845b305e..99032ee211 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/GeoHashLengthStrategy.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/GeoHashLengthStrategy.java @@ -1,11 +1,31 @@ +/* + * Copyright (c) 2018-2021, 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 org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; /** * This interface is to decide a length for the geohash prefix * which will be used to group the clusters based on geohash */ public interface GeoHashLengthStrategy { + int getGeohashLength(GeoCoordinate southWest, GeoCoordinate northEast, int zoom); + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/ZoomGeoHashLengthStrategy.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/ZoomGeoHashLengthStrategy.java index 0dd0e762f9..1eddf90602 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/ZoomGeoHashLengthStrategy.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/geoHash/geoHashStrategy/ZoomGeoHashLengthStrategy.java @@ -1,11 +1,31 @@ +/* + * Copyright (c) 2018-2021, 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 org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; -/**A class that will decide the geoHashLength based on the zoom level and -* the boundaries of the map**/ +/** + * A class that will decide the geoHashLength based on the zoom level and + * the boundaries of the map + **/ -public class ZoomGeoHashLengthStrategy implements GeoHashLengthStrategy{ +public class ZoomGeoHashLengthStrategy implements GeoHashLengthStrategy { private int minGeohashLength = 1; private int maxGeohashLength = 16; @@ -19,35 +39,36 @@ public class ZoomGeoHashLengthStrategy implements GeoHashLengthStrategy{ return (int) Math.max(minGeohashLength, Math.min(a * Math.exp(b * zoom), maxGeohashLength)); } - public void setMinGeohashLength(int minGeohashLength) { - this.minGeohashLength = minGeohashLength; - } - - public void setMaxGeohashLength(int maxGeohashLength) { - this.maxGeohashLength = maxGeohashLength; - } - - public void setMinZoom(int minZoom) { - this.minZoom = minZoom; - } - - public void setMaxZoom(int maxZoom) { - this.maxZoom = maxZoom; - } - public int getMinGeohashLength() { return minGeohashLength; } + public void setMinGeohashLength(int minGeohashLength) { + this.minGeohashLength = minGeohashLength; + } + public int getMaxGeohashLength() { return maxGeohashLength; } + public void setMaxGeohashLength(int maxGeohashLength) { + this.maxGeohashLength = maxGeohashLength; + } + public int getMinZoom() { return minZoom; } + public void setMinZoom(int minZoom) { + this.minZoom = minZoom; + } + public int getMaxZoom() { return maxZoom; } + + public void setMaxZoom(int maxZoom) { + this.maxZoom = maxZoom; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java index 9c77c75588..fad3138d44 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java @@ -44,11 +44,11 @@ import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationExceptio import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationProviderService; import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; import org.wso2.carbon.device.mgt.common.geo.service.Alert; +import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException; import org.wso2.carbon.device.mgt.common.geo.service.GeoFence; import org.wso2.carbon.device.mgt.common.geo.service.GeoFenceEventMeta; -import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException; -import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException; +import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.geo.service.GeofenceData; import org.wso2.carbon.device.mgt.core.cache.impl.GeoCacheManagerImpl; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; @@ -85,11 +85,11 @@ import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Collections; import java.util.Set; import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices.DAS_PORT; @@ -101,7 +101,7 @@ import static org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoSer */ public class GeoLocationProviderServiceImpl implements GeoLocationProviderService { - private static Log log = LogFactory.getLog(GeoLocationProviderServiceImpl.class); + private static final Log log = LogFactory.getLog(GeoLocationProviderServiceImpl.class); /** * required soap header for authorization @@ -136,6 +136,18 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic this.geofenceDAO = DeviceManagementDAOFactory.getGeofenceDAO(); } + public static JWTClientManagerService getJWTClientManagerService() { + JWTClientManagerService jwtClientManagerService; + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + jwtClientManagerService = (JWTClientManagerService) ctx.getOSGiService(JWTClientManagerService.class, null); + if (jwtClientManagerService == null) { + String msg = "jwtClientManagerServicehas not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return jwtClientManagerService; + } + @Override public List getWithinAlerts(DeviceIdentifier identifier, String owner) throws GeoLocationBasedServiceException { @@ -227,7 +239,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic return fences; } catch (RegistryException | IOException e) { throw new GeoLocationBasedServiceException( - "Error occurred while getting the geo alerts" , e); + "Error occurred while getting the geo alerts", e); } } @@ -334,7 +346,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic @Override public boolean createGeoAlert(Alert alert, String alertType) - throws GeoLocationBasedServiceException,AlertAlreadyExistException { + throws GeoLocationBasedServiceException, AlertAlreadyExistException { return saveGeoAlert(alert, alertType, false); } @@ -346,12 +358,12 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic @Override public boolean updateGeoAlert(Alert alert, String alertType) - throws GeoLocationBasedServiceException,AlertAlreadyExistException { + throws GeoLocationBasedServiceException, AlertAlreadyExistException { return saveGeoAlert(alert, alertType, true); } private boolean saveGeoAlert(Alert alert, String alertType, boolean isUpdate) - throws GeoLocationBasedServiceException,AlertAlreadyExistException { + throws GeoLocationBasedServiceException, AlertAlreadyExistException { Type type = new TypeToken>() { }.getType(); @@ -408,7 +420,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic if (validationResponse.equals("success")) { allActiveExecutionPlanConfigs = eventprocessorStub.getAllActiveExecutionPlanConfigurations(); if (isUpdate) { - for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) { + for (ExecutionPlanConfigurationDto activeExectionPlanConfig : allActiveExecutionPlanConfigs) { activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan(); if (activeExecutionPlan.contains(executionPlanName)) { eventprocessorStub.editActiveExecutionPlan(parsedTemplate, executionPlanName); @@ -417,14 +429,14 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } eventprocessorStub.deployExecutionPlan(parsedTemplate); } else { - for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) { + for (ExecutionPlanConfigurationDto activeExectionPlanConfig : allActiveExecutionPlanConfigs) { activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan(); if (activeExecutionPlan.contains(executionPlanName)) { throw new AlertAlreadyExistException("Execution plan already exists with name " + executionPlanName); } } - updateRegistry(getRegistryPath(alertType, alert.getQueryName()),content,options); + updateRegistry(getRegistryPath(alertType, alert.getQueryName()), content, options); eventprocessorStub.deployExecutionPlan(parsedTemplate); } } else { @@ -519,7 +531,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic if (validationResponse.equals("success")) { allActiveExecutionPlanConfigs = eventprocessorStub.getAllActiveExecutionPlanConfigurations(); if (isUpdate) { - for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) { + for (ExecutionPlanConfigurationDto activeExectionPlanConfig : allActiveExecutionPlanConfigs) { activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan(); if (activeExecutionPlan.contains(executionPlanName)) { eventprocessorStub.editActiveExecutionPlan(parsedTemplate, executionPlanName); @@ -528,7 +540,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } eventprocessorStub.deployExecutionPlan(parsedTemplate); } else { - for (ExecutionPlanConfigurationDto activeExectionPlanConfig:allActiveExecutionPlanConfigs) { + for (ExecutionPlanConfigurationDto activeExectionPlanConfig : allActiveExecutionPlanConfigs) { activeExecutionPlan = activeExectionPlanConfig.getExecutionPlan(); if (activeExecutionPlan.contains(executionPlanName)) { throw new AlertAlreadyExistException("Execution plan already exists with name " @@ -605,32 +617,32 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } private String getRegistryPath(String alertType, String queryName) - throws GeoLocationBasedServiceException { - String path = ""; - if (GeoServices.ALERT_TYPE_WITHIN.equals(alertType)) { - path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_WITHIN + - "/" + "/" + queryName; - } else if (GeoServices.ALERT_TYPE_EXIT.equals(alertType)) { - path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_EXIT + - "/" + queryName; - } else if (GeoServices.ALERT_TYPE_SPEED.equals(alertType)) { - path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_SPEED + - "/" ; - } else if (GeoServices.ALERT_TYPE_PROXIMITY.equals(alertType)) { - path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_PROXIMITY + - "/" + queryName; - } else if (GeoServices.ALERT_TYPE_STATIONARY.equals(alertType)) { - path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_STATIONARY + - "/" + queryName; - } else if (GeoServices.ALERT_TYPE_TRAFFIC.equals(alertType)) { - path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_TRAFFIC + - "/" + queryName; - } else { - throw new GeoLocationBasedServiceException( - "Unrecognized execution plan type: " + alertType); - } - return path; + throws GeoLocationBasedServiceException { + String path = ""; + if (GeoServices.ALERT_TYPE_WITHIN.equals(alertType)) { + path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_WITHIN + + "/" + "/" + queryName; + } else if (GeoServices.ALERT_TYPE_EXIT.equals(alertType)) { + path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_EXIT + + "/" + queryName; + } else if (GeoServices.ALERT_TYPE_SPEED.equals(alertType)) { + path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_SPEED + + "/"; + } else if (GeoServices.ALERT_TYPE_PROXIMITY.equals(alertType)) { + path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_PROXIMITY + + "/" + queryName; + } else if (GeoServices.ALERT_TYPE_STATIONARY.equals(alertType)) { + path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_STATIONARY + + "/" + queryName; + } else if (GeoServices.ALERT_TYPE_TRAFFIC.equals(alertType)) { + path = GeoServices.REGISTRY_PATH_FOR_ALERTS + GeoServices.ALERT_TYPE_TRAFFIC + + "/" + queryName; + } else { + throw new GeoLocationBasedServiceException( + "Unrecognized execution plan type: " + alertType); } + return path; + } private String getExecutionPlanName(String alertType, String queryName, String deviceId, String owner) { if (GeoServices.ALERT_TYPE_TRAFFIC.equals(alertType)) { @@ -798,7 +810,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic InputStream inputStream = resource.getContentStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, "UTF-8"); - return "{'speedLimit':" + writer.toString() + "}"; + return "{'speedLimit':" + writer + "}"; } catch (RegistryException | IOException e) { return "{'content': false}"; } @@ -816,7 +828,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic InputStream inputStream = resource.getContentStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, "UTF-8"); - return "{'speedLimit':" + writer.toString() + "}"; + return "{'speedLimit':" + writer + "}"; } catch (RegistryException | IOException e) { return "{'content': false}"; } @@ -835,8 +847,8 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic List proxTimeObj = (List) props.get(GeoServices.PROXIMITY_TIME); return String.format("{proximityDistance:\"%s\", proximityTime:\"%s\"}", - proxDisObj != null ? proxDisObj.get(0).toString() : "", - proxTimeObj != null ? proxTimeObj.get(0).toString() : ""); + proxDisObj != null ? proxDisObj.get(0).toString() : "", + proxTimeObj != null ? proxTimeObj.get(0).toString() : ""); } else { return "{'content': false}"; } @@ -868,7 +880,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } } - @Override public List getStationaryAlerts(DeviceIdentifier identifier, String owner) throws GeoLocationBasedServiceException { @@ -1079,7 +1090,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } private String parseTemplate(String alertType, Map parseMap) throws - GeoLocationBasedServiceException { + GeoLocationBasedServiceException { String templatePath = "alerts/Geo-ExecutionPlan-" + alertType + "_alert.siddhiql"; InputStream resource = getClass().getClassLoader().getResourceAsStream(templatePath); if (resource == null) { @@ -1142,22 +1153,22 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } private void updateRegistry(String path, Object content, Map options) - throws GeoLocationBasedServiceException { - try { + throws GeoLocationBasedServiceException { + try { - Registry registry = getGovernanceRegistry(); - Resource newResource = registry.newResource(); - newResource.setContent(content); - newResource.setMediaType("application/json"); - for (Map.Entry option : options.entrySet()) { - newResource.addProperty(option.getKey(), option.getValue()); - } - registry.put(path, newResource); - } catch (RegistryException e) { - throw new GeoLocationBasedServiceException( - "Error occurred while setting the Within Alert", e); + Registry registry = getGovernanceRegistry(); + Resource newResource = registry.newResource(); + newResource.setContent(content); + newResource.setMediaType("application/json"); + for (Map.Entry option : options.entrySet()) { + newResource.addProperty(option.getKey(), option.getValue()); } + registry.put(path, newResource); + } catch (RegistryException e) { + throw new GeoLocationBasedServiceException( + "Error occurred while setting the Within Alert", e); } + } /** * Loads the keystore. @@ -1207,7 +1218,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic */ private SSLContext initSSLConnection(String tenantAdminUser) throws NoSuchAlgorithmException, UnrecoverableKeyException, - KeyStoreException, KeyManagementException, IOException, CertificateException { + KeyStoreException, KeyManagementException, IOException, CertificateException { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty( "Security.TrustStore.Password"); @@ -1243,18 +1254,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } } - public static JWTClientManagerService getJWTClientManagerService() { - JWTClientManagerService jwtClientManagerService; - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - jwtClientManagerService = (JWTClientManagerService) ctx.getOSGiService(JWTClientManagerService.class, null); - if (jwtClientManagerService == null) { - String msg = "jwtClientManagerServicehas not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return jwtClientManagerService; - } - @Override public boolean createGeofence(GeofenceData geofenceData) throws GeoLocationBasedServiceException, EventConfigurationException { int tenantId; @@ -1291,7 +1290,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic List createdEventIds; try { setEventSource(geofenceData.getEventConfig()); - eventConfigService = DeviceManagementDataHolder.getInstance().getEventConfigurationService(); + eventConfigService = DeviceManagementDataHolder.getInstance().getEventConfigurationService(); createdEventIds = eventConfigService.createEventsOfDeviceGroup(geofenceData.getEventConfig(), geofenceData.getGroupIds()); DeviceManagementDAOFactory.beginTransaction(); geofenceDAO.createGeofenceEventMapping(geofenceData.getId(), createdEventIds); @@ -1333,6 +1332,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic /** * Set source of the event to GEOFENCE + * * @param eventConfig event list to be set event source */ private void setEventSource(List eventConfig) { @@ -1365,7 +1365,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } return geofence; } catch (DeviceManagementDAOException e) { - String msg = "Error occurred while retrieving Geofence data with ID "+fenceId; + String msg = "Error occurred while retrieving Geofence data with ID " + fenceId; log.error(msg, e); throw new GeoLocationBasedServiceException(msg, e); } catch (SQLException e) { @@ -1608,7 +1608,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic try { tenantId = DeviceManagementDAOUtil.getTenantId(); setEventSource(geofenceData.getEventConfig()); - eventConfigService = DeviceManagementDataHolder.getInstance().getEventConfigurationService(); + eventConfigService = DeviceManagementDataHolder.getInstance().getEventConfigurationService(); if (eventConfigService == null) { String msg = "Failed to load EventConfigurationProviderService osgi service of tenant " + tenantId; log.error(msg); @@ -1747,8 +1747,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic /** * Delete events of geofence + * * @param geofenceData geofence mapped with deleting events - * @param eventList events to be deleted + * @param eventList events to be deleted */ private void deleteGeoFenceEvents(GeofenceData geofenceData, List eventList) throws GeoLocationBasedServiceException { @@ -1762,7 +1763,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic } try { - EventConfigurationProviderService eventConfigService = DeviceManagementDataHolder + EventConfigurationProviderService eventConfigService = DeviceManagementDataHolder .getInstance().getEventConfigurationService(); eventConfigService.deleteEvents(eventList); eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_REVOKE, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventCreateCallback.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventCreateCallback.java index a5277e09a8..02c49b7406 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventCreateCallback.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventCreateCallback.java @@ -17,6 +17,7 @@ */ package org.wso2.carbon.device.mgt.core.geo.task; + public interface EventCreateCallback { void onCompleteEventOperation(Object values); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventOperationTaskException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventOperationTaskException.java index 4e8e14d914..3288410e76 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventOperationTaskException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/EventOperationTaskException.java @@ -18,7 +18,8 @@ package org.wso2.carbon.device.mgt.core.geo.task; -public class EventOperationTaskException extends Exception{ +public class EventOperationTaskException extends Exception { + public EventOperationTaskException(String message) { super(message); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/GeoFenceEventOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/GeoFenceEventOperationManager.java index e18968524f..daea9d53df 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/GeoFenceEventOperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/geo/task/GeoFenceEventOperationManager.java @@ -45,14 +45,15 @@ public class GeoFenceEventOperationManager { this.eventOperationCode = eventOperationCode; this.tenantId = tenantId; this.callback = callback; - isEventEnabled= DeviceConfigurationManager.getInstance().getDeviceManagementConfig() + isEventEnabled = DeviceConfigurationManager.getInstance().getDeviceManagementConfig() .getEventOperationTaskConfiguration().isEnabled(); } /** * Get executor for create EVENT_CONFIG / EVENT_REVOKE operations at the time of a device/s * assigned into a group or removed from a group - * @param groupId Id of the assigned / removed group + * + * @param groupId Id of the assigned / removed group * @param deviceIdentifiers Device identifiers assigned to / removed from the group * @return {@link GroupAssignmentEventOperationExecutor} Created executor to create operations */ @@ -72,7 +73,8 @@ public class GeoFenceEventOperationManager { /** * Get executor for create EVENT_CONFIG / EVENT_REVOKE operations at the time of a event is created - * @param groupIds list of group ids to apply the created event + * + * @param groupIds list of group ids to apply the created event * @param eventMetaData contains all the data of the related event * @return {@link EventOperationExecutor} The created event executor object */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index f084e35c3a..6ff661568c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -62,6 +62,7 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceTypeNotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.exceptions.UnauthorizedDeviceAccessException; import org.wso2.carbon.device.mgt.common.exceptions.UserNotFoundException; +import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery; import org.wso2.carbon.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitationDetails; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; @@ -74,8 +75,8 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; import java.sql.SQLException; import java.util.Date; @@ -827,8 +828,7 @@ public interface DeviceManagementProviderService { List getDeviceEnrolledTenants() throws DeviceManagementException; - List findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast, - int geohashLength) throws DeviceManagementException; + List findGeoClusters(GeoQuery geoQuery) throws DeviceManagementException; int getDeviceCountOfTypeByStatus(String deviceType, String deviceStatus) throws DeviceManagementException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 4959c282c4..1f4bac57d1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -92,6 +92,7 @@ import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; import org.wso2.carbon.device.mgt.common.exceptions.UnauthorizedDeviceAccessException; import org.wso2.carbon.device.mgt.common.exceptions.UserNotFoundException; +import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; import org.wso2.carbon.device.mgt.common.group.mgt.GroupAlreadyExistException; @@ -128,8 +129,8 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManag import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster; +import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener; @@ -3371,18 +3372,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public List findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast, - int geohashLength) throws DeviceManagementException { + public List findGeoClusters(GeoQuery geoQuery) throws DeviceManagementException { if (log.isDebugEnabled()) { - if (deviceType == null || deviceType.isEmpty()) { - log.debug("get information about geo clusters."); - } else { - log.debug("get information about geo clusters for device type: " + deviceType); - } + log.debug("Get information about geo clusters for query: " + new Gson().toJson(geoQuery)); } try { DeviceManagementDAOFactory.openConnection(); - return deviceDAO.findGeoClusters(deviceType, southWest, northEast, geohashLength, this.getTenantId()); + return deviceDAO.findGeoClusters(geoQuery, this.getTenantId()); } catch (DeviceManagementDAOException e) { String msg = "Error occurred while retrieving the geo clusters."; log.error(msg, e); From af2f8155e57831d06d8da9e4ef138376bd96e319 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 21 May 2021 12:32:02 +0530 Subject: [PATCH 41/49] added webapp authenticator component --- .../pom.xml | 14 +-- .../repository/conf/application-mgt.xml.j2 | 10 +- .../conf/webapp-authenticator-config.xml.j2 | 118 ++++++++++++++++++ .../src/main/resources/p2.inf | 1 + pom.xml | 2 + 5 files changed, 133 insertions(+), 12 deletions(-) create mode 100644 features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/webapp-authenticator-config.xml.j2 diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 2d3df3e061..e88716313f 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -63,13 +63,13 @@ javax.xml.bind.annotation, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.validation, - org.apache.catalina, - org.apache.catalina.connector, - org.apache.catalina.util, + + + org.apache.commons.logging, - org.apache.coyote, - org.apache.tomcat.util.buf, - org.apache.tomcat.util.http, + + + org.osgi.service.component, org.osgi.framework, org.w3c.dom, @@ -106,7 +106,7 @@ org.apache.commons.pool.impl, org.apache.http.conn, org.apache.http.impl.conn, - javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}", + javax.xml.stream, org.apache.axiom.*; version="${axiom.osgi.version.range}", org.wso2.carbon.registry.core.*, diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 index 8774964271..2550288629 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf_templates/templates/repository/conf/application-mgt.xml.j2 @@ -195,11 +195,11 @@ Video Players & Editors Weather GooglePlaySyncedApp - {% if application_mgt_conf.app_categories is defined %} - {%- for app_category in application_mgt_conf.app_categories -%} - {{app_category}} - {% endfor %} - {% endif %} + {% if application_mgt_conf.app_categories is defined %} + {%- for app_category in application_mgt_conf.app_categories -%} + {{app_category}} + {% endfor %} + {% endif %} diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/webapp-authenticator-config.xml.j2 b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/webapp-authenticator-config.xml.j2 new file mode 100644 index 0000000000..187c9131fe --- /dev/null +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/webapp-authenticator-config.xml.j2 @@ -0,0 +1,118 @@ + + + + OAuth + {% if webapp_auth_conf.authenticator.oauth is defined %} + {{webapp_auth_conf.authenticator.oauth.class_name}} + + {% for property_name,property_value in webapp_auth_conf.authenticator.oauth.parameter_options.items() %} + {{property_value}} + {% endfor %} + + {% else %} + org.wso2.carbon.webapp.authenticator.framework.authenticator.OAuthAuthenticator + + false + https://${iot.keymanager.host}:${iot.keymanager.https.port} + admin + admin + 100 + 100 + + {% endif %} + + + BasicAuth + {% if webapp_auth_conf.authenticator.basic_auth is defined %} + {{webapp_auth_conf.authenticator.basic_auth.class_name}} + + {% for property_name,property_value in webapp_auth_conf.authenticator.basic_auth.parameter_options.items() %} + {{property_value}} + {% endfor %} + + {% else %} + org.wso2.carbon.webapp.authenticator.framework.authenticator.BasicAuthAuthenticator + {% endif %} + + + JWT + {% if webapp_auth_conf.authenticator.jwt is defined %} + {{webapp_auth_conf.authenticator.jwt.class_name}} + + {% for property_name,property_value in webapp_auth_conf.authenticator.jwt.parameter_options.items() %} + {{property_value}} + {% endfor %} + + {% else %} + org.wso2.carbon.webapp.authenticator.framework.authenticator.JWTAuthenticator + + + wso2carbon + wso2carbon + wso2carbon + wso2carbon + + {% endif %} + + + CertificateAuth + {% if webapp_auth_conf.authenticator.certificate_auth is defined %} + {{webapp_auth_conf.authenticator.certificate_auth.class_name}} + + {% for property_name,property_value in webapp_auth_conf.authenticator.certificate_auth.parameter_options.items() %} + {{property_value}} + {% endfor %} + + {% else %} + org.wso2.carbon.webapp.authenticator.framework.authenticator.CertificateAuthenticator + {% endif %} + + + OTPAuth + {% if webapp_auth_conf.authenticator.otpauth is defined %} + {{webapp_auth_conf.authenticator.otpauth.class_name}} + + {% for property_name,property_value in webapp_auth_conf.authenticator.otpauth.parameter_options.items() %} + {{property_value}} + {% endfor %} + + {% else %} + org.wso2.carbon.webapp.authenticator.framework.authenticator.OneTimeTokenAuthenticator + {% endif %} + + + BST + {% if webapp_auth_conf.authenticator.bst is defined %} + {{webapp_auth_conf.authenticator.bst.class_name}} + + {% for property_name,property_value in webapp_auth_conf.authenticator.bst.parameter_options.items() %} + {{property_value}} + {% endfor %} + + {% else %} + org.wso2.carbon.webapp.authenticator.framework.authenticator.BSTAuthenticator + + false + https://${iot.keymanager.host}:${iot.keymanager.https.port} + admin + admin + 100 + 100 + + {% endif %} + + {% if webapp_auth_conf.authenticators is defined %} + {%- for authenticator in webapp_auth_conf.authenticators -%} + + {{authenticator.name}} + {{authenticator.class_name}} + + {% for property_name,property_value in authenticator.parameter_options.items() %} + {{property_value}} + {% endfor %} + + + {% endfor %} + {% endif %} + + diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf index 7b1ad15df1..a526d71269 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/src/main/resources/p2.inf @@ -1,2 +1,3 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.webapp.authenticator.framework.server_${feature.version}/conf/webapp-authenticator-config.xml,target:${installFolder}/../../conf/etc/webapp-authenticator-config.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.webapp.authenticator.framework.server_${feature.version}/conf_templates/,target:${installFolder}/../../resources/conf/,overwrite:true);\ diff --git a/pom.xml b/pom.xml index e3e7998167..afa35d50db 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ components/certificate-mgt components/ui-request-interceptor components/transport-mgt + components/webapp-authenticator-framework features/device-mgt features/apimgt-extensions features/application-mgt @@ -54,6 +55,7 @@ features/jwt-client features/device-mgt-extensions features/transport-mgt + features/webapp-authenticator-framework From 22dc7aaf2529a1893dfedef65f4a780e5e491633 Mon Sep 17 00:00:00 2001 From: Pahansith Gunathilake Date: Fri, 21 May 2021 13:22:25 +0000 Subject: [PATCH 42/49] Revert "Merge branch 'invoker' into 'master'" This reverts merge request !769 --- .../io/entgra/ui/request/interceptor/InvokerHandler.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java index d56202d8e2..51a6c06674 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/InvokerHandler.java @@ -48,7 +48,6 @@ import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.InputStreamBody; import io.entgra.ui.request.interceptor.beans.ProxyResponse; -import org.wso2.carbon.context.CarbonContext; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -111,11 +110,6 @@ public class InvokerHandler extends HttpServlet { HttpGet getRequest = new HttpGet(generateBackendRequestURL(req)); copyRequestHeaders(req, getRequest, false); getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); - if (apiEndpoint.equals(System.getProperty("iot.reporting.webapp.host"))) { - getRequest.setHeader("Tenant-Id", String.valueOf( - CarbonContext.getThreadLocalCarbonContext().getTenantId() - )); - } ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); if (HandlerConstants.TOKEN_IS_EXPIRED.equals(proxyResponse.getExecutorResponse())) { proxyResponse = retryRequestWithRefreshedToken(req, resp, getRequest); From 3a17cb23297ce870a9615de1228dc8e1d78ae6e1 Mon Sep 17 00:00:00 2001 From: charitha Date: Mon, 24 May 2021 21:17:24 +0530 Subject: [PATCH 43/49] Consider not now operations as pending --- .../operation/mgt/dao/impl/GenericOperationDAOImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index aed6c935a3..1ce3d8a006 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -53,8 +53,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.HashMap; -import java.util.Date; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -167,7 +165,7 @@ public class GenericOperationDAOImpl implements OperationDAO { try { Connection connection = OperationManagementDAOFactory.getConnection(); StringBuilder query = new StringBuilder("SELECT OPERATION_ID, ENROLMENT_ID FROM DM_ENROLMENT_OP_MAPPING " + - "WHERE OPERATION_CODE = ? AND STATUS = ? AND ENROLMENT_ID IN ("); + "WHERE OPERATION_CODE = ? AND STATUS IN ('NOTNOW', 'PENDING') AND ENROLMENT_ID IN ("); for (int i = 0; i < enrolmentIds.length; i++) { query.append(" ?,"); } @@ -175,10 +173,9 @@ public class GenericOperationDAOImpl implements OperationDAO { query.append(")"); stmt = connection.prepareStatement(query.toString()); stmt.setString(1, operationCode); - stmt.setString(2, Operation.Status.PENDING.toString()); for (int i = 0; i < enrolmentIds.length; i++) { - stmt.setInt(i + 3, enrolmentIds[i]); + stmt.setInt(i + 2, enrolmentIds[i]); } rs = stmt.executeQuery(); @@ -324,7 +321,7 @@ public class GenericOperationDAOImpl implements OperationDAO { for (int i = 0; i < operationResponseIds.size(); i++) { builder.append("?,"); } - sql1 += builder.deleteCharAt(builder.length() - 1).toString() + ")"; + sql1 += builder.deleteCharAt(builder.length() - 1) + ")"; stmt = conn.prepareStatement(sql1); int i; for (i = 0; i < operationResponseIds.size(); i++) { From a1567d8a3ded0ab3a0076add05a1b6064808fba3 Mon Sep 17 00:00:00 2001 From: MalshaPiumini Date: Mon, 24 May 2021 22:36:09 +0530 Subject: [PATCH 44/49] Increase session time for sso and non-sso login. --- .../device/mgt/core/config/ui/UIConfiguration.java | 10 ++++++++++ .../io/entgra/ui/request/interceptor/LoginHandler.java | 8 +++++--- .../entgra/ui/request/interceptor/SsoLoginHandler.java | 5 ++++- .../src/main/resources/conf/mdm-ui-config.xml | 2 ++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java index 914597687c..1c4a1e91cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java @@ -31,6 +31,7 @@ public class UIConfiguration { private AppRegistration appRegistration; private List scopes; private boolean isSsoEnable; + private int sessionTimeOut; @XmlElement(name = "AppRegistration", required=true) public AppRegistration getAppRegistration() { @@ -59,4 +60,13 @@ public class UIConfiguration { public void setSsoEnable(boolean ssoEnable) { isSsoEnable = ssoEnable; } + + @XmlElement(name = "SessionTimeOut") + public int getSessionTimeOut() { + return sessionTimeOut; + } + + public void setSessionTimeOut(int sessionTimeOut) { + this.sessionTimeOut = sessionTimeOut; + } } diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index e4246fbfc0..60dd31ab2d 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -39,6 +39,7 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.json.JSONString; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -69,13 +70,14 @@ public class LoginHandler extends HttpServlet { httpSession.invalidate(); } httpSession = req.getSession(true); - //setting session to expiry in 5 minutes - httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT)); JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); - JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); + int sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); + + //setting session to expire in 1h + httpSession.setMaxInactiveInterval(sessionTimeOut); // Check if OAuth app cache exists. If not create a new application. LoginCacheManager loginCacheManager = new LoginCacheManager(); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java index e23019d2c8..fb4f93b0c9 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/SsoLoginHandler.java @@ -72,6 +72,7 @@ public class SsoLoginHandler extends HttpServlet { private static String adminPassword; private static String gatewayUrl; private static String iotsCoreUrl; + private static int sessionTimeOut; private static String encodedAdminCredentials; private static String encodedClientApp; private static String applicationId; @@ -93,7 +94,7 @@ public class SsoLoginHandler extends HttpServlet { } httpSession = req.getSession(true); - httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT)); + initializeAdminCredentials(); baseContextPath = req.getContextPath(); applicationName = baseContextPath.substring(1, baseContextPath.indexOf("-ui-request-handler")); @@ -157,6 +158,7 @@ public class SsoLoginHandler extends HttpServlet { uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); + sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); // Register the client application HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); @@ -294,6 +296,7 @@ public class SsoLoginHandler extends HttpServlet { httpSession.setAttribute("encodedClientApp", encodedClientApp); httpSession.setAttribute("scope", scopes); httpSession.setAttribute("redirectUrl", req.getParameter("redirect")); + httpSession.setMaxInactiveInterval(sessionTimeOut); } /*** diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 3a425274f1..eba51b1d84 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -20,6 +20,8 @@ true true + + 3600 application_management From b8935487ef5bced8114cd95374e9f13ded005afa Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 7 Jun 2021 15:20:49 +0530 Subject: [PATCH 45/49] updated sim-config j2 file --- .../conf_templates/templates/repository/conf/sms-config.xml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 index 7f8cd7359b..61f7a16e45 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 @@ -22,7 +22,7 @@ - + sample From dfb4235a07107abfa413439070664eadcaa7b883 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Mon, 7 Jun 2021 17:37:20 +0530 Subject: [PATCH 46/49] fixed sms-config errors --- .../templates/repository/conf/sms-config.xml.j2 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 index 61f7a16e45..0ffc635427 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/src/main/resources/conf_templates/templates/repository/conf/sms-config.xml.j2 @@ -22,7 +22,7 @@ - + sample @@ -34,9 +34,6 @@ {%- for gateway in sms_conf.gateways -%} - sample - +94 - 160 {% for property_name,property_value in gateway.properties_options.items() %} {{property_value}} {% endfor %} From 293b5f5a7bbb2bf8f218f6fe10a81d38e3b17a66 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Tue, 8 Jun 2021 12:15:48 +0530 Subject: [PATCH 47/49] updated pom versions to 5.0.0-SNAPSHOT --- .../org.wso2.carbon.apimgt.annotations/pom.xml | 3 +-- .../pom.xml | 3 +-- .../org.wso2.carbon.apimgt.application.extension/pom.xml | 3 +-- .../org.wso2.carbon.apimgt.handlers/pom.xml | 3 +-- .../org.wso2.carbon.apimgt.integration.client/pom.xml | 3 +-- .../pom.xml | 3 +-- .../org.wso2.carbon.apimgt.webapp.publisher/pom.xml | 3 +-- components/apimgt-extensions/pom.xml | 3 +-- .../org.wso2.carbon.device.application.mgt.addons/pom.xml | 3 +-- .../org.wso2.carbon.device.application.mgt.api/pom.xml | 3 +-- .../org.wso2.carbon.device.application.mgt.common/pom.xml | 3 +-- .../org.wso2.carbon.device.application.mgt.core/pom.xml | 3 +-- .../pom.xml | 3 +-- .../pom.xml | 3 +-- components/application-mgt/pom.xml | 3 +-- .../org.wso2.carbon.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.certificate.mgt.core/pom.xml | 3 +-- components/certificate-mgt/pom.xml | 3 +-- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.carbon.device.mgt.config.api/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.api/pom.xml | 8 +++++++- .../device-mgt/org.wso2.carbon.device.mgt.common/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.core/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.extensions/pom.xml | 2 +- .../device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.url.printer/pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../io.entgra.server.bootup.heartbeat.beacon/pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.oauth.extensions/pom.xml | 3 +-- .../pom.xml | 2 +- .../org.wso2.carbon.identity.jwt.client.extension/pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../org.wso2.carbon.complex.policy.decision.point/pom.xml | 3 +-- .../org.wso2.carbon.policy.decision.point/pom.xml | 3 +-- .../org.wso2.carbon.policy.information.point/pom.xml | 3 +-- .../policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml | 3 +-- .../policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml | 3 +-- components/policy-mgt/pom.xml | 3 +-- .../org.wso2.carbon.email.sender.core/pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.api/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.common/pom.xml | 2 +- .../io.entgra.transport.mgt.sms.handler.core/pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor/pom.xml | 3 +-- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 3 +-- components/webapp-authenticator-framework/pom.xml | 3 +-- .../pom.xml | 3 +-- .../org.wso2.carbon.apimgt.handler.server.feature/pom.xml | 3 +-- .../pom.xml | 3 +-- .../pom.xml | 3 +-- features/apimgt-extensions/pom.xml | 3 +-- .../pom.xml | 3 +-- .../pom.xml | 3 +-- features/application-mgt/pom.xml | 3 +-- .../org.wso2.carbon.certificate.mgt.api.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 3 +-- features/certificate-mgt/pom.xml | 3 +-- .../pom.xml | 3 +-- .../pom.xml | 3 +-- .../pom.xml | 3 +-- .../pom.xml | 3 +-- .../pom.xml | 3 +-- features/device-mgt-extensions/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.analytics.feature/pom.xml | 3 +-- .../org.wso2.carbon.device.mgt.api.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.basics.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.extensions.feature/pom.xml | 3 +-- .../device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml | 2 +- .../org.wso2.carbon.device.mgt.server.feature/pom.xml | 3 +-- .../org.wso2.carbon.device.mgt.ui.feature/pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../io.entgra.server.heart.beat.feature/pom.xml | 2 +- features/heartbeat-management/pom.xml | 3 +-- .../pom.xml | 3 +-- features/jwt-client/pom.xml | 3 +-- .../pom.xml | 3 +-- features/oauth-extensions/pom.xml | 3 +-- .../org.wso2.carbon.policy.mgt.server.feature/pom.xml | 3 +-- features/policy-mgt/pom.xml | 3 +-- .../org.wso2.carbon.email.sender.feature/pom.xml | 3 +-- features/transport-mgt/email-sender/pom.xml | 3 +-- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 3 +-- .../pom.xml | 3 +-- features/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor.feature/pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 3 +-- features/webapp-authenticator-framework/pom.xml | 3 +-- pom.xml | 4 ++-- 104 files changed, 111 insertions(+), 163 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index a530cbcfa1..aeb8e0168c 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 4.1.16-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index c99c9d1988..6b0a02043b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,11 @@ apimgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 - 4.1.16-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 0282a89040..ae6c1076a2 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,11 @@ apimgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 - 4.1.16-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index 2fbd10211f..aa77bf7ecd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -21,13 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 4.1.16-SNAPSHOT bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index eeddf628a5..7980d20223 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -13,13 +13,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 4.1.16-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 22c399e5b7..391979285e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -13,13 +13,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 4.1.16-SNAPSHOT bundle WSO2 Carbon - API Management Integration Generated Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index b2b587bcd1..1934338712 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 4.1.16-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index eea40219af..a692fbbf24 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,12 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 4.1.16-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml index e85664237d..059af5fb7e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml @@ -3,13 +3,12 @@ application-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.addons - 4.1.16-SNAPSHOT WSO2 Carbon - Application Management Add-Ons WSO2 Carbon - Application Management Add-Ons https://entgra.io diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml index 591b2f46f1..6a84b225e1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml @@ -22,13 +22,12 @@ application-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.api - 4.1.16-SNAPSHOT war WSO2 Carbon - Application Management API WSO2 Carbon - Application Management API diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml index 9ebaecc139..9bc4a1dcf4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml @@ -21,13 +21,12 @@ org.wso2.carbon.devicemgt application-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.common - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Application Management Common WSO2 Carbon - Application Management Common diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index e54526735e..1bf38faaaa 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -21,13 +21,12 @@ org.wso2.carbon.devicemgt application-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.core - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Application Management Core WSO2 Carbon - Application Management Core diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml index cc88e04256..75586560be 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml @@ -22,13 +22,12 @@ application-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.publisher.api - 4.1.16-SNAPSHOT war WSO2 Carbon - Application Management Publisher API WSO2 Carbon - Application Management Publisher API diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml index c23da83cb2..480264b88a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml @@ -22,13 +22,12 @@ application-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.store.api - 4.1.16-SNAPSHOT war WSO2 Carbon - Application Management Store API WSO2 Carbon - Application Management Store API diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 8d20275116..53a4256688 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,13 +22,12 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 application-mgt - 4.1.16-SNAPSHOT pom WSO2 Carbon - Application Management Component WSO2 Carbon - Application Management Component diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index f77e066ce5..2e4defe98c 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 743227b322..d5e645e24f 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 898f828dc5..b129c7affa 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -38,13 +38,12 @@ org.wso2.carbon.devicemgt certificate-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index df7948b53f..ebb7bae8ba 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 4.1.16-SNAPSHOT pom WSO2 Carbon - Certificate Management Component http://wso2.org diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 698bba5d44..6116d38fc5 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index e8f93ec911..ae6ddc3665 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index a40a895622..821389cf34 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index 994f41bfe5..4490ef70fa 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 5b6766bb66..61f896e377 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 2a60c2797e..9150709a6b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index d55cf9ea49..f76390dbee 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index 0629418662..85c915cd66 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index d4849aceef..2606d543c8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml index bf9eedf2a7..4c495596d5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml @@ -20,7 +20,7 @@ device-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT 4.0.0 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 38bc2c001a..bae7d9e84a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml @@ -325,6 +325,12 @@ javax.ws.rs javax.ws.rs-api + provided + + + javax.ws.rs + jsr311-api + provided org.wso2.carbon.commons diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index dc6240b236..071ebfb39d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 30a8d6fa76..8f78ea3064 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 11c9471e76..3c17f25ec2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml index 402dedb384..cda668636f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index 744abc8ba1..981a5383b3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index adb86890c8..0e362501db 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml index 2aab7d1cdd..2a660006e6 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heartbeat-management - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 08477b29cb..dae6112b77 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index ae46c74805..2853017c24 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,13 +22,12 @@ org.wso2.carbon.devicemgt identity-extensions - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions - 4.1.16-SNAPSHOT bundle WSO2 Carbon - OAuth Extensions http://wso2.org diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index 4adb6539ab..33286cd1e6 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -21,7 +21,7 @@ identity-extensions org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT 4.0.0 diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index 7e171cd155..dcabec21e4 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index bbf1f08a4e..27d6a1bc79 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml index 4823875d18..6e0f87666d 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt policy-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.complex.policy.decision.point - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index 0c3d56ebc2..8c43b569f9 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,14 +3,13 @@ org.wso2.carbon.devicemgt policy-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.decision.point - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 91e54e19ae..00a3b9c925 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml @@ -11,7 +11,6 @@ 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.information.point - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Policy Information Point WSO2 Carbon - Policy Information Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 7430fd3211..8aa6a91517 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt policy-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.common - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Policy Management Common WSO2 Carbon - Policy Management Common diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index 38acfd2d93..2efdf89d5f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,13 +22,12 @@ org.wso2.carbon.devicemgt policy-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.policy.mgt.core - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Policy Management Core WSO2 Carbon - Policy Management Core diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index e047aa2278..4f1db3f6ae 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,13 +23,12 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 policy-mgt - 4.1.16-SNAPSHOT pom WSO2 Carbon - Policy Management Component http://wso2.org diff --git a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml index 6ae1098d84..592564cc0a 100644 --- a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 61e795d747..da5fdb82a1 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index b307febc12..fc1c94aaef 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml index 8a8ae5ee3c..c4bdb628f5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml index 8edc2d7a44..ac4edf6955 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml index 49eae641ab..f88e557184 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 2f46ed8dfa..4c8815afc6 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml index d41942e3f6..0fcf6eee7d 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml @@ -21,12 +21,11 @@ ui-request-interceptor io.entgra.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT 4.0.0 io.entgra.ui.request.interceptor - 4.1.16-SNAPSHOT war Entgra - Request Handling Proxy Servlet Proxy Service for Request Handling in Entgra EMM/IOT Server. diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index cfed28d8b0..6204dc57d3 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index e88716313f..e041b45f83 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,14 +21,13 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.webapp.authenticator.framework - 4.1.16-SNAPSHOT bundle WSO2 Carbon - Web Application Authenticator Framework Bundle WSO2 Carbon - Web Application Authenticator Framework Bundle diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 4a3c39e174..922e3fdcf5 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework - 4.1.16-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework http://wso2.org diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index e97519888a..b1033f9963 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,14 +21,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.application.extension.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - API Management Application Extension Feature http://wso2.org This feature contains an implementation of a api application registration, which takes care of subscription diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml index 6e332ef23b..2bd2ef8468 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handler.server.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Device Management - APIM handler Server Feature http://wso2.org This feature contains the handler for the api authentications diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index a934c7dc4c..8051e07759 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -21,13 +21,12 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client.feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - APIM Integration Client Feature http://wso2.org diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index e9f713c97f..d8c6d64729 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,14 +21,13 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - API Management Webapp Publisher Feature http://wso2.org This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 3561b8c4d6..42650878ae 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt apimgt-extensions-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - API Management Extensions Feature http://wso2.org diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml index 44f13b7540..5bdf583f19 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml @@ -22,13 +22,12 @@ org.wso2.carbon.devicemgt application-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.api.feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - Application Management API Feature https://entgra.io diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml index dc53590a67..66d0322843 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt application-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.server.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Application Management Server Feature https://entgra.io diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 86fe383b78..1aa070544a 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,13 +22,12 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 application-mgt-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - Application Management Feature https://entgra.io diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index 1988d44d71..c4894c3c43 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index 1dfc80f494..5cbef9678b 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index a7a9d89595..6792ce5d05 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.server.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Certificate Management Server Feature http://wso2.org This feature contains the core bundles required for back-end Certificate Management functionality diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 29ce4363df..7dceadff12 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,13 +22,12 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 certificate-mgt-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - Certificate Management Feature http://wso2.org diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index 367a9e97dd..aca2bf216d 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Device Type Deployer Feature http://wso2.org WSO2 Carbon - Device Type Deployer Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 3a9724ec93..e1caa4a07d 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - FCM Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 03ab72d6f5..489e36b2cd 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - MQTT Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 87c6f51c3e..4c025f8572 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - MQTT Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 7f49e2dd7a..f482a4874f 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - XMPP Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - XMPP Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 8f4033f2f0..063ed9e1c2 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml index 4f2154e29d..411d4d0a2c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt device-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.analytics.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains bundles related to device analytics data publisher and ws proxy diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index 68ac18bdf9..c36f6b292c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index f315096d69..f96f388520 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index 00d4a96a0b..d9969b9071 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,14 +4,13 @@ org.wso2.carbon.devicemgt device-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Device Management Extensions Feature http://wso2.org This feature contains common extensions used by key device management functionalities diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index f986e520a0..2b919cccdf 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index d5d7bf98f0..3e5bc9400e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt device-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.server.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml index e00fa634c8..c4f70cf3be 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 528051da15..d53543139b 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml index de26779b16..ceae78d430 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heart-beat-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 2602548044..b034331e1b 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt heart-beat-feature - 4.1.16-SNAPSHOT pom Entgra - Heart Beat Feature http://entgra.io diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index 410cca6e21..4047e2295c 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,14 +23,13 @@ org.wso2.carbon.devicemgt jwt-client-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.identity.jwt.client.extension.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - JWT Client Feature http://wso2.org This feature contains jwt client implementation from which we can get a access token using the jwt diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 75942261f7..994c462f6a 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,13 +23,12 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 jwt-client-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - JWT Client Extension Feature http://wso2.org diff --git a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml index 1ca77e930c..bd943afb33 100644 --- a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml +++ b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml @@ -23,14 +23,13 @@ org.wso2.carbon.devicemgt oauth-extensions-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Device Mgt OAuth Extensions Feature http://wso2.org This feature contains devicemgt related OAuth extensions diff --git a/features/oauth-extensions/pom.xml b/features/oauth-extensions/pom.xml index 8e62605ea5..5e1d9ad26d 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/oauth-extensions/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt oauth-extensions-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - Device Management OAuth Extensions Feature http://wso2.org diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index daffbc913c..57146156f9 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,14 +23,13 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.policy.mgt.server.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Policy Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 3223326c5c..44dd54475a 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,14 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt policy-mgt-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - Policy Management Feature http://wso2.org diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index eaf13f69ff..52a2cc4730 100644 --- a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt email-sender-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.email.sender.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Email Sender Feature http://wso2.org This feature contains the core bundles required for email sender related functionality diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 3292c9ddd4..f44b2990b2 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt email-sender-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - Email Sender Feature http://wso2.org diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 1ad1049576..7f934bdd60 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml index 9c33be06bb..a702d27095 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt sms-handler-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.transport.mgt.sms.handler.api.feature pom - 4.1.16-SNAPSHOT Entgra - SMS Handler API Feature https://entgra.io This feature contains the APIs required for SMS Handler diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml index e6555c2037..9fad844781 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt sms-handler-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.transport.mgt.sms.handler.server.feature pom - 4.1.16-SNAPSHOT Entgra - SMS Handler Server Feature https://entgra.io This feature contains the core bundles required for Back-end SMS Handler functionality diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index d5bf4be703..107357cbaf 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml index b1df7b1684..364ce6a9f4 100644 --- a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 0ab46ec416..1e4441c810 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index a2448e6fff..7f825735f1 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.webapp.authenticator.framework.server.feature pom - 4.1.16-SNAPSHOT WSO2 Carbon - Webapp Authenticator Framework Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 264f071c9d..d399ea4680 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,14 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 4.1.16-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework Feature http://wso2.org diff --git a/pom.xml b/pom.xml index 885f41e130..5f6a2d8d1d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 4.1.16-SNAPSHOT + 5.0.0-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -2093,7 +2093,7 @@ 1.2.11.wso2v10 - 4.1.16-SNAPSHOT + ${project.version} 4.7.35 From 23d2b9d767c15962a3509045d286921488f6380b Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 11 Jun 2021 10:48:33 +0530 Subject: [PATCH 48/49] added claim adding logic to SP --- .../resources/payloads/update-app-request.xml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml index 4f608a9e55..50e82b986c 100644 --- a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml @@ -8,6 +8,48 @@ ${applicationName} ${description} + + + + + + + + + + + + + http://wso2.org/claims/username + + + true + + + + + + http://testclaims/claims/username + + + true + + + + + + + + + + + + + + + + + From 8f689c810145a7e8a606bbdef823abbe583e0bd6 Mon Sep 17 00:00:00 2001 From: sandaru Date: Mon, 14 Jun 2021 14:46:36 +0530 Subject: [PATCH 49/49] Add default sim update operation scope https://gitlab.com/entgra/product-iots/-/issues/991 --- .../src/main/resources/conf/mdm-ui-config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index eba51b1d84..36fe025034 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -180,6 +180,7 @@ perm:metadata:create perm:metadata:update perm:android:google-account + perm:android:update-default-sim device-mgt