updateFunction method

Future<UpdateFunctionResponse> updateFunction({
  1. required String apiId,
  2. required String dataSourceName,
  3. required String functionId,
  4. required String functionVersion,
  5. required String name,
  6. String? description,
  7. String? requestMappingTemplate,
  8. String? responseMappingTemplate,
})

Updates a Function object.

May throw ConcurrentModificationException. May throw NotFoundException. May throw UnauthorizedException. May throw InternalFailureException.

Parameter apiId : The GraphQL API ID.

Parameter dataSourceName : The Function DataSource name.

Parameter functionId : The function ID.

Parameter functionVersion : The version of the request mapping template. Currently the supported value is 2018-05-29.

Parameter name : The Function name.

Parameter description : The Function description.

Parameter requestMappingTemplate : The Function request mapping template. Functions support only the 2018-05-29 version of the request mapping template.

Parameter responseMappingTemplate : The Function request mapping template.

Implementation

Future<UpdateFunctionResponse> updateFunction({
  required String apiId,
  required String dataSourceName,
  required String functionId,
  required String functionVersion,
  required String name,
  String? description,
  String? requestMappingTemplate,
  String? responseMappingTemplate,
}) async {
  ArgumentError.checkNotNull(apiId, 'apiId');
  ArgumentError.checkNotNull(dataSourceName, 'dataSourceName');
  _s.validateStringLength(
    'dataSourceName',
    dataSourceName,
    1,
    65536,
    isRequired: true,
  );
  ArgumentError.checkNotNull(functionId, 'functionId');
  _s.validateStringLength(
    'functionId',
    functionId,
    1,
    65536,
    isRequired: true,
  );
  ArgumentError.checkNotNull(functionVersion, 'functionVersion');
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    65536,
    isRequired: true,
  );
  _s.validateStringLength(
    'requestMappingTemplate',
    requestMappingTemplate,
    1,
    65536,
  );
  _s.validateStringLength(
    'responseMappingTemplate',
    responseMappingTemplate,
    1,
    65536,
  );
  final $payload = <String, dynamic>{
    'dataSourceName': dataSourceName,
    'functionVersion': functionVersion,
    'name': name,
    if (description != null) 'description': description,
    if (requestMappingTemplate != null)
      'requestMappingTemplate': requestMappingTemplate,
    if (responseMappingTemplate != null)
      'responseMappingTemplate': responseMappingTemplate,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/v1/apis/${Uri.encodeComponent(apiId)}/functions/${Uri.encodeComponent(functionId)}',
    exceptionFnMap: _exceptionFns,
  );
  return UpdateFunctionResponse.fromJson(response);
}