use of com.spectralogic.ds3autogen.go.models.client.Client in project ds3_autogen by SpectraLogic.
the class GoCodeGenerator method generateClient.
/**
* Generates the client files. Each file contains the client commands separated by {@link HttpVerb}
*/
private void generateClient(final ImmutableList<Ds3Request> ds3Requests) throws IOException, TemplateException {
for (final HttpVerb httpVerb : HttpVerb.values()) {
final ImmutableList<Ds3Request> filteredRequests = ds3Requests.stream().filter(ds3Request -> ds3Request.getHttpVerb() == httpVerb).collect(GuavaCollectors.immutableList());
generateClientFile(filteredRequests, httpVerb);
}
}
use of com.spectralogic.ds3autogen.go.models.client.Client in project ds3_autogen by SpectraLogic.
the class GoCodeGenerator method generateClientFile.
/**
* Generates a client file for commands that have the specified {@link HttpVerb}
*/
private void generateClientFile(final ImmutableList<Ds3Request> ds3Requests, final HttpVerb httpVerb) throws IOException, TemplateException {
if (isEmpty(ds3Requests)) {
LOG.info("There were no commands with verb {} to generate the {} client file", getClientFileName(httpVerb), httpVerb.toString());
}
final Template tmpl = config.getTemplate("client/client_template.ftl");
final ClientModelGenerator<?> generator = new BaseClientGenerator();
final Client client = generator.generate(ds3Requests);
final Path path = destDir.resolve(BASE_PROJECT_PATH.resolve(Paths.get(getClientFileName(httpVerb) + ".go")));
LOG.info("Getting OutputStream for file: {}", path.toString());
try (final OutputStream outputStream = fileUtils.getOutputFile(path);
final Writer writer = new OutputStreamWriter(outputStream)) {
tmpl.process(client, writer);
}
}
Aggregations