createTrafficPolicy method

Future<CreateTrafficPolicyResponse> createTrafficPolicy({
  1. required String document,
  2. required String name,
  3. String? comment,
})

Creates a traffic policy, which you use to create multiple DNS resource record sets for one domain name (such as example.com) or one subdomain name (such as www.example.com).

May throw InvalidInput. May throw TooManyTrafficPolicies. May throw TrafficPolicyAlreadyExists. May throw InvalidTrafficPolicyDocument.

Parameter document : The definition of this traffic policy in JSON format. For more information, see Traffic Policy Document Format.

Parameter name : The name of the traffic policy.

Parameter comment : (Optional) Any comments that you want to include about the traffic policy.

Implementation

Future<CreateTrafficPolicyResponse> createTrafficPolicy({
  required String document,
  required String name,
  String? comment,
}) async {
  ArgumentError.checkNotNull(document, 'document');
  _s.validateStringLength(
    'document',
    document,
    0,
    102400,
    isRequired: true,
  );
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    0,
    512,
    isRequired: true,
  );
  _s.validateStringLength(
    'comment',
    comment,
    0,
    1024,
  );
  final $result = await _protocol.sendRaw(
    method: 'POST',
    requestUri: '/2013-04-01/trafficpolicy',
    payload: CreateTrafficPolicyRequest(
            document: document, name: name, comment: comment)
        .toXml(
      'CreateTrafficPolicyRequest',
      attributes: [
        _s.XmlAttribute(_s.XmlName('xmlns'),
            'https://route53.amazonaws.com/doc/2013-04-01/'),
      ],
    ),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return CreateTrafficPolicyResponse(
    trafficPolicy:
        TrafficPolicy.fromXml(_s.extractXmlChild($elem, 'TrafficPolicy')!),
    location: _s.extractHeaderStringValue($result.headers, 'Location')!,
  );
}