createModel method
Adds a new Model resource to an existing RestApi resource.
May throw BadRequestException.
May throw ConflictException.
May throw LimitExceededException.
May throw NotFoundException.
May throw TooManyRequestsException.
May throw UnauthorizedException.
Parameter contentType :
The content-type for the model.
Parameter name :
The name of the model. Must be alphanumeric.
Parameter restApiId :
The RestApi identifier under which the Model will be created.
Parameter description :
The description of the model.
Parameter schema :
The schema for the model. For application/json models, this
should be JSON schema draft 4 model. The maximum size of the model is 400
KB.
Implementation
Future<Model> createModel({
required String contentType,
required String name,
required String restApiId,
String? description,
String? schema,
}) async {
final $payload = <String, dynamic>{
'contentType': contentType,
'name': name,
if (description != null) 'description': description,
if (schema != null) 'schema': schema,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/restapis/${Uri.encodeComponent(restApiId)}/models',
exceptionFnMap: _exceptionFns,
);
return Model.fromJson(response);
}