aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
235 stars 78 forks source link

Add outfile option to AG-GetExport #156

Closed rhaddan closed 1 year ago

rhaddan commented 4 years ago

In the AWS CLI, the apigateway get-export command has an outfile option to write the export to file. This feature appears to be missing in AWS Tools for Powershell. Adding an -Outfile parameter would simplify the usability of the function

Current Behavior

$agExport = Get-AGExport 
    -Parameter $AGExportParameters 
    -Accept "application/json" 
    -ExportType "oas30" 
    -RestApiId $(aws_api_gateway_rest_api_id) 
    -StageName $(aws_api_gateway_stage_name) 
    -Select "Body"

$MyBuffer = [System.Byte[]]::new([int]$agExport.Length)
$agExport.Read($MyBuffer, 0, [int]$agExport.Length)
$FilePath = '.\myfilename.json' -f $HOME
$FileStream = [System.IO.File]::OpenWrite($FilePath)
$FileStream.Write($MyBuffer, 0, $MyBuffer.Length)
$FileStream.Close()

Possible Solution

Get-AGExport 
    -Parameter $AGExportParameters 
    -Accept "application/json" 
    -ExportType "oas30" 
    -RestApiId $(aws_api_gateway_rest_api_id) 
    -StageName $(aws_api_gateway_stage_name) 
    -Select "Body"
    -Outfile ".\myfilename.json"

Context

Implementing this with AWS CLI was simple as we could just put the path to the desired outfile at the end of the command. The documentation for Get-AGExport didn't provide much guidance on getting the actual export file and ultimately required a few hours of research (we stumped AWS tech support as well) to get the additional code.

Your Environment

github-actions[bot] commented 2 years ago

We have noticed this issue has not recieved attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

ashishdhingra commented 2 years ago

Don't close for now.

github-actions[bot] commented 1 year ago

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.