createAccessToken method

Future<CreateAccessTokenOutput> createAccessToken({
  1. required String dnsViewId,
  2. String? clientToken,
  3. DateTime? expiresAt,
  4. String? name,
  5. Map<String, String>? tags,
})

Creates an access token for a DNS view. Access tokens provide token-based authentication for DNS-over-HTTPS (DoH) and DNS-over-TLS (DoT) connections to the Route 53 Global Resolver.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter dnsViewId : The ID of the DNS view to associate with this token.

Parameter clientToken : A unique, case-sensitive identifier to ensure idempotency. This means that making the same request multiple times with the same clientToken has the same result every time.

Parameter expiresAt : The date and time when the token expires. Tokens can have a minimum expiration of 30 days and maximum of 365 days from creation.

Parameter name : A descriptive name for the access token.

Parameter tags : An array of user-defined keys and optional values. These tags can be used for categorization and organization.

Implementation

Future<CreateAccessTokenOutput> createAccessToken({
  required String dnsViewId,
  String? clientToken,
  DateTime? expiresAt,
  String? name,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (expiresAt != null) 'expiresAt': iso8601ToJson(expiresAt),
    if (name != null) 'name': name,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/tokens/${Uri.encodeComponent(dnsViewId)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateAccessTokenOutput.fromJson(response);
}