createBasePathMapping method

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

Creates a new BasePathMapping resource.

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

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

Parameter restApiId : 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 domainNameId : The identifier for the domain name resource. Required for private custom domain names.

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? domainNameId,
  String? stage,
}) async {
  final $query = <String, List<String>>{
    if (domainNameId != null) 'domainNameId': [domainNameId],
  };
  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',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return BasePathMapping.fromJson(response);
}