updateContinuousDeploymentPolicy method

Future<UpdateContinuousDeploymentPolicyResult> updateContinuousDeploymentPolicy({
  1. required ContinuousDeploymentPolicyConfig continuousDeploymentPolicyConfig,
  2. required String id,
  3. String? ifMatch,
})

Updates a continuous deployment policy. You can update a continuous deployment policy to enable or disable it, to change the percentage of traffic that it sends to the staging distribution, or to change the staging distribution that it sends traffic to.

When you update a continuous deployment policy configuration, all the fields are updated with the values that are provided in the request. You cannot update some fields independent of others. To update a continuous deployment policy configuration:

  1. Use GetContinuousDeploymentPolicyConfig to get the current configuration.
  2. Locally modify the fields in the continuous deployment policy configuration that you want to update.
  3. Use UpdateContinuousDeploymentPolicy, providing the entire continuous deployment policy configuration, including the fields that you modified and those that you didn't.

May throw AccessDenied. May throw InconsistentQuantities. May throw InvalidArgument. May throw InvalidIfMatchVersion. May throw NoSuchContinuousDeploymentPolicy. May throw PreconditionFailed. May throw StagingDistributionInUse.

Parameter continuousDeploymentPolicyConfig : The continuous deployment policy configuration.

Parameter id : The identifier of the continuous deployment policy that you are updating.

Parameter ifMatch : The current version (ETag value) of the continuous deployment policy that you are updating.

Implementation

Future<UpdateContinuousDeploymentPolicyResult>
    updateContinuousDeploymentPolicy({
  required ContinuousDeploymentPolicyConfig continuousDeploymentPolicyConfig,
  required String id,
  String? ifMatch,
}) async {
  final headers = <String, String>{
    if (ifMatch != null) 'If-Match': ifMatch.toString(),
  };
  final $result = await _protocol.sendRaw(
    method: 'PUT',
    requestUri:
        '/2020-05-31/continuous-deployment-policy/${Uri.encodeComponent(id)}',
    headers: headers,
    payload: continuousDeploymentPolicyConfig
        .toXml('ContinuousDeploymentPolicyConfig'),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return UpdateContinuousDeploymentPolicyResult(
    continuousDeploymentPolicy: ContinuousDeploymentPolicy.fromXml($elem),
    eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
  );
}