Search in sources :

Example 1 with APIData

use of org.wso2.carbon.rest.api.APIData in project carbon-apimgt by wso2.

the class APIGatewayAdminTest method getDefaultApi.

@Test
public void getDefaultApi() throws Exception {
    APIData apiData = new APIData();
    apiData.setContext("/abc");
    apiData.setName(name);
    apiData.setFileName(name);
    RESTAPIAdminServiceProxy restapiAdminServiceProxy = Mockito.mock(RESTAPIAdminServiceProxy.class);
    Mockito.when(restapiAdminServiceProxy.getApi(apiDefaultName)).thenReturn(apiData);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(restapiAdminServiceProxy, null, null);
    Assert.assertNotNull(apiGatewayAdmin.getDefaultApi(name, version));
}
Also used : RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) APIData(org.wso2.carbon.rest.api.APIData) Test(org.junit.Test)

Example 2 with APIData

use of org.wso2.carbon.rest.api.APIData in project carbon-apimgt by wso2.

the class APIGatewayAdmin method getDefaultApiForTenant.

public org.wso2.carbon.apimgt.gateway.dto.APIData getDefaultApiForTenant(String apiName, String version, String tenantDomain) throws AxisFault {
    RESTAPIAdminServiceProxy restClient = getRestapiAdminClient(tenantDomain);
    String qualifiedName = GatewayUtils.getQualifiedDefaultApiName(apiName);
    APIData apiData = restClient.getApi(qualifiedName);
    return convert(apiData);
}
Also used : RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) APIData(org.wso2.carbon.rest.api.APIData)

Example 3 with APIData

use of org.wso2.carbon.rest.api.APIData in project carbon-apimgt by wso2.

the class APIGatewayAdmin method getApiForTenant.

/**
 * Get API from the gateway
 *
 * @param tenantDomain
 * @return
 * @throws AxisFault
 */
public org.wso2.carbon.apimgt.gateway.dto.APIData getApiForTenant(String apiName, String version, String tenantDomain) throws AxisFault {
    RESTAPIAdminServiceProxy restClient = getRestapiAdminClient(tenantDomain);
    String qualifiedName = GatewayUtils.getQualifiedApiName(apiName, version);
    APIData apiData = restClient.getApi(qualifiedName);
    return convert(apiData);
}
Also used : RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) APIData(org.wso2.carbon.rest.api.APIData)

Example 4 with APIData

use of org.wso2.carbon.rest.api.APIData in project carbon-apimgt by wso2.

the class APIGatewayAdmin method getDefaultApi.

public org.wso2.carbon.apimgt.gateway.dto.APIData getDefaultApi(String apiName, String version) throws AxisFault {
    RESTAPIAdminServiceProxy restClient = getRestapiAdminClient(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    String qualifiedName = GatewayUtils.getQualifiedDefaultApiName(apiName);
    APIData apiData = restClient.getApi(qualifiedName);
    return convert(apiData);
}
Also used : RESTAPIAdminServiceProxy(org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy) APIData(org.wso2.carbon.rest.api.APIData)

Example 5 with APIData

use of org.wso2.carbon.rest.api.APIData in project carbon-apimgt by wso2.

the class APIGatewayAdmin method convert.

private org.wso2.carbon.apimgt.gateway.dto.APIData convert(APIData data) {
    if (data == null) {
        return null;
    }
    org.wso2.carbon.apimgt.gateway.dto.APIData apiData = new org.wso2.carbon.apimgt.gateway.dto.APIData();
    apiData.setContext(data.getContext());
    apiData.setFileName(data.getFileName());
    apiData.setHost(data.getHost());
    apiData.setName(data.getName());
    apiData.setPort(data.getPort());
    ResourceData[] resources = data.getResources();
    List<org.wso2.carbon.apimgt.gateway.dto.ResourceData> resList = new ArrayList<org.wso2.carbon.apimgt.gateway.dto.ResourceData>();
    if (resources != null && resources.length > 0) {
        for (ResourceData res : resources) {
            if (res == null) {
                continue;
            }
            org.wso2.carbon.apimgt.gateway.dto.ResourceData resource = convert(res);
            resList.add(resource);
        }
        apiData.setResources(resList.toArray(new org.wso2.carbon.apimgt.gateway.dto.ResourceData[0]));
    }
    return apiData;
}
Also used : ResourceData(org.wso2.carbon.rest.api.ResourceData) ArrayList(java.util.ArrayList) APIData(org.wso2.carbon.rest.api.APIData)

Aggregations

APIData (org.wso2.carbon.rest.api.APIData)9 RESTAPIAdminServiceProxy (org.wso2.carbon.apimgt.gateway.utils.RESTAPIAdminServiceProxy)8 Test (org.junit.Test)4 ResourceData (org.wso2.carbon.rest.api.ResourceData)2 ArrayList (java.util.ArrayList)1