updateFunction method

Future<UpdateFunctionResult> updateFunction({
  1. required Uint8List functionCode,
  2. required FunctionConfig functionConfig,
  3. required String ifMatch,
  4. required String name,
})

Updates a CloudFront function.

You can update a function's code or the comment that describes the function. You cannot update a function's name.

To update a function, you provide the function's name and version (ETag value) along with the updated function code. To get the name and version, you can use ListFunctions and DescribeFunction.

May throw FunctionSizeLimitExceeded. May throw InvalidArgument. May throw InvalidIfMatchVersion. May throw NoSuchFunctionExists. May throw PreconditionFailed. May throw UnsupportedOperation.

Parameter functionCode : The function code. For more information about writing a CloudFront function, see Writing function code for CloudFront Functions in the Amazon CloudFront Developer Guide.

Parameter functionConfig : Configuration information about the function.

Parameter ifMatch : The current version (ETag value) of the function that you are updating, which you can get using DescribeFunction.

Parameter name : The name of the function that you are updating.

Implementation

Future<UpdateFunctionResult> updateFunction({
  required Uint8List functionCode,
  required FunctionConfig functionConfig,
  required String ifMatch,
  required String name,
}) async {
  final headers = <String, String>{
    'If-Match': ifMatch.toString(),
  };
  final $result = await _protocol.sendRaw(
    method: 'PUT',
    requestUri: '/2020-05-31/function/${Uri.encodeComponent(name)}',
    headers: headers,
    payload: UpdateFunctionRequest(
            functionCode: functionCode,
            functionConfig: functionConfig,
            ifMatch: ifMatch,
            name: name)
        .toXml('UpdateFunctionRequest'),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return UpdateFunctionResult(
    functionSummary: FunctionSummary.fromXml($elem),
    eTag: _s.extractHeaderStringValue($result.headers, 'ETtag'),
  );
}