use of org.apache.axis2.util.URL in project carbon-apimgt by wso2.
the class SolaceAdminApis method deleteApplication.
/**
* Delete application from Solace Broker
*
* @param organization name of the Organization
* @param uuid UUID of Application object to be deleted
* @return CloseableHttpResponse of the DELETE call
*/
public CloseableHttpResponse deleteApplication(String organization, String uuid) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpDelete httpDelete = new HttpDelete(baseUrl + "/" + organization + "/developers/" + developerUserName + "/apps/" + uuid);
httpDelete.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + getBase64EncodedCredentials());
try {
return APIUtil.executeHTTPRequest(httpDelete, httpClient);
} catch (IOException | APIManagementException e) {
log.error(e.getMessage());
}
return null;
}
use of org.apache.axis2.util.URL in project carbon-apimgt by wso2.
the class SolaceAdminApis method patchClientIdForApplication.
/**
* Patch client ID for Solace application
*
* @param organization name of the Organization
* @param application Application object to be renamed
* @param consumerKey Consumer key to be used when patching
* @param consumerSecret Consumer secret to be used when patching
* @return CloseableHttpResponse of the PATCH call
*/
public CloseableHttpResponse patchClientIdForApplication(String organization, Application application, String consumerKey, String consumerSecret) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpPatch httpPatch = new HttpPatch(baseUrl + "/" + organization + "/developers/" + developerUserName + "/apps/" + application.getUUID());
httpPatch.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + getBase64EncodedCredentials());
httpPatch.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
org.json.JSONObject requestBody = buildRequestBodyForClientIdPatch(application, consumerKey, consumerSecret);
StringEntity params = null;
try {
params = new StringEntity(requestBody.toString());
httpPatch.setEntity(params);
return APIUtil.executeHTTPRequest(httpPatch, httpClient);
} catch (IOException | APIManagementException e) {
log.error(e.getMessage());
}
return null;
}
use of org.apache.axis2.util.URL in project carbon-apimgt by wso2.
the class SolaceAdminApis method apiProductGet.
/**
* Check existence of API Product in Solace
*
* @param organization name of the Organization
* @param apiProductName name of the API Product
* @return CloseableHttpResponse of the GET call
*/
public CloseableHttpResponse apiProductGet(String organization, String apiProductName) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpGet httpGet = new HttpGet(baseUrl + "/" + organization + "/apiProducts/" + apiProductName);
httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + getBase64EncodedCredentials());
try {
return APIUtil.executeHTTPRequest(httpGet, httpClient);
} catch (IOException | APIManagementException e) {
log.error(e.getMessage());
}
return null;
}
use of org.apache.axis2.util.URL in project carbon-apimgt by wso2.
the class SolaceAdminApis method applicationPatchRemoveSubscription.
/**
* Remove subscriptions to application in Solace and update the application
*
* @param organization name of the Organization
* @param application Application to be checked in solace
* @param apiProductsToRemove List of API products to remove from subscriptions
* @return CloseableHttpResponse of the PATCH call
*/
public CloseableHttpResponse applicationPatchRemoveSubscription(String organization, Application application, List<String> apiProductsToRemove) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpPatch httpPatch = new HttpPatch(baseUrl + "/" + organization + "/developers/" + developerUserName + "/apps/" + application.getUUID());
httpPatch.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + getBase64EncodedCredentials());
httpPatch.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
// retrieve existing API products in the app
ArrayList<String> apiProducts = new ArrayList<>();
try {
apiProducts = retrieveApiProductsInAnApplication(applicationGet(organization, application.getUUID(), "default"), apiProducts);
} catch (IOException e) {
log.error(e.getMessage());
}
// remove API product from arrayList
apiProducts.removeAll(apiProductsToRemove);
org.json.JSONObject requestBody = buildRequestBodyForApplicationPatchSubscriptions(apiProducts);
StringEntity params = null;
try {
params = new StringEntity(requestBody.toString());
httpPatch.setEntity(params);
return APIUtil.executeHTTPRequest(httpPatch, httpClient);
} catch (IOException | APIManagementException e) {
log.error(e.getMessage());
}
return null;
}
use of org.apache.axis2.util.URL in project carbon-apimgt by wso2.
the class SolaceAdminApis method registeredAPIGet.
/**
* Check existence of API in Solace
*
* @param organization name of the Organization
* @param apiTitle name of the API
* @return CloseableHttpResponse of the GET call
*/
public CloseableHttpResponse registeredAPIGet(String organization, String apiTitle) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpGet httpGet = new HttpGet(baseUrl + "/" + organization + "/apis/" + apiTitle);
httpGet.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + getBase64EncodedCredentials());
try {
return APIUtil.executeHTTPRequest(httpGet, httpClient);
} catch (IOException | APIManagementException e) {
log.error(e.getMessage());
}
return null;
}
Aggregations