use of com.emc.apidocs.model.ApiMethod 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);
}
use of com.emc.apidocs.model.ApiMethod 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());
}
use of com.emc.apidocs.model.ApiMethod in project coprhd-controller by CoprHD.
the class EnunciateFileReader method toApiMethod.
public ApiMethod toApiMethod(Node resourceNode, Map<String, ApiClass> types) {
ApiMethod apiMethod = new ApiMethod();
apiMethod.httpMethod = XMLUtils.getNodeText(resourceNode, EnunciateConstants.RESOURCE_HTTP_OPERATION);
apiMethod.path = XMLUtils.getNodeText(resourceNode, EnunciateConstants.RESOURCE_PATH);
String requestElementName = XMLUtils.getNodeText(resourceNode, EnunciateConstants.RESOURCE_REQUEST_ELEMENT_TYPE);
if (requestElementName != null) {
apiMethod.input = findElementType(requestElementName, types, resourceNode.getOwnerDocument());
}
String responseElementName = XMLUtils.getNodeText(resourceNode, EnunciateConstants.RESOURCE_RESPONSE_ELEMENT_TYPE);
if (responseElementName != null) {
apiMethod.output = findElementType(responseElementName, types, resourceNode.getOwnerDocument());
}
return apiMethod;
}
use of com.emc.apidocs.model.ApiMethod in project coprhd-controller by CoprHD.
the class EnunciateFileReader method loadServices.
private Map<String, ApiService> loadServices(Document document) {
Map<String, ApiClass> apiClasses = loadTypes(document);
Map<String, ApiService> apiServices = Maps.newHashMap();
NodeList resourceNodes = XMLUtils.getNodeList(document, EnunciateConstants.RESOURCES);
for (int f = 0; f < resourceNodes.getLength(); f++) {
Node resourceNode = resourceNodes.item(f);
String serviceClass = XMLUtils.getNodeText(resourceNode, EnunciateConstants.RESOURCE_SERVICE_CLASS);
ApiService apiService = null;
if (apiClasses.containsKey(serviceClass)) {
apiService = apiServices.get(serviceClass);
} else {
apiService = new ApiService();
apiService.javaClassName = serviceClass;
apiServices.put(serviceClass, apiService);
}
ApiMethod apiMethod = toApiMethod(resourceNode, apiClasses);
System.out.println("Loaded Method " + serviceClass + " " + apiMethod.httpMethod + " " + apiMethod.path);
apiService.addMethod(apiMethod);
}
return apiServices;
}
use of com.emc.apidocs.model.ApiMethod 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();
}
Aggregations