Search in sources :

Example 6 with ApiService

use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.

the class ApiReferenceTocOrganizer method removeObjectDataServices.

private void removeObjectDataServices(List<ApiService> services) {
    List<ApiService> dataservices = Lists.newArrayList();
    for (ApiService service : services) {
        if (service.packageName.endsWith("s3.operation") || service.packageName.endsWith("atmos.operation") || service.packageName.endsWith("swift.operation")) {
            dataservices.add(service);
        }
    }
    services.removeAll(dataservices);
}
Also used : ApiService(com.emc.apidocs.model.ApiService)

Example 7 with ApiService

use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.

the class PlayRoutesParser method parse.

private static void parse(File routeFile, Map<String, ApiService> services, String moduleRoot) throws Exception {
    byte[] bytes = IOUtils.toByteArray(new FileInputStream(routeFile));
    String file = new String(bytes);
    Matcher serviceMatcher = docPattern.matcher(file);
    while (serviceMatcher.find()) {
        int groupCount = serviceMatcher.groupCount();
        String className = getClassName(serviceMatcher.group(groupCount));
        String packageName = getPackage(serviceMatcher.group(groupCount));
        ApiService apiService = null;
        if (services.containsKey(className)) {
            apiService = services.get(className);
        } else {
            apiService = new ApiService();
            apiService.packageName = packageName;
            apiService.javaClassName = className;
            apiService.description = "";
            apiService.path = moduleRoot + "/api";
            services.put(className, apiService);
        }
        if (!serviceMatcher.group(groupCount - 1).endsWith("{<json|xml>format}")) {
            ApiMethod apiMethod = new ApiMethod();
            apiMethod.javaMethodName = getMethodName(serviceMatcher.group(serviceMatcher.groupCount()));
            apiMethod.httpMethod = serviceMatcher.group(groupCount - 2);
            apiMethod.path = moduleRoot + serviceMatcher.group(groupCount - 1);
            apiMethod.description = serviceMatcher.group(1).replaceAll("## ", "");
            apiMethod.brief = serviceMatcher.group(3);
            apiMethod.apiService = apiService;
            apiMethod.alert = "<b>Note:</b> Hosted on HTTPS port 443";
            apiMethod.xmlExample = ExampleLoader.loadExample(apiMethod.getXmlExampleFilename());
            apiMethod.jsonExample = ExampleLoader.loadExample(apiMethod.getJsonExampleFilename());
            addParameterInfo(serviceMatcher.group(0), apiMethod);
            apiService.addMethod(apiMethod);
        }
    }
}
Also used : Matcher(java.util.regex.Matcher) ApiService(com.emc.apidocs.model.ApiService) ApiMethod(com.emc.apidocs.model.ApiMethod) FileInputStream(java.io.FileInputStream)

Example 8 with ApiService

use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.

the class PlayRoutesParser method getPortalServices.

public static Collection<ApiService> getPortalServices(String portalSrcRoot) {
    try {
        Map<String, ApiService> apiServices = Maps.newHashMap();
        parse(new File(portalSrcRoot + "/conf/routes"), apiServices, "");
        return apiServices.values();
    } catch (Exception e) {
        throw new RuntimeException("Error reading portal services", e);
    }
}
Also used : ApiService(com.emc.apidocs.model.ApiService) File(java.io.File)

Example 9 with ApiService

use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.

the class RouteParserTests method testPlayParser.

@Test
@Ignore
public void testPlayParser() {
    Collection<ApiService> services = PlayRoutesParser.getPortalServices("/Users/maddid/SourceCode/bourne/isa/portal");
    boolean executionWindowsFound = false;
    boolean approvalsFound = false;
    for (ApiService service : services) {
        // System.out.println(service.path+"  "+service.getTitle());
        for (ApiMethod method : service.methods) {
            // System.out.println(method.httpMethod+"  "+method.path+"  "+method.getTitle());
            if (method.path.equals("/admin/api/executionwindows")) {
                // An admin service found
                executionWindowsFound = true;
            }
            if (method.path.equals("/api/approvals")) {
                // a Non Admin service Found
                approvalsFound = true;
            }
        }
    }
    TestCase.assertTrue(executionWindowsFound);
    TestCase.assertTrue(approvalsFound);
}
Also used : ApiService(com.emc.apidocs.model.ApiService) ApiMethod(com.emc.apidocs.model.ApiMethod) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with ApiService

use of com.emc.apidocs.model.ApiService in project coprhd-controller by CoprHD.

the class SerializationTests method main.

public static void main(String[] args) throws Exception {
    ApiService service = new ApiService();
    service.javaClassName = "Dave";
    service.path = "/wobble";
    ApiMethod method = new ApiMethod();
    method.httpMethod = "GET";
    method.path = "/wobble/fred";
    service.addMethod(method);
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    String asJson = gson.toJson(service);
    System.out.println(asJson);
    ApiService back = gson.fromJson(asJson, ApiService.class);
    System.out.println(back.getFqJavaClassName() + " " + back.methods.size());
}
Also used : ApiService(com.emc.apidocs.model.ApiService) GsonBuilder(com.google.gson.GsonBuilder) ApiMethod(com.emc.apidocs.model.ApiMethod) Gson(com.google.gson.Gson)

Aggregations

ApiService (com.emc.apidocs.model.ApiService)14 ApiMethod (com.emc.apidocs.model.ApiMethod)8 File (java.io.File)3 List (java.util.List)3 ApiReferenceTocOrganizer (com.emc.apidocs.generating.ApiReferenceTocOrganizer)2 ApiDifferences (com.emc.apidocs.model.ApiDifferences)2 ImmutableList (com.google.common.collect.ImmutableList)2 JavaFile (com.squareup.javapoet.JavaFile)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 DifferenceEngine (com.emc.apidocs.differencing.DifferenceEngine)1 EnunciateFileReader (com.emc.apidocs.differencing.EnunciateFileReader)1 ApiClass (com.emc.apidocs.model.ApiClass)1 ApiErrorCode (com.emc.apidocs.model.ApiErrorCode)1 ApiServiceChanges (com.emc.apidocs.model.ApiServiceChanges)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 Map (java.util.Map)1