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);
}
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);
}
}
}
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);
}
}
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);
}
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());
}
Aggregations