use of org.apache.axis2.util.URL in project carbon-apimgt by wso2.
the class SolaceAdminApis method deleteRegisteredAPI.
/**
* Delete registered API from Solace
*
* @param organization name of the Organization
* @param title name of the API
* @return CloseableHttpResponse of the DELETE call
*/
public CloseableHttpResponse deleteRegisteredAPI(String organization, String title) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpDelete httpDelete = new HttpDelete(baseUrl + "/" + organization + "/apis/" + title);
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 renameApplication.
/**
* Rename application in Solace Broker
*
* @param organization name of the Organization
* @param application Application object to be renamed
* @return CloseableHttpResponse of the DELETE call
*/
public CloseableHttpResponse renameApplication(String organization, Application application) {
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 = buildRequestBodyForRenamingApp(application);
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 deleteApiProduct.
/**
* Delete API Product from Solace Broker
*
* @param organization name of the Organization
* @param apiProductName name of the API product
* @return CloseableHttpResponse of the DELETE call
*/
public CloseableHttpResponse deleteApiProduct(String organization, String apiProductName) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpDelete httpDelete = new HttpDelete(baseUrl + "/" + organization + "/apiProducts/" + apiProductName);
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 developerGet.
/**
* Check existence of the developer in Solace
*
* @param organization name of the Organization
* @return CloseableHttpResponse of the GET call
*/
public CloseableHttpResponse developerGet(String organization) {
URL serviceEndpointURL = new URL(baseUrl);
HttpClient httpClient = APIUtil.getHttpClient(serviceEndpointURL.getPort(), serviceEndpointURL.getProtocol());
HttpGet httpGet = new HttpGet(baseUrl + "/" + organization + "/developers/" + developerUserName);
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 applicationPatchAddSubscription.
/**
* Add subscriptions to application in Solace and update the application
*
* @param organization name of the Organization
* @param application Application to be checked in solace
* @param apiProducts API products to add as subscriptions
* @return CloseableHttpResponse of the PATCH call
*/
public CloseableHttpResponse applicationPatchAddSubscription(String organization, Application application, ArrayList<String> apiProducts) {
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
try {
apiProducts = retrieveApiProductsInAnApplication(applicationGet(organization, application.getUUID(), "default"), apiProducts);
} catch (IOException e) {
log.error(e.getMessage());
}
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;
}
Aggregations