Search in sources :

Example 1 with ApiReferenceTocOrganizer

use of com.emc.apidocs.generating.ApiReferenceTocOrganizer in project coprhd-controller by CoprHD.

the class DifferenceEngineTest method main.

public static void main(String[] args) throws Exception {
    List<ApiService> oldApi = MetaData.load(EncunciationReaderTests.class.getResourceAsStream("MetaData-1.1.json"));
    List<ApiService> newApi = MetaData.load(EncunciationReaderTests.class.getResourceAsStream("MetaData-2.0.json"));
    ApiDifferences differences = DifferenceEngine.calculateDifferences(oldApi, newApi);
    ApiReferenceTocOrganizer organizer = new ApiReferenceTocOrganizer(new File("/Users/maddid/SourceCode/bourne/vipr-controller/tools/apidocs/src/content/reference/ApiReferenceGrouping.txt"));
    Map<String, List<ApiService>> newServicesToc = organizer.organizeServices(differences.newServices);
    Map<String, List<ApiService>> removedServicesToc = organizer.organizeServices(differences.removedServices);
    System.out.println("\n===== NEW SERVICES:");
    dumpServices(newServicesToc);
    System.out.println("\n===== SERVICE CHANGES");
    for (ApiServiceChanges changes : differences.modifiedServices) {
        System.out.println(changes.service.getFqJavaClassName());
        if (!changes.newMethods.isEmpty()) {
            System.out.println("---- NEW METHODS");
            for (ApiMethod apiMethod : changes.newMethods) {
                System.out.println("-- " + apiMethod.httpMethod + " " + apiMethod.path);
            }
        }
        if (!changes.removedMethods.isEmpty()) {
            System.out.println("---- REMOVED METHODS");
            for (ApiMethod apiMethod : changes.removedMethods) {
                System.out.println("-- " + apiMethod.httpMethod + " " + apiMethod.path);
            }
        }
    }
}
Also used : ApiService(com.emc.apidocs.model.ApiService) ApiDifferences(com.emc.apidocs.model.ApiDifferences) ApiMethod(com.emc.apidocs.model.ApiMethod) ApiReferenceTocOrganizer(com.emc.apidocs.generating.ApiReferenceTocOrganizer) ApiServiceChanges(com.emc.apidocs.model.ApiServiceChanges) List(java.util.List) File(java.io.File)

Example 2 with ApiReferenceTocOrganizer

use of com.emc.apidocs.generating.ApiReferenceTocOrganizer in project coprhd-controller by CoprHD.

the class ApiPrimitiveMaker method makePrimitives.

/**
 * Accept a list of ApiServices and make primitives for each HTTP method in
 * the service
 *
 * @param services
 *            - a list of services
 *
 * @return a JavaFile representing java source code for the primitive
 */
public static Iterable<JavaFile> makePrimitives(final List<ApiService> services) {
    final Builder<JavaFile> builder = ImmutableList.<JavaFile>builder();
    final ApiReferenceTocOrganizer grouping = new ApiReferenceTocOrganizer(KnownPaths.getReferenceFile("ApiReferenceGrouping.txt"));
    final Map<String, List<ApiService>> groups = grouping.organizeServices(services);
    for (final Entry<String, List<ApiService>> groupEntry : groups.entrySet()) {
        for (final ApiService service : groupEntry.getValue()) {
            for (final ApiMethod method : service.methods) {
                if (blackListed(method)) {
                    _log.info("Method " + method.apiService.getFqJavaClassName() + "::" + method.javaMethodName + " is black listed");
                } else if (method.isDeprecated) {
                    _log.info("Method " + method.apiService.getFqJavaClassName() + "::" + method.javaMethodName + " is deprecated");
                } else {
                    builder.add(makePrimitive(groupEntry.getKey(), method));
                }
            }
        }
    }
    return builder.build();
}
Also used : ApiService(com.emc.apidocs.model.ApiService) ApiMethod(com.emc.apidocs.model.ApiMethod) JavaFile(com.squareup.javapoet.JavaFile) ApiReferenceTocOrganizer(com.emc.apidocs.generating.ApiReferenceTocOrganizer) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List)

Aggregations

ApiReferenceTocOrganizer (com.emc.apidocs.generating.ApiReferenceTocOrganizer)2 ApiMethod (com.emc.apidocs.model.ApiMethod)2 ApiService (com.emc.apidocs.model.ApiService)2 List (java.util.List)2 ApiDifferences (com.emc.apidocs.model.ApiDifferences)1 ApiServiceChanges (com.emc.apidocs.model.ApiServiceChanges)1 ImmutableList (com.google.common.collect.ImmutableList)1 JavaFile (com.squareup.javapoet.JavaFile)1 File (java.io.File)1