Search in sources :

Example 1 with Request

use of com.spectralogic.ds3autogen.go.models.request.Request in project ds3_autogen by SpectraLogic.

the class GoCodeGenerator method generateRequest.

/**
     * Generates the Go code for a request handler
     */
private void generateRequest(final Ds3Request ds3Request) throws IOException, TemplateException {
    final Template tmpl = getRequestTemplate(ds3Request);
    final RequestModelGenerator<?> generator = getRequestGenerator(ds3Request);
    final Request request = generator.generate(ds3Request);
    final Path path = destDir.resolve(BASE_PROJECT_PATH.resolve(Paths.get(COMMANDS_NAMESPACE.replace(".", "/") + "/" + uncapitalize(request.getName()) + ".go")));
    LOG.info("Getting Output Stream for file: {}", path.toString());
    try (final OutputStream outputStream = fileUtils.getOutputFile(path);
        final Writer writer = new OutputStreamWriter(outputStream)) {
        tmpl.process(request, writer);
    }
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Request(com.spectralogic.ds3autogen.go.models.request.Request) OutputStreamWriter(java.io.OutputStreamWriter) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

Aggregations

Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)1 Request (com.spectralogic.ds3autogen.go.models.request.Request)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 Path (java.nio.file.Path)1