createTrafficPolicyVersion method

Future<CreateTrafficPolicyVersionResponse> createTrafficPolicyVersion({
  1. required String document,
  2. required String id,
  3. String? comment,
})

Creates a new version of an existing traffic policy. When you create a new version of a traffic policy, you specify the ID of the traffic policy that you want to update and a JSON-formatted document that describes the new version. You use traffic policies to create multiple DNS resource record sets for one domain name (such as example.com) or one subdomain name (such as www.example.com). You can create a maximum of 1000 versions of a traffic policy. If you reach the limit and need to create another version, you'll need to start a new traffic policy.

May throw NoSuchTrafficPolicy. May throw InvalidInput. May throw TooManyTrafficPolicyVersionsForCurrentPolicy. May throw ConcurrentModification. May throw InvalidTrafficPolicyDocument.

Parameter document : The definition of this version of the traffic policy, in JSON format. You specified the JSON in the CreateTrafficPolicyVersion request. For more information about the JSON format, see CreateTrafficPolicy.

Parameter id : The ID of the traffic policy for which you want to create a new version.

Parameter comment : The comment that you specified in the CreateTrafficPolicyVersion request, if any.

Implementation

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