putRestApi method
A feature of the API Gateway control service for updating an existing API with an input of external API definitions. The update can take the form of merging the supplied definition into the existing API or overwriting the existing API.
May throw UnauthorizedException. May throw LimitExceededException. May throw NotFoundException. May throw BadRequestException. May throw TooManyRequestsException. May throw ConflictException.
Parameter body
:
Required
The PUT request body containing external API definitions.
Currently, only OpenAPI definition JSON/YAML files are supported. The
maximum size of the API definition file is 6MB.
Parameter restApiId
:
Required
The string identifier of the associated RestApi.
Parameter failOnWarnings
:
A query parameter to indicate whether to rollback the API update
(true
) or not (false
) when a warning is
encountered. The default value is false
.
Parameter mode
:
The mode
query parameter to specify the update mode. Valid
values are "merge" and "overwrite". By default, the update mode is
"merge".
Parameter parameters
:
Custom header parameters as part of the request. For example, to exclude
DocumentationParts from an imported API, set
ignore=documentation
as a parameters
value, as
in the AWS CLI command of aws apigateway import-rest-api
--parameters ignore=documentation --body
'file:///path/to/imported-api-body.json'
.
Implementation
Future<RestApi> putRestApi({
required Uint8List body,
required String restApiId,
bool? failOnWarnings,
PutMode? mode,
Map<String, String>? parameters,
}) async {
ArgumentError.checkNotNull(body, 'body');
ArgumentError.checkNotNull(restApiId, 'restApiId');
final $query = <String, List<String>>{
if (failOnWarnings != null) 'failonwarnings': [failOnWarnings.toString()],
if (mode != null) 'mode': [mode.toValue()],
if (parameters != null)
for (var e in parameters.entries) e.key: [e.value],
};
final response = await _protocol.send(
payload: body,
method: 'PUT',
requestUri: '/restapis/${Uri.encodeComponent(restApiId)}',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return RestApi.fromJson(response);
}