mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Map Json object return types to dto classes in Publisher
This commit is contained in:
parent
565a7614ad
commit
bdf1e97d84
@ -47,13 +47,13 @@ public interface PublisherRESTAPIServices {
|
|||||||
boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope)
|
boolean updateSharedScope(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Scope scope)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||||
|
|
||||||
JSONObject getApi(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String apiUuid)
|
APIInfo getApi(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String apiUuid)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||||
|
|
||||||
JSONObject getApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo)
|
APIInfo[] getApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||||
|
|
||||||
JSONObject addAPI(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, APIInfo api)
|
APIInfo addAPI(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, APIInfo api)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||||
|
|
||||||
boolean updateApi(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, APIInfo api)
|
boolean updateApi(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, APIInfo api)
|
||||||
@ -91,7 +91,7 @@ public interface PublisherRESTAPIServices {
|
|||||||
String apiRevisionId, List<APIRevisionDeployment> apiRevisionDeploymentList)
|
String apiRevisionId, List<APIRevisionDeployment> apiRevisionDeploymentList)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||||
|
|
||||||
abstract boolean undeployAPIRevisionDeployment(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo,
|
boolean undeployAPIRevisionDeployment(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo,
|
||||||
JSONObject apiRevisionDeployment, String uuid)
|
JSONObject apiRevisionDeployment, String uuid)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
throws APIServicesException, BadRequestException, UnexpectedResponseException;
|
||||||
|
|
||||||
|
|||||||
@ -21,12 +21,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.APIInfo;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.*;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.Scope;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.Mediation;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.Documentation;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.APIRevision;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.APIRevisionDeployment;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException;
|
||||||
@ -123,7 +118,7 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new BadRequestException(msg);
|
throw new BadRequestException(msg);
|
||||||
} else if (HttpStatus.SC_NOT_FOUND == response.code()) {
|
} else if (HttpStatus.SC_NOT_FOUND == response.code()) {
|
||||||
String msg = "Shared scope key not found";
|
String msg = "Shared scope key not found : " + key;
|
||||||
log.info(msg);
|
log.info(msg);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -144,8 +139,10 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
String addNewSharedScopeEndPoint = endPointPrefix + Constants.SCOPE_API_ENDPOINT;
|
String addNewSharedScopeEndPoint = endPointPrefix + Constants.SCOPE_API_ENDPOINT;
|
||||||
|
|
||||||
JSONArray bindings = new JSONArray();
|
JSONArray bindings = new JSONArray();
|
||||||
for (String str : scope.getBindings()) {
|
if (scope.getBindings() != null) {
|
||||||
bindings.put(str);
|
for (String str : scope.getBindings()) {
|
||||||
|
bindings.put(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject payload = new JSONObject();
|
JSONObject payload = new JSONObject();
|
||||||
@ -196,8 +193,10 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
String updateScopeUrl = endPointPrefix + Constants.SCOPE_API_ENDPOINT + scope.getId();
|
String updateScopeUrl = endPointPrefix + Constants.SCOPE_API_ENDPOINT + scope.getId();
|
||||||
|
|
||||||
JSONArray bindings = new JSONArray();
|
JSONArray bindings = new JSONArray();
|
||||||
for (String str : scope.getBindings()) {
|
if (scope.getBindings() != null) {
|
||||||
bindings.put(str);
|
for (String str : scope.getBindings()) {
|
||||||
|
bindings.put(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject payload = new JSONObject();
|
JSONObject payload = new JSONObject();
|
||||||
@ -242,7 +241,7 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getApi(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String apiUuid)
|
public APIInfo getApi(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String apiUuid)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
||||||
|
|
||||||
String getAllApi = endPointPrefix + Constants.API_ENDPOINT + apiUuid;
|
String getAllApi = endPointPrefix + Constants.API_ENDPOINT + apiUuid;
|
||||||
@ -256,8 +255,7 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
try {
|
try {
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
if (HttpStatus.SC_OK == response.code()) {
|
if (HttpStatus.SC_OK == response.code()) {
|
||||||
JSONObject jsonObject = new JSONObject(response.body().string());
|
return gson.fromJson(response.body().string(), APIInfo.class);
|
||||||
return jsonObject;
|
|
||||||
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
||||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||||
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
||||||
@ -281,7 +279,7 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo)
|
public APIInfo[] getApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
||||||
|
|
||||||
String getAllApis = endPointPrefix + Constants.GET_ALL_APIS;
|
String getAllApis = endPointPrefix + Constants.GET_ALL_APIS;
|
||||||
@ -295,8 +293,8 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
try {
|
try {
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
if (HttpStatus.SC_OK == response.code()) {
|
if (HttpStatus.SC_OK == response.code()) {
|
||||||
JSONObject jsonObject = new JSONObject(response.body().string());
|
JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list");
|
||||||
return jsonObject;
|
return gson.fromJson(apiList.toString(), APIInfo[].class);
|
||||||
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
||||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||||
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
||||||
@ -320,59 +318,111 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject addAPI(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, APIInfo api)
|
public APIInfo addAPI(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, APIInfo api)
|
||||||
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
throws APIServicesException, BadRequestException, UnexpectedResponseException {
|
||||||
|
|
||||||
String addAPIEndPoint = endPointPrefix + Constants.API_ENDPOINT;
|
String addAPIEndPoint = endPointPrefix + Constants.API_ENDPOINT;
|
||||||
|
|
||||||
String apiString = "{\n" +
|
JSONObject payload = new JSONObject();
|
||||||
" \"name\": \"" + api.getName() + "\",\n" +
|
payload.put("name", api.getName());
|
||||||
" \"description\":\"" + api.getDescription() + "\",\n" +
|
payload.put("description", api.getDescription());
|
||||||
" \"context\":\"" + api.getContext() + "\",\n" +
|
payload.put("context", api.getContext());
|
||||||
" \"version\":\"" + api.getVersion() + "\",\n" +
|
payload.put("version", api.getVersion());
|
||||||
" \"provider\":\"" + api.getProvider() + "\",\n" +
|
payload.put("provider", api.getProvider());
|
||||||
" \"lifeCycleStatus\":\"" + api.getLifeCycleStatus() + "\",\n" +
|
payload.put("lifeCycleStatus", api.getLifeCycleStatus());
|
||||||
" \"wsdlInfo\": " + api.getWsdlInfo() + ",\n" +
|
payload.put("wsdlInfo", (api.getWsdlInfo() != null ? api.getWsdlInfo() : null));
|
||||||
" \"wsdlUrl\":" + api.getWsdlUrl() + ",\n" +
|
payload.put("wsdlUrl", (api.getWsdlUrl() != null ? api.getWsdlUrl() : null));
|
||||||
" \"responseCachingEnabled\": " + api.isResponseCachingEnabled() + ",\n" +
|
payload.put("responseCachingEnabled", api.isResponseCachingEnabled());
|
||||||
" \"cacheTimeout\": " + api.getCacheTimeout() + ",\n" +
|
payload.put("cacheTimeout", api.getCacheTimeout());
|
||||||
" \"hasThumbnail\": " + api.isHasThumbnail() + ",\n" +
|
payload.put("hasThumbnail", api.isHasThumbnail());
|
||||||
" \"isDefaultVersion\": " + api.isDefaultVersion() + ",\n" +
|
payload.put("isDefaultVersion", api.isDefaultVersion());
|
||||||
" \"isRevision\": " + api.isRevision() + ",\n" +
|
payload.put("isRevision", api.isRevision());
|
||||||
" \"revisionedApiId\": " + api.getRevisionedApiId() + ",\n" +
|
payload.put("revisionedApiId", (api.getRevisionedApiId() != null ? api.getRevisionedApiId() : null));
|
||||||
" \"revisionId\": " + api.getRevisionId() + ",\n" +
|
payload.put("revisionId", api.getRevisionId());
|
||||||
" \"enableSchemaValidation\": " + api.isEnableSchemaValidation() + ",\n" +
|
payload.put("enableSchemaValidation", api.isEnableSchemaValidation());
|
||||||
" \"type\": \"" + api.getType() + "\",\n" +
|
payload.put("type", api.getType());
|
||||||
" \"transport\": " + gson.toJson(api.getTransport()) + ",\n" +
|
payload.put("apiThrottlingPolicy", api.getApiThrottlingPolicy());
|
||||||
" \"tags\": " + gson.toJson(api.getTags()) + ",\n" +
|
payload.put("authorizationHeader", api.getAuthorizationHeader());
|
||||||
" \"policies\": " + gson.toJson(api.getPolicies()) + ",\n" +
|
payload.put("visibility", api.getVisibility());
|
||||||
" \"apiThrottlingPolicy\": " + api.getApiThrottlingPolicy() + ",\n" +
|
payload.put("subscriptionAvailability", (api.getSubscriptionAvailability() != null ? api.getSubscriptionAvailability() : ""));
|
||||||
" \"authorizationHeader\": \"" + api.getAuthorizationHeader() + "\",\n" +
|
|
||||||
" \"visibility\": \"" + api.getVisibility() + "\",\n" +
|
|
||||||
" \"mediationPolicies\": " + (api.getInSequence() != null ? "[{\"name\": \"" + api.getInSequence() + "\",\"type\": \"in\"}]" : null) + ",\n" +
|
|
||||||
" \"subscriptionAvailability\": \"" + api.getSubscriptionAvailability() + "\",\n" +
|
|
||||||
" \"subscriptionAvailableTenants\": [],\n" +
|
|
||||||
" \"additionalProperties\": [],\n" +
|
|
||||||
" \"monetization\": " + api.getMonetization() + ",\n" +
|
|
||||||
" \"corsConfiguration\": " + gson.toJson(api.getCorsConfiguration()) + ",\n" +
|
|
||||||
" \"websubSubscriptionConfiguration\": {\n" +
|
|
||||||
" \"enable\": false,\n" +
|
|
||||||
" \"secret\": \"\",\n" +
|
|
||||||
" \"signingAlgorithm\": \"SHA1\",\n" +
|
|
||||||
" \"signatureHeader\": \"x-hub-signature\"\n" +
|
|
||||||
" },\n" +
|
|
||||||
" \"workflowStatus\": null,\n" +
|
|
||||||
" \"endpointConfig\": " + api.getEndpointConfig().toString() + ",\n" +
|
|
||||||
" \"endpointImplementationType\": \"ENDPOINT\",\n" +
|
|
||||||
" \"scopes\": " + api.getScopes().toString() + ",\n" +
|
|
||||||
" \"operations\": " + (api.getOperations() != null ? api.getOperations().toString() : null) + ",\n" +
|
|
||||||
" \"threatProtectionPolicies\": null,\n" +
|
|
||||||
" \"categories\": [],\n" +
|
|
||||||
" \"keyManagers\": " + gson.toJson(api.getKeyManagers()) + ",\n" +
|
|
||||||
" \"serviceInfo\": " + api.getServiceInfo() + "\n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
RequestBody requestBody = RequestBody.create(JSON, apiString);
|
//Lists
|
||||||
|
if (api.getTransport() != null) {
|
||||||
|
JSONArray transport = new JSONArray();
|
||||||
|
for (String str : api.getTransport()) {
|
||||||
|
transport.put(str);
|
||||||
|
}
|
||||||
|
payload.put("transport", transport);
|
||||||
|
}
|
||||||
|
if (api.getTags() != null) {
|
||||||
|
JSONArray tags = new JSONArray();
|
||||||
|
for (String str : api.getTags()) {
|
||||||
|
tags.put(str);
|
||||||
|
}
|
||||||
|
payload.put("tags", tags);
|
||||||
|
}
|
||||||
|
if (api.getPolicies() != null) {
|
||||||
|
JSONArray policies = new JSONArray();
|
||||||
|
for (String str : api.getPolicies()) {
|
||||||
|
policies.put(str);
|
||||||
|
}
|
||||||
|
payload.put("policies", policies);
|
||||||
|
}
|
||||||
|
if (api.getMediationPolicies() != null) {
|
||||||
|
JSONArray mediationPolicies = new JSONArray();
|
||||||
|
for (MediationPolicy object : api.getMediationPolicies()) {
|
||||||
|
mediationPolicies.put(new JSONObject(gson.toJson(object)));
|
||||||
|
}
|
||||||
|
payload.put("mediationPolicies", mediationPolicies);
|
||||||
|
}
|
||||||
|
if (api.getSubscriptionAvailableTenants() != null) {
|
||||||
|
JSONArray subscriptionAvailableTenants = new JSONArray();
|
||||||
|
for (String str : api.getSubscriptionAvailableTenants()) {
|
||||||
|
subscriptionAvailableTenants.put(str);
|
||||||
|
}
|
||||||
|
payload.put("subscriptionAvailableTenants", subscriptionAvailableTenants);
|
||||||
|
}
|
||||||
|
if (api.getAdditionalProperties() != null) {
|
||||||
|
JSONArray additionalProperties = new JSONArray();
|
||||||
|
for (AdditionalProperties str : api.getAdditionalProperties()) {
|
||||||
|
additionalProperties.put(str);
|
||||||
|
}
|
||||||
|
payload.put("additionalProperties", additionalProperties);
|
||||||
|
}
|
||||||
|
if (api.getScopes() != null) {
|
||||||
|
JSONArray scopes = new JSONArray();
|
||||||
|
for (JSONObject object : api.getScopes()) {
|
||||||
|
scopes.put(object);
|
||||||
|
}
|
||||||
|
payload.put("scopes", scopes);
|
||||||
|
}
|
||||||
|
if (api.getOperations() != null) {
|
||||||
|
JSONArray operations = new JSONArray();
|
||||||
|
for (Operations operation : api.getOperations()) {
|
||||||
|
operations.put(new JSONObject(gson.toJson(operation)));
|
||||||
|
}
|
||||||
|
payload.put("operations", operations);
|
||||||
|
}
|
||||||
|
if (api.getCategories() != null) {
|
||||||
|
JSONArray categories = new JSONArray();
|
||||||
|
for (String str : api.getCategories()) {
|
||||||
|
categories.put(str);
|
||||||
|
}
|
||||||
|
payload.put("categories", categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
//objects
|
||||||
|
payload.put("monetization", (api.getMonetization() != null ? new JSONObject(gson.toJson(api.getMonetization())) : null));
|
||||||
|
payload.put("corsConfiguration", (api.getCorsConfiguration() != null ? new JSONObject(gson.toJson(api.getCorsConfiguration())) : null));
|
||||||
|
payload.put("websubSubscriptionConfiguration", (api.getWebsubSubscriptionConfiguration() != null ? new JSONObject(gson.toJson(api.getWebsubSubscriptionConfiguration())) : null));
|
||||||
|
payload.put("workflowStatus", (api.getWorkflowStatus() != null ? api.getWorkflowStatus() : null));
|
||||||
|
payload.put("endpointConfig", (api.getEndpointConfig() != null ? api.getEndpointConfig() : null));
|
||||||
|
payload.put("endpointImplementationType", (api.getEndpointImplementationType() != null ? api.getEndpointImplementationType() : null));
|
||||||
|
payload.put("threatProtectionPolicies", (api.getThreatProtectionPolicies() != null ? api.getThreatProtectionPolicies() : null));
|
||||||
|
payload.put("serviceInfo", (api.getServiceInfo() != null ? new JSONObject(gson.toJson(api.getServiceInfo())) : null));
|
||||||
|
payload.put("advertiseInfo", (api.getAdvertiseInfo() != null ? new JSONObject(gson.toJson(api.getAdvertiseInfo())) : null));
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(JSON, payload.toString());
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(addAPIEndPoint)
|
.url(addAPIEndPoint)
|
||||||
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER
|
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER
|
||||||
@ -383,8 +433,7 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
try {
|
try {
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
if (HttpStatus.SC_CREATED == response.code()) {
|
if (HttpStatus.SC_CREATED == response.code()) {
|
||||||
JSONObject jsonObject = new JSONObject(response.body().string());
|
return gson.fromJson(response.body().string(), APIInfo.class);
|
||||||
return jsonObject;
|
|
||||||
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
||||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||||
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
||||||
@ -413,54 +462,106 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
|
|
||||||
String updateAPIEndPoint = endPointPrefix + Constants.API_ENDPOINT + api.getId();
|
String updateAPIEndPoint = endPointPrefix + Constants.API_ENDPOINT + api.getId();
|
||||||
|
|
||||||
String apiString = "{\n" +
|
JSONObject payload = new JSONObject();
|
||||||
" \"name\": \"" + api.getName() + "\",\n" +
|
payload.put("name", api.getName());
|
||||||
" \"description\":\"" + api.getDescription() + "\",\n" +
|
payload.put("description", api.getDescription());
|
||||||
" \"context\":\"" + api.getContext() + "\",\n" +
|
payload.put("context", api.getContext());
|
||||||
" \"version\":\"" + api.getVersion() + "\",\n" +
|
payload.put("version", api.getVersion());
|
||||||
" \"provider\":\"" + api.getProvider() + "\",\n" +
|
payload.put("provider", api.getProvider());
|
||||||
" \"lifeCycleStatus\":\"" + api.getLifeCycleStatus() + "\",\n" +
|
payload.put("lifeCycleStatus", api.getLifeCycleStatus());
|
||||||
" \"wsdlInfo\": " + api.getWsdlInfo() + ",\n" +
|
payload.put("wsdlInfo", (api.getWsdlInfo() != null ? api.getWsdlInfo() : null));
|
||||||
" \"wsdlUrl\":" + api.getWsdlUrl() + ",\n" +
|
payload.put("wsdlUrl", (api.getWsdlUrl() != null ? api.getWsdlUrl() : null));
|
||||||
" \"responseCachingEnabled\": " + api.isResponseCachingEnabled() + ",\n" +
|
payload.put("responseCachingEnabled", api.isResponseCachingEnabled());
|
||||||
" \"cacheTimeout\": " + api.getCacheTimeout() + ",\n" +
|
payload.put("cacheTimeout", api.getCacheTimeout());
|
||||||
" \"hasThumbnail\": " + api.isHasThumbnail() + ",\n" +
|
payload.put("hasThumbnail", api.isHasThumbnail());
|
||||||
" \"isDefaultVersion\": " + api.isDefaultVersion() + ",\n" +
|
payload.put("isDefaultVersion", api.isDefaultVersion());
|
||||||
" \"isRevision\": " + api.isRevision() + ",\n" +
|
payload.put("isRevision", api.isRevision());
|
||||||
" \"revisionedApiId\": " + api.getRevisionedApiId() + ",\n" +
|
payload.put("revisionedApiId", (api.getRevisionedApiId() != null ? api.getRevisionedApiId() : null));
|
||||||
" \"revisionId\": " + api.getRevisionId() + ",\n" +
|
payload.put("revisionId", api.getRevisionId());
|
||||||
" \"enableSchemaValidation\": " + api.isEnableSchemaValidation() + ",\n" +
|
payload.put("enableSchemaValidation", api.isEnableSchemaValidation());
|
||||||
" \"type\": \"" + api.getType() + "\",\n" +
|
payload.put("type", api.getType());
|
||||||
" \"transport\": " + gson.toJson(api.getTransport()) + ",\n" +
|
payload.put("apiThrottlingPolicy", api.getApiThrottlingPolicy());
|
||||||
" \"tags\": " + gson.toJson(api.getTags()) + ",\n" +
|
payload.put("authorizationHeader", api.getAuthorizationHeader());
|
||||||
" \"policies\": " + gson.toJson(api.getPolicies()) + ",\n" +
|
payload.put("visibility", api.getVisibility());
|
||||||
" \"apiThrottlingPolicy\": " + api.getApiThrottlingPolicy() + ",\n" +
|
payload.put("subscriptionAvailability", (api.getSubscriptionAvailability() != null ? api.getSubscriptionAvailability() : ""));
|
||||||
" \"authorizationHeader\": \"" + api.getAuthorizationHeader() + "\",\n" +
|
|
||||||
" \"visibility\": \"" + api.getVisibility() + "\",\n" +
|
|
||||||
" \"mediationPolicies\": " + (api.getInSequence() != null ? "[{\"name\": \"" + api.getInSequence() + "\",\"type\": \"in\"}]" : null) + ",\n" +
|
|
||||||
" \"subscriptionAvailability\": \"" + api.getSubscriptionAvailability() + "\",\n" +
|
|
||||||
" \"subscriptionAvailableTenants\": [],\n" +
|
|
||||||
" \"additionalProperties\": [],\n" +
|
|
||||||
" \"monetization\": " + api.getMonetization() + ",\n" +
|
|
||||||
" \"corsConfiguration\": " + gson.toJson(api.getCorsConfiguration()) + ",\n" +
|
|
||||||
" \"websubSubscriptionConfiguration\": {\n" +
|
|
||||||
" \"enable\": false,\n" +
|
|
||||||
" \"secret\": \"\",\n" +
|
|
||||||
" \"signingAlgorithm\": \"SHA1\",\n" +
|
|
||||||
" \"signatureHeader\": \"x-hub-signature\"\n" +
|
|
||||||
" },\n" +
|
|
||||||
" \"workflowStatus\": null,\n" +
|
|
||||||
" \"endpointConfig\": " + api.getEndpointConfig().toString() + ",\n" +
|
|
||||||
" \"endpointImplementationType\": \"ENDPOINT\",\n" +
|
|
||||||
" \"scopes\": " + api.getScopes().toString() + ",\n" +
|
|
||||||
" \"operations\": " + (api.getOperations() != null ? api.getOperations().toString() : null) + ",\n" +
|
|
||||||
" \"threatProtectionPolicies\": null,\n" +
|
|
||||||
" \"categories\": [],\n" +
|
|
||||||
" \"keyManagers\": " + gson.toJson(api.getKeyManagers()) + ",\n" +
|
|
||||||
" \"serviceInfo\": " + api.getServiceInfo() + "\n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
RequestBody requestBody = RequestBody.create(JSON, apiString);
|
//Lists
|
||||||
|
if (api.getTransport() != null) {
|
||||||
|
JSONArray transport = new JSONArray();
|
||||||
|
for (String str : api.getTransport()) {
|
||||||
|
transport.put(str);
|
||||||
|
}
|
||||||
|
payload.put("transport", transport);
|
||||||
|
}
|
||||||
|
if (api.getTags() != null) {
|
||||||
|
JSONArray tags = new JSONArray();
|
||||||
|
for (String str : api.getTags()) {
|
||||||
|
tags.put(str);
|
||||||
|
}
|
||||||
|
payload.put("tags", tags);
|
||||||
|
}
|
||||||
|
if (api.getPolicies() != null) {
|
||||||
|
JSONArray policies = new JSONArray();
|
||||||
|
for (String str : api.getPolicies()) {
|
||||||
|
policies.put(str);
|
||||||
|
}
|
||||||
|
payload.put("policies", policies);
|
||||||
|
}
|
||||||
|
if (api.getMediationPolicies() != null) {
|
||||||
|
JSONArray mediationPolicies = new JSONArray();
|
||||||
|
for (MediationPolicy object : api.getMediationPolicies()) {
|
||||||
|
mediationPolicies.put(new JSONObject(gson.toJson(object)));
|
||||||
|
}
|
||||||
|
payload.put("mediationPolicies", mediationPolicies);
|
||||||
|
}
|
||||||
|
if (api.getSubscriptionAvailableTenants() != null) {
|
||||||
|
JSONArray subscriptionAvailableTenants = new JSONArray();
|
||||||
|
for (String str : api.getSubscriptionAvailableTenants()) {
|
||||||
|
subscriptionAvailableTenants.put(str);
|
||||||
|
}
|
||||||
|
payload.put("subscriptionAvailableTenants", subscriptionAvailableTenants);
|
||||||
|
}
|
||||||
|
if (api.getAdditionalProperties() != null) {
|
||||||
|
JSONArray additionalProperties = new JSONArray();
|
||||||
|
for (AdditionalProperties str : api.getAdditionalProperties()) {
|
||||||
|
additionalProperties.put(str);
|
||||||
|
}
|
||||||
|
payload.put("additionalProperties", additionalProperties);
|
||||||
|
}
|
||||||
|
if (api.getScopes() != null) {
|
||||||
|
JSONArray scopes = new JSONArray();
|
||||||
|
for (JSONObject object : api.getScopes()) {
|
||||||
|
scopes.put(object);
|
||||||
|
}
|
||||||
|
payload.put("scopes", scopes);
|
||||||
|
}
|
||||||
|
if (api.getOperations() != null) {
|
||||||
|
JSONArray operations = new JSONArray();
|
||||||
|
for (Operations operation : api.getOperations()) {
|
||||||
|
operations.put(new JSONObject(gson.toJson(operation)));
|
||||||
|
}
|
||||||
|
payload.put("operations", operations);
|
||||||
|
}
|
||||||
|
if (api.getCategories() != null) {
|
||||||
|
JSONArray categories = new JSONArray();
|
||||||
|
for (String str : api.getCategories()) {
|
||||||
|
categories.put(str);
|
||||||
|
}
|
||||||
|
payload.put("categories", categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
//objects
|
||||||
|
payload.put("monetization", (api.getMonetization() != null ? new JSONObject(gson.toJson(api.getMonetization())) : null));
|
||||||
|
payload.put("corsConfiguration", (api.getCorsConfiguration() != null ? new JSONObject(gson.toJson(api.getCorsConfiguration())) : null));
|
||||||
|
payload.put("websubSubscriptionConfiguration", (api.getWebsubSubscriptionConfiguration() != null ? new JSONObject(gson.toJson(api.getWebsubSubscriptionConfiguration())) : null));
|
||||||
|
payload.put("workflowStatus", (api.getWorkflowStatus() != null ? api.getWorkflowStatus() : null));
|
||||||
|
payload.put("endpointConfig", (api.getEndpointConfig() != null ? api.getEndpointConfig() : null));
|
||||||
|
payload.put("endpointImplementationType", (api.getEndpointImplementationType() != null ? api.getEndpointImplementationType() : null));
|
||||||
|
payload.put("threatProtectionPolicies", (api.getThreatProtectionPolicies() != null ? api.getThreatProtectionPolicies() : null));
|
||||||
|
payload.put("serviceInfo", (api.getServiceInfo() != null ? new JSONObject(gson.toJson(api.getServiceInfo())) : null));
|
||||||
|
payload.put("advertiseInfo", (api.getAdvertiseInfo() != null ? new JSONObject(gson.toJson(api.getAdvertiseInfo())) : null));
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(JSON, payload.toString());
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(updateAPIEndPoint)
|
.url(updateAPIEndPoint)
|
||||||
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER
|
.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER
|
||||||
@ -472,7 +573,6 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices {
|
|||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
if (HttpStatus.SC_OK == response.code()) {
|
if (HttpStatus.SC_OK == response.code()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
} else if (HttpStatus.SC_UNAUTHORIZED == response.code()) {
|
||||||
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl();
|
||||||
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
AccessTokenInfo refreshedAccessToken = apiApplicationServices.
|
||||||
|
|||||||
@ -20,7 +20,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
|||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the API response.
|
* This class represents the API response.
|
||||||
@ -35,69 +35,75 @@ public class APIInfo {
|
|||||||
private String version;
|
private String version;
|
||||||
private String provider;
|
private String provider;
|
||||||
private String lifeCycleStatus;
|
private String lifeCycleStatus;
|
||||||
private String wsdlInfo;
|
private type wsdlInfo;
|
||||||
private String wsdlUrl;
|
private String wsdlUrl;
|
||||||
private boolean responseCachingEnabled;
|
private boolean responseCachingEnabled;
|
||||||
private int cacheTimeout;
|
private int cacheTimeout;
|
||||||
private boolean hasThumbnail;
|
private boolean hasThumbnail;
|
||||||
private boolean isDefaultVersion;
|
private boolean isDefaultVersion;
|
||||||
private boolean isRevision;
|
private boolean isRevision;
|
||||||
private String revisionedApiId;
|
private String revisionedApiId;
|
||||||
private int revisionId;
|
private int revisionId;
|
||||||
private boolean enableSchemaValidation;
|
private boolean enableSchemaValidation;
|
||||||
|
private boolean enableStore;
|
||||||
private String type;
|
private String type;
|
||||||
private Set<String> transport;
|
private List<String> transport;
|
||||||
private Set<String> tags;
|
private List<String> tags;
|
||||||
private Set<String> policies;
|
private List<String> policies;
|
||||||
private String apiThrottlingPolicy;
|
private String apiThrottlingPolicy;
|
||||||
private String authorizationHeader;
|
private String authorizationHeader;
|
||||||
private String securityScheme;
|
private List<String> securityScheme;
|
||||||
private String maxTps;
|
private APIMaxTps maxTps;
|
||||||
private String visibility;
|
private String visibility;
|
||||||
private String visibleRoles;
|
private List<String> visibleRoles;
|
||||||
private String visibleTenants;
|
private List<String> visibleTenants;
|
||||||
private String mediationPolicies;
|
private List<MediationPolicy> mediationPolicies;
|
||||||
private String subscriptionAvailability;
|
private String subscriptionAvailability;
|
||||||
private String subscriptionAvailableTenants;
|
private List<String> subscriptionAvailableTenants;
|
||||||
private String additionalProperties;
|
private List<AdditionalProperties> additionalProperties;
|
||||||
private String monetization;
|
private Monetization monetization;
|
||||||
private String accessControl;
|
private String accessControl;
|
||||||
private String accessControlRoles;
|
private List<String> accessControlRoles;
|
||||||
private BusinessInformation businessInformation;
|
private BusinessInformation businessInformation;
|
||||||
private CORSConfiguration corsConfiguration;
|
private CORSConfiguration corsConfiguration;
|
||||||
|
private WebsubSubscriptionConfiguration websubSubscriptionConfiguration;
|
||||||
private String workflowStatus;
|
private String workflowStatus;
|
||||||
private String createdTime;
|
private String createdTime;
|
||||||
private String lastUpdatedTime;
|
private String lastUpdatedTime;
|
||||||
private JSONObject endpointConfig = new JSONObject();
|
private JSONObject endpointConfig;
|
||||||
private String endpointImplementationType;
|
private String endpointImplementationType;
|
||||||
private List<JSONObject> scopes = new ArrayList();
|
private List<JSONObject> scopes;
|
||||||
private List<JSONObject> operations;
|
private List<Operations> operations;
|
||||||
private String threatProtectionPolicies;
|
private JSONObject threatProtectionPolicies;
|
||||||
private List<String> keyManagers = new ArrayList();
|
private List<String> categories;
|
||||||
private JSONObject serviceInfo = new JSONObject();
|
private List<String> keyManagers;
|
||||||
|
private ServiceInfo serviceInfo;
|
||||||
private AdvertiseInfo advertiseInfo;
|
private AdvertiseInfo advertiseInfo;
|
||||||
|
|
||||||
private String asyncApiDefinition;
|
public enum type {
|
||||||
|
WSDL, ZIP
|
||||||
|
}
|
||||||
|
|
||||||
private Set<URITemplate> uriTemplates = new LinkedHashSet<URITemplate>();
|
|
||||||
private String inSequence;
|
|
||||||
|
|
||||||
private Map<String, String> wsUriMapping;
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
@ -109,12 +115,15 @@ public class APIInfo {
|
|||||||
public void setContext(String context) {
|
public void setContext(String context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersion(String version) {
|
public void setVersion(String version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProvider() {
|
public String getProvider() {
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
@ -131,11 +140,11 @@ public class APIInfo {
|
|||||||
this.lifeCycleStatus = lifeCycleStatus;
|
this.lifeCycleStatus = lifeCycleStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWsdlInfo() {
|
public APIInfo.type getWsdlInfo() {
|
||||||
return wsdlInfo;
|
return wsdlInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWsdlInfo(String wsdlInfo) {
|
public void setWsdlInfo(APIInfo.type wsdlInfo) {
|
||||||
this.wsdlInfo = wsdlInfo;
|
this.wsdlInfo = wsdlInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +220,14 @@ public class APIInfo {
|
|||||||
this.enableSchemaValidation = enableSchemaValidation;
|
this.enableSchemaValidation = enableSchemaValidation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnableStore() {
|
||||||
|
return enableStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnableStore(boolean enableStore) {
|
||||||
|
this.enableStore = enableStore;
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@ -219,27 +236,27 @@ public class APIInfo {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getTransport() {
|
public List<String> getTransport() {
|
||||||
return transport;
|
return transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransport(Set<String> transport) {
|
public void setTransport(List<String> transport) {
|
||||||
this.transport = transport;
|
this.transport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getTags() {
|
public List<String> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTags(Set<String> tags) {
|
public void setTags(List<String> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPolicies() {
|
public List<String> getPolicies() {
|
||||||
return policies;
|
return policies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPolicies(Set<String> policies) {
|
public void setPolicies(List<String> policies) {
|
||||||
this.policies = policies;
|
this.policies = policies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,19 +276,19 @@ public class APIInfo {
|
|||||||
this.authorizationHeader = authorizationHeader;
|
this.authorizationHeader = authorizationHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSecurityScheme() {
|
public List<String> getSecurityScheme() {
|
||||||
return securityScheme;
|
return securityScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecurityScheme(String securityScheme) {
|
public void setSecurityScheme(List<String> securityScheme) {
|
||||||
this.securityScheme = securityScheme;
|
this.securityScheme = securityScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMaxTps() {
|
public APIMaxTps getMaxTps() {
|
||||||
return maxTps;
|
return maxTps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxTps(String maxTps) {
|
public void setMaxTps(APIMaxTps maxTps) {
|
||||||
this.maxTps = maxTps;
|
this.maxTps = maxTps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,27 +300,27 @@ public class APIInfo {
|
|||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVisibleRoles() {
|
public List<String> getVisibleRoles() {
|
||||||
return visibleRoles;
|
return visibleRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisibleRoles(String visibleRoles) {
|
public void setVisibleRoles(List<String> visibleRoles) {
|
||||||
this.visibleRoles = visibleRoles;
|
this.visibleRoles = visibleRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVisibleTenants() {
|
public List<String> getVisibleTenants() {
|
||||||
return visibleTenants;
|
return visibleTenants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisibleTenants(String visibleTenants) {
|
public void setVisibleTenants(List<String> visibleTenants) {
|
||||||
this.visibleTenants = visibleTenants;
|
this.visibleTenants = visibleTenants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMediationPolicies() {
|
public List<MediationPolicy> getMediationPolicies() {
|
||||||
return mediationPolicies;
|
return mediationPolicies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMediationPolicies(String mediationPolicies) {
|
public void setMediationPolicies(List<MediationPolicy> mediationPolicies) {
|
||||||
this.mediationPolicies = mediationPolicies;
|
this.mediationPolicies = mediationPolicies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,27 +332,27 @@ public class APIInfo {
|
|||||||
this.subscriptionAvailability = subscriptionAvailability;
|
this.subscriptionAvailability = subscriptionAvailability;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubscriptionAvailableTenants() {
|
public List<String> getSubscriptionAvailableTenants() {
|
||||||
return subscriptionAvailableTenants;
|
return subscriptionAvailableTenants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubscriptionAvailableTenants(String subscriptionAvailableTenants) {
|
public void setSubscriptionAvailableTenants(List<String> subscriptionAvailableTenants) {
|
||||||
this.subscriptionAvailableTenants = subscriptionAvailableTenants;
|
this.subscriptionAvailableTenants = subscriptionAvailableTenants;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAdditionalProperties() {
|
public List<AdditionalProperties> getAdditionalProperties() {
|
||||||
return additionalProperties;
|
return additionalProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdditionalProperties(String additionalProperties) {
|
public void setAdditionalProperties(List<AdditionalProperties> additionalProperties) {
|
||||||
this.additionalProperties = additionalProperties;
|
this.additionalProperties = additionalProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMonetization() {
|
public Monetization getMonetization() {
|
||||||
return monetization;
|
return monetization;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMonetization(String monetization) {
|
public void setMonetization(Monetization monetization) {
|
||||||
this.monetization = monetization;
|
this.monetization = monetization;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,11 +364,11 @@ public class APIInfo {
|
|||||||
this.accessControl = accessControl;
|
this.accessControl = accessControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessControlRoles() {
|
public List<String> getAccessControlRoles() {
|
||||||
return accessControlRoles;
|
return accessControlRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccessControlRoles(String accessControlRoles) {
|
public void setAccessControlRoles(List<String> accessControlRoles) {
|
||||||
this.accessControlRoles = accessControlRoles;
|
this.accessControlRoles = accessControlRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,6 +388,14 @@ public class APIInfo {
|
|||||||
this.corsConfiguration = corsConfiguration;
|
this.corsConfiguration = corsConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WebsubSubscriptionConfiguration getWebsubSubscriptionConfiguration() {
|
||||||
|
return websubSubscriptionConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWebsubSubscriptionConfiguration(WebsubSubscriptionConfiguration websubSubscriptionConfiguration) {
|
||||||
|
this.websubSubscriptionConfiguration = websubSubscriptionConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
public String getWorkflowStatus() {
|
public String getWorkflowStatus() {
|
||||||
return workflowStatus;
|
return workflowStatus;
|
||||||
}
|
}
|
||||||
@ -411,7 +436,7 @@ public class APIInfo {
|
|||||||
this.endpointImplementationType = endpointImplementationType;
|
this.endpointImplementationType = endpointImplementationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JSONObject>getScopes() {
|
public List<JSONObject> getScopes() {
|
||||||
return scopes;
|
return scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,22 +444,30 @@ public class APIInfo {
|
|||||||
this.scopes = scopes;
|
this.scopes = scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JSONObject> getOperations() {
|
public List<Operations> getOperations() {
|
||||||
return operations;
|
return operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOperations(List<JSONObject> operations) {
|
public void setOperations(List<Operations> operations) {
|
||||||
this.operations = operations;
|
this.operations = operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getThreatProtectionPolicies() {
|
public JSONObject getThreatProtectionPolicies() {
|
||||||
return threatProtectionPolicies;
|
return threatProtectionPolicies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThreatProtectionPolicies(String threatProtectionPolicies) {
|
public void setThreatProtectionPolicies(JSONObject threatProtectionPolicies) {
|
||||||
this.threatProtectionPolicies = threatProtectionPolicies;
|
this.threatProtectionPolicies = threatProtectionPolicies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getCategories() {
|
||||||
|
return categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategories(List<String> categories) {
|
||||||
|
this.categories = categories;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getKeyManagers() {
|
public List<String> getKeyManagers() {
|
||||||
return keyManagers;
|
return keyManagers;
|
||||||
}
|
}
|
||||||
@ -443,11 +476,11 @@ public class APIInfo {
|
|||||||
this.keyManagers = keyManagers;
|
this.keyManagers = keyManagers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getServiceInfo() {
|
public ServiceInfo getServiceInfo() {
|
||||||
return serviceInfo;
|
return serviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceInfo(JSONObject serviceInfo) {
|
public void setServiceInfo(ServiceInfo serviceInfo) {
|
||||||
this.serviceInfo = serviceInfo;
|
this.serviceInfo = serviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,36 +491,4 @@ public class APIInfo {
|
|||||||
public void setAdvertiseInfo(AdvertiseInfo advertiseInfo) {
|
public void setAdvertiseInfo(AdvertiseInfo advertiseInfo) {
|
||||||
this.advertiseInfo = advertiseInfo;
|
this.advertiseInfo = advertiseInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInSequence() {
|
|
||||||
return inSequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInSequence(String inSequence) {
|
|
||||||
this.inSequence = inSequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAsyncApiDefinition() {
|
|
||||||
return asyncApiDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAsyncApiDefinition(String asyncApiDefinition) {
|
|
||||||
this.asyncApiDefinition = asyncApiDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<URITemplate> getUriTemplates() {
|
|
||||||
return uriTemplates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUriTemplates(Set<URITemplate> uriTemplates) {
|
|
||||||
this.uriTemplates = uriTemplates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getWsUriMapping() {
|
|
||||||
return wsUriMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWsUriMapping(Map<String, String> wsUriMapping) {
|
|
||||||
this.wsUriMapping = wsUriMapping;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class APIMaxTps implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
int production;
|
||||||
|
int sandbox;
|
||||||
|
|
||||||
|
public int getProduction() {
|
||||||
|
return production;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduction(int production) {
|
||||||
|
this.production = production;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSandbox() {
|
||||||
|
return sandbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSandbox(int sandbox) {
|
||||||
|
this.sandbox = sandbox;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
|
public class AdditionalProperties {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
private boolean display;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisplay() {
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplay(boolean display) {
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
|
public class MediationPolicy {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String type;
|
||||||
|
private boolean shared;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShared() {
|
||||||
|
return shared;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShared(boolean shared) {
|
||||||
|
this.shared = shared;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class Monetization {
|
||||||
|
private boolean enabled;
|
||||||
|
private JSONObject properties;
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(JSONObject properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
import java.util.Set;
|
import org.json.JSONObject;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This hold the api operations information.
|
* This hold the api operations information.
|
||||||
@ -29,8 +30,8 @@ public class Operations {
|
|||||||
private String verb;
|
private String verb;
|
||||||
private String authType;
|
private String authType;
|
||||||
private String throttlingPolicy;
|
private String throttlingPolicy;
|
||||||
private Set<String> scopes;
|
private List<String> scopes;
|
||||||
private String usedProductIds;
|
private List<String> usedProductIds;
|
||||||
private String amznResourceName;
|
private String amznResourceName;
|
||||||
private String amznResourceTimeout;
|
private String amznResourceTimeout;
|
||||||
private String payloadSchema;
|
private String payloadSchema;
|
||||||
@ -78,19 +79,19 @@ public class Operations {
|
|||||||
this.throttlingPolicy = throttlingPolicy;
|
this.throttlingPolicy = throttlingPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getScopes() {
|
public List<String> getScopes() {
|
||||||
return scopes;
|
return scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScopes(Set<String> scopes) {
|
public void setScopes(List<String> scopes) {
|
||||||
this.scopes = scopes;
|
this.scopes = scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsedProductIds() {
|
public List<String> getUsedProductIds() {
|
||||||
return usedProductIds;
|
return usedProductIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsedProductIds(String usedProductIds) {
|
public void setUsedProductIds(List<String> usedProductIds) {
|
||||||
this.usedProductIds = usedProductIds;
|
this.usedProductIds = usedProductIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
|
public class ServiceInfo {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private String name;
|
||||||
|
private String version;
|
||||||
|
private boolean outdated;
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOutdated() {
|
||||||
|
return outdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutdated(boolean outdated) {
|
||||||
|
this.outdated = outdated;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
|
public class ThreatProtectionPolicies {
|
||||||
|
|
||||||
|
private String policyID;
|
||||||
|
private int priority;
|
||||||
|
|
||||||
|
public String getPolicyID() {
|
||||||
|
return policyID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolicyID(String policyID) {
|
||||||
|
this.policyID = policyID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriority(int priority) {
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This hold the Websub Subscription Configuration of an API.
|
||||||
|
*/
|
||||||
|
public class WebsubSubscriptionConfiguration {
|
||||||
|
private boolean enable;
|
||||||
|
private String secret;
|
||||||
|
private String signingAlgorithm;
|
||||||
|
private String signatureHeader;
|
||||||
|
|
||||||
|
public boolean isEnable() {
|
||||||
|
return enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnable(boolean enable) {
|
||||||
|
this.enable = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecret() {
|
||||||
|
return secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecret(String secret) {
|
||||||
|
this.secret = secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSigningAlgorithm() {
|
||||||
|
return signingAlgorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSigningAlgorithm(String signingAlgorithm) {
|
||||||
|
this.signingAlgorithm = signingAlgorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignatureHeader() {
|
||||||
|
return signatureHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignatureHeader(String signatureHeader) {
|
||||||
|
this.signatureHeader = signatureHeader;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -17,19 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
package io.entgra.device.mgt.core.apimgt.webapp.publisher;
|
package io.entgra.device.mgt.core.apimgt.webapp.publisher;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import io.entgra.device.mgt.core.apimgt.annotations.Scopes;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServices;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServices;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServicesImpl;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServicesImpl;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.APIInfo;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.*;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.Scope;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.Mediation;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.Documentation;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.APIRevision;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.APIRevisionDeployment;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.CORSConfiguration;
|
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException;
|
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException;
|
||||||
@ -91,6 +87,7 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
public class APIPublisherServiceImpl implements APIPublisherService {
|
public class APIPublisherServiceImpl implements APIPublisherService {
|
||||||
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
|
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
|
||||||
|
private static final Gson gson = new Gson();
|
||||||
private static final String UNLIMITED_TIER = "Unlimited";
|
private static final String UNLIMITED_TIER = "Unlimited";
|
||||||
private static final String WS_UNLIMITED_TIER = "AsyncUnlimited";
|
private static final String WS_UNLIMITED_TIER = "AsyncUnlimited";
|
||||||
private static final String API_PUBLISH_ENVIRONMENT = "Default";
|
private static final String API_PUBLISH_ENVIRONMENT = "Default";
|
||||||
@ -166,14 +163,14 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
apiConfig.getName(), apiConfig.getVersion());
|
apiConfig.getName(), apiConfig.getVersion());
|
||||||
|
|
||||||
PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServicesImpl();
|
PublisherRESTAPIServices publisherRESTAPIServices = new PublisherRESTAPIServicesImpl();
|
||||||
JSONArray apiList = (JSONArray) publisherRESTAPIServices.getApis(apiApplicationKey, accessTokenInfo).get("list");
|
APIInfo[] apiList = publisherRESTAPIServices.getApis(apiApplicationKey, accessTokenInfo);
|
||||||
boolean apiFound = false;
|
boolean apiFound = false;
|
||||||
for (int i = 0; i < apiList.length(); i++) {
|
for (int i = 0; i < apiList.length; i++) {
|
||||||
JSONObject apiObj = apiList.getJSONObject(i);
|
APIInfo apiObj = apiList[i];
|
||||||
if (apiObj.getString("name").equals(apiIdentifier.getApiName().replace(Constants.SPACE,
|
if (apiObj.getName().equals(apiIdentifier.getApiName().replace(Constants.SPACE,
|
||||||
Constants.EMPTY_STRING))) {
|
Constants.EMPTY_STRING))) {
|
||||||
apiFound = true;
|
apiFound = true;
|
||||||
apiIdentifier.setUuid(apiObj.getString("id"));
|
apiIdentifier.setUuid(apiObj.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,13 +191,13 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
APIInfo api = getAPI(apiConfig, true);
|
APIInfo api = getAPI(apiConfig, true);
|
||||||
JSONObject createdAPI = publisherRESTAPIServices.addAPI(apiApplicationKey, accessTokenInfo, api);
|
APIInfo createdAPI = publisherRESTAPIServices.addAPI(apiApplicationKey, accessTokenInfo, api);
|
||||||
apiUuid = createdAPI.getString("id");
|
apiUuid = createdAPI.getId();
|
||||||
if (apiConfig.getEndpointType() != null && "WS".equals(apiConfig.getEndpointType())) {
|
if (apiConfig.getEndpointType() != null && "WS".equals(apiConfig.getEndpointType())) {
|
||||||
publisherRESTAPIServices.saveAsyncApiDefinition(apiApplicationKey, accessTokenInfo,
|
publisherRESTAPIServices.saveAsyncApiDefinition(apiApplicationKey, accessTokenInfo,
|
||||||
apiUuid, apiConfig.getAsyncApiDefinition());
|
apiUuid, apiConfig.getAsyncApiDefinition());
|
||||||
}
|
}
|
||||||
if (CREATED_STATUS.equals(createdAPI.getString("lifeCycleStatus"))) {
|
if (CREATED_STATUS.equals(createdAPI.getLifeCycleStatus())) {
|
||||||
// if endpoint type "dynamic" and then add in sequence
|
// if endpoint type "dynamic" and then add in sequence
|
||||||
if ("dynamic".equals(apiConfig.getEndpointType())) {
|
if ("dynamic".equals(apiConfig.getEndpointType())) {
|
||||||
Mediation mediation = new Mediation();
|
Mediation mediation = new Mediation();
|
||||||
@ -272,12 +269,12 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get existing API
|
// Get existing API
|
||||||
JSONObject existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo,
|
APIInfo existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo,
|
||||||
apiUuid);
|
apiUuid);
|
||||||
if (scopesToMoveAsSharedScopes.size() > 0) {
|
if (scopesToMoveAsSharedScopes.size() > 0) {
|
||||||
// update API to remove local scopes
|
// update API to remove local scopes
|
||||||
APIInfo api = getAPI(apiConfig, false);
|
APIInfo api = getAPI(apiConfig, false);
|
||||||
api.setLifeCycleStatus(existingAPI.getString("lifeCycleStatus"));
|
api.setLifeCycleStatus(existingAPI.getLifeCycleStatus());
|
||||||
publisherRESTAPIServices.updateApi(apiApplicationKey, accessTokenInfo, api);
|
publisherRESTAPIServices.updateApi(apiApplicationKey, accessTokenInfo, api);
|
||||||
|
|
||||||
for (ApiScope apiScope : scopesToMoveAsSharedScopes) {
|
for (ApiScope apiScope : scopesToMoveAsSharedScopes) {
|
||||||
@ -294,7 +291,7 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
|
|
||||||
existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, apiUuid);
|
existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, apiUuid);
|
||||||
APIInfo api = getAPI(apiConfig, true);
|
APIInfo api = getAPI(apiConfig, true);
|
||||||
api.setLastUpdatedTime(existingAPI.getString("lifeCycleStatus"));
|
api.setLifeCycleStatus(existingAPI.getLifeCycleStatus());
|
||||||
api.setId(apiUuid);
|
api.setId(apiUuid);
|
||||||
publisherRESTAPIServices.updateApi(apiApplicationKey, accessTokenInfo, api);
|
publisherRESTAPIServices.updateApi(apiApplicationKey, accessTokenInfo, api);
|
||||||
|
|
||||||
@ -375,7 +372,7 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
publisherRESTAPIServices.deployAPIRevision(apiApplicationKey, accessTokenInfo,
|
publisherRESTAPIServices.deployAPIRevision(apiApplicationKey, accessTokenInfo,
|
||||||
apiUuid, apiRevisionId, apiRevisionDeploymentList);
|
apiUuid, apiRevisionId, apiRevisionDeploymentList);
|
||||||
|
|
||||||
if (CREATED_STATUS.equals(existingAPI.getString("lifeCycleStatus"))) {
|
if (CREATED_STATUS.equals(existingAPI.getLifeCycleStatus())) {
|
||||||
publisherRESTAPIServices.changeLifeCycleStatus(apiApplicationKey, accessTokenInfo,
|
publisherRESTAPIServices.changeLifeCycleStatus(apiApplicationKey, accessTokenInfo,
|
||||||
apiUuid, PUBLISH_ACTION);
|
apiUuid, PUBLISH_ACTION);
|
||||||
}
|
}
|
||||||
@ -779,55 +776,49 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
apiInfo.setRevisionedApiId(null);
|
apiInfo.setRevisionedApiId(null);
|
||||||
apiInfo.setEnableSchemaValidation(false);
|
apiInfo.setEnableSchemaValidation(false);
|
||||||
|
|
||||||
Set<String> tags = new HashSet<>();
|
List<String> tags = new ArrayList<>();
|
||||||
tags.addAll(Arrays.asList(config.getTags()));
|
tags.addAll(Arrays.asList(config.getTags()));
|
||||||
apiInfo.setTags(tags);
|
apiInfo.setTags(tags);
|
||||||
|
|
||||||
Set<String> availableTiers = new HashSet<>();
|
List<String> availableTiers = new ArrayList<>();
|
||||||
if (config.getEndpointType() != null && "WS".equals(config.getEndpointType())) {
|
if (config.getEndpointType() != null && "WS".equals(config.getEndpointType())) {
|
||||||
availableTiers.add(WS_UNLIMITED_TIER);
|
availableTiers.add(WS_UNLIMITED_TIER);
|
||||||
} else {
|
} else {
|
||||||
availableTiers.add(UNLIMITED_TIER);
|
availableTiers.add(UNLIMITED_TIER);
|
||||||
}
|
}
|
||||||
apiInfo.setPolicies(availableTiers);
|
apiInfo.setPolicies(availableTiers);
|
||||||
|
apiInfo.setApiThrottlingPolicy(UNLIMITED_TIER);
|
||||||
if (config.getEndpointType() != null && "WS".equals(config.getEndpointType())) {
|
|
||||||
apiInfo.setAsyncApiDefinition(config.getAsyncApiDefinition());
|
|
||||||
}
|
|
||||||
|
|
||||||
//set operations and scopes
|
//set operations and scopes
|
||||||
List<JSONObject> operations = new ArrayList();
|
List<Operations> operations = new ArrayList();
|
||||||
List<JSONObject> scopeSet = new ArrayList();
|
List<JSONObject> scopeSet = new ArrayList();
|
||||||
Iterator<ApiUriTemplate> iterator;
|
Iterator<ApiUriTemplate> iterator;
|
||||||
|
|
||||||
for (iterator = config.getUriTemplates().iterator(); iterator.hasNext(); ) {
|
for (iterator = config.getUriTemplates().iterator(); iterator.hasNext(); ) {
|
||||||
ApiUriTemplate apiUriTemplate = iterator.next();
|
ApiUriTemplate apiUriTemplate = iterator.next();
|
||||||
JSONObject operation = new JSONObject();
|
Operations operation = new Operations();
|
||||||
operation.put("target", apiUriTemplate.getUriTemplate());
|
operation.setTarget(apiUriTemplate.getUriTemplate());
|
||||||
operation.put("verb", apiUriTemplate.getHttpVerb());
|
operation.setVerb(apiUriTemplate.getHttpVerb());
|
||||||
operation.put("authType", apiUriTemplate.getAuthType());
|
operation.setAuthType(apiUriTemplate.getAuthType());
|
||||||
operation.put("throttlingPolicy", UNLIMITED_TIER);
|
operation.setThrottlingPolicy(UNLIMITED_TIER);
|
||||||
operation.put("uriMapping", apiUriTemplate.getUriMapping());
|
operation.setUriMapping(apiUriTemplate.getUriMapping());
|
||||||
if (includeScopes) {
|
if (includeScopes) {
|
||||||
if (apiUriTemplate.getScope() != null) {
|
if (apiUriTemplate.getScope() != null) {
|
||||||
String scopeString = "{\n" +
|
Scope scope = new Scope();
|
||||||
" \"scope\": {\n" +
|
scope.setName(apiUriTemplate.getScope().getKey());
|
||||||
" \"id\": null,\n" +
|
scope.setDisplayName(apiUriTemplate.getScope().getName());
|
||||||
" \"name\": \"" + apiUriTemplate.getScope().getKey() + "\",\n" +
|
scope.setDescription(apiUriTemplate.getScope().getDescription());
|
||||||
" \"displayName\": \"" + apiUriTemplate.getScope().getName() + "\",\n" +
|
scope.setBindings(apiUriTemplate.getScope().getRoles());
|
||||||
" \"description\": \"" + apiUriTemplate.getScope().getDescription() + "\",\n" +
|
|
||||||
" \"bindings\": [\n" +
|
|
||||||
" \"" + apiUriTemplate.getScope().getRoles() + "\"\n" +
|
|
||||||
" ],\n" +
|
|
||||||
" \"usageCount\": null\n" +
|
|
||||||
" },\n" +
|
|
||||||
" \"shared\": true\n" +
|
|
||||||
" }";
|
|
||||||
JSONObject scope = new JSONObject(scopeString);
|
|
||||||
scopeSet.add(scope);
|
|
||||||
|
|
||||||
Set<String> scopes = new HashSet<>();
|
JSONObject scopeObject = new JSONObject();
|
||||||
scopes.add(apiUriTemplate.getScope().getKey());
|
scopeObject.put("scope", new JSONObject(gson.toJson(scope)));
|
||||||
operation.put("scopes", scopes);
|
scopeObject.put("shared", true);
|
||||||
|
|
||||||
|
scopeSet.add(scopeObject);
|
||||||
|
|
||||||
|
List<String> scopes = new ArrayList<>();
|
||||||
|
scopes.addAll(Arrays.asList(apiUriTemplate.getScope().getKey()));
|
||||||
|
operation.setScopes(scopes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
operations.add(operation);
|
operations.add(operation);
|
||||||
@ -855,8 +846,8 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
" }";
|
" }";
|
||||||
JSONObject endPointConfig = new JSONObject(endpointConfig);
|
JSONObject endPointConfig = new JSONObject(endpointConfig);
|
||||||
|
|
||||||
Set<String> transports = new HashSet<>();
|
List<String> transports = new ArrayList<>();
|
||||||
transports.addAll(Arrays.asList(config.getTransports()));
|
transports.addAll(Arrays.asList(config.getTransports().split(",")));
|
||||||
apiInfo.setTransport(transports);
|
apiInfo.setTransport(transports);
|
||||||
|
|
||||||
apiInfo.setType("HTTP");
|
apiInfo.setType("HTTP");
|
||||||
@ -872,7 +863,7 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
" }\n" +
|
" }\n" +
|
||||||
" }";
|
" }";
|
||||||
endPointConfig = new JSONObject(endpointConfig);
|
endPointConfig = new JSONObject(endpointConfig);
|
||||||
apiInfo.setInSequence(config.getInSequenceName());
|
apiInfo.setEndpointImplementationType("ENDPOINT");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ws endpoint
|
// if ws endpoint
|
||||||
@ -888,7 +879,8 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
" }";
|
" }";
|
||||||
endPointConfig = new JSONObject(endpointConfig);
|
endPointConfig = new JSONObject(endpointConfig);
|
||||||
|
|
||||||
transports.addAll(Arrays.asList("wss,ws"));
|
transports.add("wss");
|
||||||
|
transports.add("ws");
|
||||||
apiInfo.setTransport(transports);
|
apiInfo.setTransport(transports);
|
||||||
apiInfo.setType("WS");
|
apiInfo.setType("WS");
|
||||||
}
|
}
|
||||||
@ -922,6 +914,8 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
|||||||
apiInfo.setEnableSchemaValidation(false);
|
apiInfo.setEnableSchemaValidation(false);
|
||||||
apiInfo.setMonetization(null);
|
apiInfo.setMonetization(null);
|
||||||
apiInfo.setServiceInfo(null);
|
apiInfo.setServiceInfo(null);
|
||||||
|
apiInfo.setWebsubSubscriptionConfiguration(null);
|
||||||
|
apiInfo.setAdvertiseInfo(null);
|
||||||
|
|
||||||
return apiInfo;
|
return apiInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user