getFunction method
Gets the code of a CloudFront function. To get configuration information
and metadata about a function, use DescribeFunction.
To get a function's code, you must provide the function's name and stage.
To get these values, you can use ListFunctions.
May throw NoSuchFunctionExists.
May throw UnsupportedOperation.
Parameter name :
The name of the function whose code you are getting.
Parameter stage :
The function's stage, either DEVELOPMENT or
LIVE.
Implementation
Future<GetFunctionResult> getFunction({
required String name,
FunctionStage? stage,
}) async {
final $query = <String, List<String>>{
if (stage != null) 'Stage': [stage.value],
};
final $result = await _protocol.sendRaw(
method: 'GET',
requestUri: '/2020-05-31/function/${Uri.encodeComponent(name)}',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return GetFunctionResult(
functionCode: await $result.stream.toBytes(),
contentType: _s.extractHeaderStringValue($result.headers, 'Content-Type'),
eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
);
}