diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 730bb53c16..b124fb4e91 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -80,6 +80,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class); public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); + private static final String UNLIMITED_TIER = "Unlimited"; @Override public boolean isTierLoaded() { @@ -238,6 +239,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); + application.setThrottlingPolicy(UNLIMITED_TIER); try { application = consumerRESTAPIServices.createApplication(tokenInfo, application); @@ -254,7 +256,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), keyType, validityTime); + keyManager.getName(), validityTime, keyType); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -317,6 +319,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Subscription subscription = new Subscription(); subscription.setApiId(apiInfo.getId()); subscription.setApplicationId(application.getApplicationId()); + subscription.setThrottlingPolicy(UNLIMITED_TIER); + subscription.setRequestedThrottlingPolicy(UNLIMITED_TIER); subscriptionList.add(subscription); }); @@ -649,7 +653,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationKey apiApplicationKey; io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { - if (username == null && password == null) { + if (username == null || password == null) { apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); } else { apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 81ed4cd4e3..293894ee71 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -176,7 +176,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { " \"description\": \"" + application.getDescription() + "\",\n" + " \"tokenType\": \"" + application.getTokenType() + "\",\n" + " \"groups\": " + gson.toJson(application.getGroups()) + ",\n" + - " \"attributes\": " + application.getAttributes().toString() + ",\n" + + " \"attributes\": " + gson.toJson(application.getAttributes()) + ",\n" + " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + "}"; RequestBody requestBody = RequestBody.create(JSON, applicationInfo); @@ -291,7 +291,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId + "&limit=1000"; Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); @@ -497,8 +497,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); - return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); + return gson.fromJson(response.body().string(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java index f18647899f..3dc4b6c570 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java @@ -36,31 +36,16 @@ public class APIInfo { private String context; private String version; private String provider; - private JSONObject apiDefinition; - private String wsdlUri; private String lifeCycleStatus; - private boolean isDefaultVersion; - private String type; - private Set transport; - private List operations; - private String authorizationHeader; - private String securityScheme; - private Set tags; - private List tiers; - private boolean hasThumbnail; - private String additionalProperties; - private JSONObject monetization; - private List endpointURLs; - private JSONObject businessInformation; - private List environmentList; - private List scopes; + private String thumbnailUri; private String avgRating; + private List throttlingPolicies; private JSONObject advertiseInfo; + private JSONObject businessInformation; private boolean isSubscriptionAvailable; - private List categories; - private List keyManagers = new ArrayList(); - private String createdTime; - private String lastUpdatedTime; + private String monetizationLabel; + private String gatewayVendor; + private List additionalProperties; public String getId() { return id; @@ -110,22 +95,6 @@ public class APIInfo { this.provider = provider; } - public JSONObject getApiDefinition() { - return apiDefinition; - } - - public void setApiDefinition(JSONObject apiDefinition) { - this.apiDefinition = apiDefinition; - } - - public String getWsdlUri() { - return wsdlUri; - } - - public void setWsdlUri(String wsdlUri) { - this.wsdlUri = wsdlUri; - } - public String getLifeCycleStatus() { return lifeCycleStatus; } @@ -134,100 +103,36 @@ public class APIInfo { this.lifeCycleStatus = lifeCycleStatus; } - public boolean isDefaultVersion() { - return isDefaultVersion; - } - - public void setDefaultVersion(boolean defaultVersion) { - isDefaultVersion = defaultVersion; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Set getTransport() { - return transport; - } - - public void setTransport(Set transport) { - this.transport = transport; - } - - public List getOperations() { - return operations; - } - - public void setOperations(List operations) { - this.operations = operations; - } - - public String getAuthorizationHeader() { - return authorizationHeader; - } - - public void setAuthorizationHeader(String authorizationHeader) { - this.authorizationHeader = authorizationHeader; - } - - public String getSecurityScheme() { - return securityScheme; - } - - public void setSecurityScheme(String securityScheme) { - this.securityScheme = securityScheme; - } - - public Set getTags() { - return tags; - } - - public void setTags(Set tags) { - this.tags = tags; - } - - public List getTiers() { - return tiers; - } - - public void setTiers(List tiers) { - this.tiers = tiers; - } - - public boolean isHasThumbnail() { - return hasThumbnail; + public String getThumbnailUri() { + return thumbnailUri; } - public void setHasThumbnail(boolean hasThumbnail) { - this.hasThumbnail = hasThumbnail; + public void setThumbnailUri(String thumbnailUri) { + this.thumbnailUri = thumbnailUri; } - public String getAdditionalProperties() { - return additionalProperties; + public String getAvgRating() { + return avgRating; } - public void setAdditionalProperties(String additionalProperties) { - this.additionalProperties = additionalProperties; + public void setAvgRating(String avgRating) { + this.avgRating = avgRating; } - public JSONObject getMonetization() { - return monetization; + public List getThrottlingPolicies() { + return throttlingPolicies; } - public void setMonetization(JSONObject monetization) { - this.monetization = monetization; + public void setThrottlingPolicies(List throttlingPolicies) { + this.throttlingPolicies = throttlingPolicies; } - public List getEndpointURLs() { - return endpointURLs; + public JSONObject getAdvertiseInfo() { + return advertiseInfo; } - public void setEndpointURLs(List endpointURLs) { - this.endpointURLs = endpointURLs; + public void setAdvertiseInfo(JSONObject advertiseInfo) { + this.advertiseInfo = advertiseInfo; } public JSONObject getBusinessInformation() { @@ -238,38 +143,6 @@ public class APIInfo { this.businessInformation = businessInformation; } - public List getEnvironmentList() { - return environmentList; - } - - public void setEnvironmentList(List environmentList) { - this.environmentList = environmentList; - } - - public List getScopes() { - return scopes; - } - - public void setScopes(List scopes) { - this.scopes = scopes; - } - - public String getAvgRating() { - return avgRating; - } - - public void setAvgRating(String avgRating) { - this.avgRating = avgRating; - } - - public JSONObject getAdvertiseInfo() { - return advertiseInfo; - } - - public void setAdvertiseInfo(JSONObject advertiseInfo) { - this.advertiseInfo = advertiseInfo; - } - public boolean isSubscriptionAvailable() { return isSubscriptionAvailable; } @@ -278,35 +151,27 @@ public class APIInfo { isSubscriptionAvailable = subscriptionAvailable; } - public List getCategories() { - return categories; - } - - public void setCategories(List categories) { - this.categories = categories; - } - - public List getKeyManagers() { - return keyManagers; + public String getMonetizationLabel() { + return monetizationLabel; } - public void setKeyManagers(List keyManagers) { - this.keyManagers = keyManagers; + public void setMonetizationLabel(String monetizationLabel) { + this.monetizationLabel = monetizationLabel; } - public String getCreatedTime() { - return createdTime; + public String getGatewayVendor() { + return gatewayVendor; } - public void setCreatedTime(String createdTime) { - this.createdTime = createdTime; + public void setGatewayVendor(String gatewayVendor) { + this.gatewayVendor = gatewayVendor; } - public String getLastUpdatedTime() { - return lastUpdatedTime; + public List getAdditionalProperties() { + return additionalProperties; } - public void setLastUpdatedTime(String lastUpdatedTime) { - this.lastUpdatedTime = lastUpdatedTime; + public void setAdditionalProperties(List additionalProperties) { + this.additionalProperties = additionalProperties; } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java index 085b87785f..2ff525f5dc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -18,13 +18,15 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +import org.json.JSONObject; + public class Subscription { private String subscriptionId; private String applicationId; private String apiId; private APIInfo apiInfo; - private Application applicationInfo; + private JSONObject applicationInfo; private String throttlingPolicy; private String requestedThrottlingPolicy; private String status; @@ -62,11 +64,11 @@ public class Subscription { this.apiInfo = apiInfo; } - public Application getApplicationInfo() { + public JSONObject getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(Application applicationInfo) { + public void setApplicationInfo(JSONObject applicationInfo) { this.applicationInfo = applicationInfo; }