Search in sources :

Example 1 with EnvironmentPropertiesDTO

use of org.wso2.carbon.apimgt.api.dto.EnvironmentPropertiesDTO in project carbon-apimgt by wso2.

the class ApisApiServiceImpl method apisApiIdEnvironmentsEnvIdKeysGet.

@Override
public Response apisApiIdEnvironmentsEnvIdKeysGet(String apiId, String envId, MessageContext messageContext) throws APIManagementException {
    // validate api UUID
    validateAPIExistence(apiId);
    // validate environment UUID
    validateEnvironment(envId);
    APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
    // get properties
    EnvironmentPropertiesDTO properties = apiProvider.getEnvironmentSpecificAPIProperties(apiId, envId);
    // convert to string to remove null values
    String jsonContent = new Gson().toJson(properties);
    return Response.ok().entity(jsonContent).build();
}
Also used : Gson(com.google.gson.Gson) APIProvider(org.wso2.carbon.apimgt.api.APIProvider) EnvironmentPropertiesDTO(org.wso2.carbon.apimgt.api.dto.EnvironmentPropertiesDTO)

Example 2 with EnvironmentPropertiesDTO

use of org.wso2.carbon.apimgt.api.dto.EnvironmentPropertiesDTO in project carbon-apimgt by wso2.

the class ApisApiServiceImpl method apisApiIdEnvironmentsEnvIdKeysPut.

@Override
public Response apisApiIdEnvironmentsEnvIdKeysPut(String apiId, String envId, Map<String, String> requestBody, MessageContext messageContext) throws APIManagementException {
    // validate api UUID
    validateAPIExistence(apiId);
    // validate environment UUID
    validateEnvironment(envId);
    APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
    // adding properties
    EnvironmentPropertiesDTO properties = validateRequestPayload(requestBody);
    apiProvider.addEnvironmentSpecificAPIProperties(apiId, envId, properties);
    // get properties
    properties = apiProvider.getEnvironmentSpecificAPIProperties(apiId, envId);
    // convert to string to remove null values
    String jsonContent = new Gson().toJson(properties);
    return Response.ok().entity(jsonContent).build();
}
Also used : Gson(com.google.gson.Gson) APIProvider(org.wso2.carbon.apimgt.api.APIProvider) EnvironmentPropertiesDTO(org.wso2.carbon.apimgt.api.dto.EnvironmentPropertiesDTO)

Aggregations

Gson (com.google.gson.Gson)2 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)2 EnvironmentPropertiesDTO (org.wso2.carbon.apimgt.api.dto.EnvironmentPropertiesDTO)2