Search in sources :

Example 1 with BaseClientGenerator

use of com.spectralogic.ds3autogen.go.generators.client.BaseClientGenerator 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);
    }
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) OutputStreamWriter(java.io.OutputStreamWriter) Client(com.spectralogic.ds3autogen.go.models.client.Client) BaseClientGenerator(com.spectralogic.ds3autogen.go.generators.client.BaseClientGenerator) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

Aggregations

BaseClientGenerator (com.spectralogic.ds3autogen.go.generators.client.BaseClientGenerator)1 Client (com.spectralogic.ds3autogen.go.models.client.Client)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 Path (java.nio.file.Path)1