createPublicDnsNamespace method

Future<CreatePublicDnsNamespaceResponse> createPublicDnsNamespace({
  1. required String name,
  2. String? creatorRequestId,
  3. String? description,
  4. PublicDnsNamespaceProperties? properties,
  5. List<Tag>? tags,
})

Creates a public namespace based on DNS, which is visible on the internet. The namespace defines your service naming scheme. For example, if you name your namespace example.com and name your service backend, the resulting DNS name for the service is backend.example.com. You can discover instances that were registered with a public DNS namespace by using either a DiscoverInstances request or using DNS. For the current quota on the number of namespaces that you can create using the same Amazon Web Services account, see Cloud Map quotas in the Cloud Map Developer Guide.

May throw DuplicateRequest. May throw InvalidInput. May throw NamespaceAlreadyExists. May throw ResourceLimitExceeded. May throw TooManyTagsException.

Parameter name : The name that you want to assign to this namespace.

Parameter creatorRequestId : A unique string that identifies the request and that allows failed CreatePublicDnsNamespace requests to be retried without the risk of running the operation twice. CreatorRequestId can be any unique string (for example, a date/timestamp).

Parameter description : A description for the namespace.

Parameter properties : Properties for the public DNS namespace.

Parameter tags : The tags to add to the namespace. Each tag consists of a key and an optional value that you define. Tags keys can be up to 128 characters in length, and tag values can be up to 256 characters in length.

Implementation

Future<CreatePublicDnsNamespaceResponse> createPublicDnsNamespace({
  required String name,
  String? creatorRequestId,
  String? description,
  PublicDnsNamespaceProperties? properties,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Route53AutoNaming_v20170314.CreatePublicDnsNamespace'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      'CreatorRequestId': creatorRequestId ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (properties != null) 'Properties': properties,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreatePublicDnsNamespaceResponse.fromJson(jsonResponse.body);
}