Example usage for com.amazonaws.services.apigateway.model GetExportResult getBody

List of usage examples for com.amazonaws.services.apigateway.model GetExportResult getBody

Introduction

In this page you can find the example usage for com.amazonaws.services.apigateway.model GetExportResult getBody.

Prototype


public java.nio.ByteBuffer getBody() 

Source Link

Document

The binary blob response to GetExport, which contains the export.

Usage

From source file:br.com.ingenieux.mojo.apigateway.DownloadApiDefinitionMojo.java

License:Apache License

@Override
protected Object executeInternal() throws Exception {
    this.lookupIds();

    Validate.notNull(restApiId);/* w w w . j a  v a 2s  .co  m*/
    Validate.notNull(stageName);

    Map<String, String> parameters = new LinkedHashMap<>();

    parameters.put("extensions", "integrations,authorizers,postman");

    final GetExportResult swaggerApi = getService()
            .getExport(new GetExportRequest().withExportType("swagger").withAccepts("application/json")
                    .withRestApiId(restApiId).withStageName(stageName).withParameters(parameters));

    String content = new String(swaggerApi.getBody().array(), Charset.defaultCharset());

    getLog().info("Content: " + content);

    if (null != outputFile) {
        if (!outputFile.exists()) {
            outputFile.getParentFile().mkdirs();

            getLog().info("Writing into file " + outputFile.getPath());

            IOUtils.write(content, new FileOutputStream(outputFile));
        }
    }

    return null;
}