Package org.wso2.carbon.rest.api.service
Class RestApiAdmin
java.lang.Object
org.wso2.carbon.core.AbstractAdmin
org.wso2.carbon.mediation.initializer.AbstractServiceBusAdmin
org.wso2.carbon.rest.api.service.RestApiAdmin
public class RestApiAdmin
extends org.wso2.carbon.mediation.initializer.AbstractServiceBusAdmin
-
Field Summary
FieldsFields inherited from class org.wso2.carbon.core.AbstractAdmin
axisConfig, configurationContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddApiForTenant(String apiData, String tenantDomain) Set the tenant domain when a publisher publishes his API in MT mode.booleanaddApiFromString(String apiData) voidaddSwaggerDocument(String apiName, String swaggerJsonString, int tenantId) Replace the swagger document in the registry with the given swagger json stringvoidDelete All API in the synapse configurationbooleanbooleandeleteApiForTenant(String apiName, String tenantDomain) Set the tenant domain when a publisher deletes his API in MT mode.voiddeleteSelectedApi(String[] apiNames) Delete Selected APIdisableStatistics(String apiName) disableTracing(String apiName) enableStatistics(String apiName) enableTracing(String apiName) generateAPIFromSwagger(String swaggerJsonString) Function to generate API from swagger definition (from JSON representation)generateAPIFromSwaggerByFormat(String swaggerString, boolean isJSON) Function to generate API from swagger definition (from JSON representation)generateSwaggerFromSynapseAPI(org.apache.synapse.api.API api) Function to generate API from swagger definition (from Synapse API)generateSwaggerFromSynapseAPIByFormat(org.apache.synapse.api.API api, boolean isJSON) Function to generate API from swagger definition (from Synapse API).generateUpdatedAPIFromSwagger(String swaggerJsonString, String existingApiName) Function to generate updated existing API by referring to swagger definition (from JSON representation)generateUpdatedAPIFromSwaggerByFormat(String swaggerJsonString, boolean isJSON, org.apache.synapse.api.API existingApi) Function to generate updated existing API by referring to swagger definition.generateUpdatedAPIFromSwaggerForAPI(String swaggerJsonString, org.apache.synapse.api.API existingApi) Function to generate updated existing API by referring to swagger definition (from JSON representation)generateUpdatedSwaggerFromAPI(String existingSwagger, boolean isJSONIn, boolean isJSONOut, org.apache.synapse.api.API api) Generate updated OpenApi definition using an updated API.getApiByName(String apiName) org.apache.axiom.om.OMElementgetAPIContent(String apiName, String tenantDomain) intgetApiForTenant(String apiName, String tenantDomain) Set the tenant domain when a publisher tries to retrieve API his API in MT mode.String[]APIData[]getAPIsForListing(int pageNumber, int itemsPerPage) getApiSource(APIData apiData) protected org.apache.axis2.engine.AxisConfigurationOverride the AbstarctAdmin.java's getAxisConfig() to create the CarbonContext from ThreadLoaclContext.protected org.apache.axis2.context.ConfigurationContextgetResourceSource(ResourceData resourceData) String[]getSwaggerDocument(String apiName, int tenantId) Return the registry resource for the provided locationprotected org.apache.synapse.api.APIgetSynapseAPIByName(String apiName) Function to retrieve synapse API object for given API nameprotected org.apache.synapse.config.SynapseConfigurationOverride the parent's getSynapseconfig() method to retrieve the Synapse configuration from the relevant axis configurationbooleanbooleanupdateApiForTenant(String apiName, String apiData, String tenantDomain) Set the tenant domain when a publisher updates his API in MT mode.booleanupdateApiFromString(String apiName, String apiData) updateNameInSwagger(String newName, String swagger) Update the title of a given swagger document.voidupdateSwaggerDocument(String apiName, String swaggerJsonString, int tenantId) Create a registry resource for the swagger document and update the registry resource with the default swaggerMethods inherited from class org.wso2.carbon.mediation.initializer.AbstractServiceBusAdmin
getLock, getMediationPersistenceManager, getServerConfigurationInformation, getServerContextInformation, getSynapseEnvironment, getSynapseEnvironment, lockSynapseConfiguration, unlockSynapseConfigurationMethods inherited from class org.wso2.carbon.core.AbstractAdmin
getConfigSystemRegistry, getConfigUserRegistry, getGovernanceRegistry, getGovernanceSystemRegistry, getGovernanceUserRegistry, getHttpSession, getLocalRepo, getRegistry, getTenantDomain, getUserId, getUsername, getUserRealm, setConfigurationContext, setPermissionUpdateTimestamp
-
Field Details
-
SYNAPSE_CONFIGURATION
- See Also:
-
-
Constructor Details
-
RestApiAdmin
public RestApiAdmin()
-
-
Method Details
-
addApi
- Throws:
APIException
-
addApiFromString
- Throws:
APIException
-
addApiForTenant
Set the tenant domain when a publisher publishes his API in MT mode. When publisher publishes the API, we login the gateway as supretenant. But we need to publish the API in the particular tenant domain.- Parameters:
apiData-tenantDomain-- Returns:
- Throws:
APIException
-
updateApi
- Throws:
APIException
-
updateApiFromString
- Throws:
APIException
-
updateApiForTenant
public boolean updateApiForTenant(String apiName, String apiData, String tenantDomain) throws APIException Set the tenant domain when a publisher updates his API in MT mode. When publisher updates the API, we login the gateway as supretenant. But we need to update the API,which is in the particular tenant domain.- Parameters:
apiName-apiData-- Returns:
- Throws:
APIException
-
deleteApi
- Throws:
APIException
-
deleteSelectedApi
Delete Selected API- Parameters:
apiNames-- Throws:
APIException
-
deleteAllApi
Delete All API in the synapse configuration- Throws:
APIException
-
deleteApiForTenant
Set the tenant domain when a publisher deletes his API in MT mode. When publisher deletes the API, we login the gateway as supretenant. But we need to delete the API,which is in the particular tenant domain.- Parameters:
apiName-tenantDomain-- Returns:
- Throws:
APIException
-
getAPIsForListing
-
getAPICount
public int getAPICount() -
getServerContext
- Throws:
APIException
-
getApiNames
-
getApiByName
-
getSynapseAPIByName
Function to retrieve synapse API object for given API name- Parameters:
apiName- API name- Returns:
- API object if exists, null otherwise
-
getApiForTenant
Set the tenant domain when a publisher tries to retrieve API his API in MT mode. When publisher gets the API, we login the gateway as supretenant. But we need to get the API,which is in the particular tenant domain.- Parameters:
apiName-tenantDomain-- Returns:
- Throws:
APIException
-
getSequences
-
enableStatistics
- Throws:
APIException
-
disableStatistics
- Throws:
APIException
-
enableTracing
- Throws:
APIException
-
disableTracing
- Throws:
APIException
-
getApiSource
-
getResourceSource
-
getSynapseConfiguration
protected org.apache.synapse.config.SynapseConfiguration getSynapseConfiguration()Override the parent's getSynapseconfig() method to retrieve the Synapse configuration from the relevant axis configuration- Overrides:
getSynapseConfigurationin classorg.wso2.carbon.mediation.initializer.AbstractServiceBusAdmin- Returns:
- extracted SynapseConfiguration from the relevant AxisConfiguration
-
getAxisConfig
protected org.apache.axis2.engine.AxisConfiguration getAxisConfig()Override the AbstarctAdmin.java's getAxisConfig() to create the CarbonContext from ThreadLoaclContext. We do this to support, publishing APIs as a supertenant but want to deploy that in tenant space. (This model is needed for APIManager)- Overrides:
getAxisConfigin classorg.wso2.carbon.core.AbstractAdmin
-
getConfigContext
protected org.apache.axis2.context.ConfigurationContext getConfigContext()- Overrides:
getConfigContextin classorg.wso2.carbon.core.AbstractAdmin
-
addSwaggerDocument
public void addSwaggerDocument(String apiName, String swaggerJsonString, int tenantId) throws APIException Replace the swagger document in the registry with the given swagger json string- Parameters:
apiName-swaggerJsonString-tenantId-- Throws:
APIException
-
updateSwaggerDocument
public void updateSwaggerDocument(String apiName, String swaggerJsonString, int tenantId) throws APIException Create a registry resource for the swagger document and update the registry resource with the default swagger- Parameters:
apiName- Name of the APIswaggerJsonString-tenantId-- Throws:
APIException
-
getSwaggerDocument
Return the registry resource for the provided location- Parameters:
apiName-tenantId-- Returns:
- Throws:
APIException
-
generateSwaggerFromSynapseAPIByFormat
public String generateSwaggerFromSynapseAPIByFormat(org.apache.synapse.api.API api, boolean isJSON) throws APIException Function to generate API from swagger definition (from Synapse API).- Parameters:
api- api existing synapse APIisJSON- generate Swagger in YAML / JSON format.- Returns:
- generated swagger.
- Throws:
APIException- error occurred while retrieving host details.
-
generateSwaggerFromSynapseAPI
Function to generate API from swagger definition (from Synapse API)- Parameters:
api- existing synapse API- Returns:
- generated swagger
- Throws:
APIException
-
generateAPIFromSwagger
Function to generate API from swagger definition (from JSON representation)- Parameters:
swaggerJsonString- swagger definition- Returns:
- generated synapse API
- Throws:
APIException- error occurred while retrieving host details.
-
generateAPIFromSwaggerByFormat
public String generateAPIFromSwaggerByFormat(String swaggerString, boolean isJSON) throws APIException Function to generate API from swagger definition (from JSON representation)- Parameters:
swaggerString- swagger definitionisJSON- input in YAML / JSON format.- Returns:
- generated synapse API.
- Throws:
APIException- error occurred while retrieving host details.
-
generateUpdatedAPIFromSwagger
public String generateUpdatedAPIFromSwagger(String swaggerJsonString, String existingApiName) throws APIException Function to generate updated existing API by referring to swagger definition (from JSON representation)- Parameters:
swaggerJsonString- swagger definitionexistingApiName- name of the existing API- Returns:
- generated synapse API
- Throws:
APIException
-
generateUpdatedAPIFromSwaggerByFormat
public String generateUpdatedAPIFromSwaggerByFormat(String swaggerJsonString, boolean isJSON, org.apache.synapse.api.API existingApi) throws APIException Function to generate updated existing API by referring to swagger definition.- Parameters:
swaggerJsonString- swagger definition.isJSON- input in YAML / JSON format.existingApi- existing synapse API.- Returns:
- generated synapse API.
- Throws:
APIException- error occurred while retrieving host details.
-
generateUpdatedAPIFromSwaggerForAPI
public String generateUpdatedAPIFromSwaggerForAPI(String swaggerJsonString, org.apache.synapse.api.API existingApi) throws APIException Function to generate updated existing API by referring to swagger definition (from JSON representation)- Parameters:
swaggerJsonString- swagger definitionexistingApi- existing synapse API- Returns:
- generated synapse API
- Throws:
APIException
-
generateUpdatedSwaggerFromAPI
public String generateUpdatedSwaggerFromAPI(String existingSwagger, boolean isJSONIn, boolean isJSONOut, org.apache.synapse.api.API api) throws org.wso2.carbon.mediation.commons.rest.api.swagger.APIGenException Generate updated OpenApi definition using an updated API.- Parameters:
existingSwagger- existing OpenApi definition of the API.isJSONIn- input data-type JSON / YAML.isJSONOut- output required in JSON / YAML.api- updated synapse API.- Returns:
- OpenApi definition of the updated API.
- Throws:
org.wso2.carbon.mediation.commons.rest.api.swagger.APIGenException- Error occurred while generating the updated definition.
-
updateNameInSwagger
Update the title of a given swagger document.- Parameters:
newName- new title which should be added.swagger- swagger document.- Returns:
- updated swagger.
- Throws:
APIException- Error occurred while updating the title of the swagger.
-
getAPIContent
-