createBasePathMapping method

Future<BasePathMapping> createBasePathMapping({
  1. required String domainName,
  2. required String restApiId,
  3. String? basePath,
  4. String? stage,
})

Creates a new BasePathMapping resource.

May throw UnauthorizedException. May throw ConflictException. May throw BadRequestException. May throw NotFoundException. May throw TooManyRequestsException.

Parameter domainName : Required The domain name of the BasePathMapping resource to create.

Parameter restApiId : Required The string identifier of the associated RestApi.

Parameter basePath : The base path name that callers of the API must provide as part of the URL after the domain name. This value must be unique for all of the mappings across a single API. Specify '(none)' if you do not want callers to specify a base path name after the domain name.

Parameter stage : The name of the API's stage that you want to use for this mapping. Specify '(none)' if you want callers to explicitly specify the stage name after any base path name.

Implementation

Future<BasePathMapping> createBasePathMapping({
  required String domainName,
  required String restApiId,
  String? basePath,
  String? stage,
}) async {
  ArgumentError.checkNotNull(domainName, 'domainName');
  ArgumentError.checkNotNull(restApiId, 'restApiId');
  final $payload = <String, dynamic>{
    'restApiId': restApiId,
    if (basePath != null) 'basePath': basePath,
    if (stage != null) 'stage': stage,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/domainnames/${Uri.encodeComponent(domainName)}/basepathmappings',
    exceptionFnMap: _exceptionFns,
  );
  return BasePathMapping.fromJson(response);
}