createDomain method
Creates a domain resource for the specified domain (e.g., example.com).
The create domain
operation supports tag-based access control
via request tags. For more information, see the Lightsail
Dev Guide.
May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw AccountSetupInProgressException. May throw UnauthenticatedException.
Parameter domainName
:
The domain name to manage (e.g., example.com
).
Parameter tags
:
The tag keys and optional values to add to the resource during create.
Use the TagResource
action to tag a resource after it's
created.
Implementation
Future<CreateDomainResult> createDomain({
required String domainName,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(domainName, 'domainName');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.CreateDomain'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'domainName': domainName,
if (tags != null) 'tags': tags,
},
);
return CreateDomainResult.fromJson(jsonResponse.body);
}