updateOriginRequestPolicy2020_05_31 method

Future<UpdateOriginRequestPolicyResult> updateOriginRequestPolicy2020_05_31({
  1. required String id,
  2. required OriginRequestPolicyConfig originRequestPolicyConfig,
  3. String? ifMatch,
})

Updates an origin request policy configuration.

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

  1. Use GetOriginRequestPolicyConfig to get the current configuration.
  2. Locally modify the fields in the origin request policy configuration that you want to update.
  3. Call UpdateOriginRequestPolicy by providing the entire origin request 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 NoSuchOriginRequestPolicy. May throw PreconditionFailed. May throw OriginRequestPolicyAlreadyExists. May throw TooManyHeadersInOriginRequestPolicy. May throw TooManyCookiesInOriginRequestPolicy. May throw TooManyQueryStringsInOriginRequestPolicy.

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

Parameter originRequestPolicyConfig : An origin request policy configuration.

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

Implementation

Future<UpdateOriginRequestPolicyResult> updateOriginRequestPolicy2020_05_31({
  required String id,
  required OriginRequestPolicyConfig originRequestPolicyConfig,
  String? ifMatch,
}) async {
  ArgumentError.checkNotNull(id, 'id');
  ArgumentError.checkNotNull(
      originRequestPolicyConfig, 'originRequestPolicyConfig');
  final headers = <String, String>{
    if (ifMatch != null) 'If-Match': ifMatch.toString(),
  };
  final $result = await _protocol.sendRaw(
    method: 'PUT',
    requestUri:
        '/2020-05-31/origin-request-policy/${Uri.encodeComponent(id)}',
    headers: headers,
    payload: originRequestPolicyConfig.toXml('OriginRequestPolicyConfig'),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return UpdateOriginRequestPolicyResult(
    originRequestPolicy: OriginRequestPolicy.fromXml($elem),
    eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
  );
}