Example usage for com.amazonaws.services.apigateway.model GetExportRequest GetExportRequest

List of usage examples for com.amazonaws.services.apigateway.model GetExportRequest GetExportRequest

Introduction

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

Prototype

GetExportRequest

Source Link

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);//from   w  ww.ja  v  a2s.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;
}