updateCachePolicy2020_05_31 method

Future<UpdateCachePolicyResult> updateCachePolicy2020_05_31({
  1. required CachePolicyConfig cachePolicyConfig,
  2. required String id,
  3. String? ifMatch,
})

Updates a cache policy configuration.

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

  1. Use GetCachePolicyConfig to get the current configuration.
  2. Locally modify the fields in the cache policy configuration that you want to update.
  3. Call UpdateCachePolicy by providing the entire cache policy configuration, including the fields that you modified and those that you didn’t.

May throw AccessDenied. May throw IllegalUpdate. May throw InconsistentQuantities. May throw InvalidArgument. May throw InvalidIfMatchVersion. May throw NoSuchCachePolicy. May throw PreconditionFailed. May throw CachePolicyAlreadyExists. May throw TooManyHeadersInCachePolicy. May throw TooManyCookiesInCachePolicy. May throw TooManyQueryStringsInCachePolicy.

Parameter cachePolicyConfig : A cache policy configuration.

Parameter id : The unique identifier for the cache policy that you are updating. The identifier is returned in a cache behavior’s CachePolicyId field in the response to GetDistributionConfig.

Parameter ifMatch : The version of the cache policy that you are updating. The version is returned in the cache policy’s ETag field in the response to GetCachePolicyConfig.

Implementation

Future<UpdateCachePolicyResult> updateCachePolicy2020_05_31({
  required CachePolicyConfig cachePolicyConfig,
  required String id,
  String? ifMatch,
}) async {
  ArgumentError.checkNotNull(cachePolicyConfig, 'cachePolicyConfig');
  ArgumentError.checkNotNull(id, 'id');
  final headers = <String, String>{
    if (ifMatch != null) 'If-Match': ifMatch.toString(),
  };
  final $result = await _protocol.sendRaw(
    method: 'PUT',
    requestUri: '/2020-05-31/cache-policy/${Uri.encodeComponent(id)}',
    headers: headers,
    payload: cachePolicyConfig.toXml('CachePolicyConfig'),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return UpdateCachePolicyResult(
    cachePolicy: CachePolicy.fromXml($elem),
    eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
  );
}