updateResponseHeadersPolicy method
Updates a response headers policy.
When you update a response headers policy, the entire policy is replaced. You cannot update some policy fields independent of others. To update a response headers policy configuration:
-
Use
GetResponseHeadersPolicyConfigto get the current policy's configuration. - Modify the fields in the response headers policy configuration that you want to update.
-
Call
UpdateResponseHeadersPolicy, providing the entire response headers 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 NoSuchResponseHeadersPolicy.
May throw PreconditionFailed.
May throw ResponseHeadersPolicyAlreadyExists.
May throw TooLongCSPInResponseHeadersPolicy.
May throw TooManyCustomHeadersInResponseHeadersPolicy.
May throw TooManyRemoveHeadersInResponseHeadersPolicy.
Parameter id :
The identifier for the response headers policy that you are updating.
Parameter responseHeadersPolicyConfig :
A response headers policy configuration.
Parameter ifMatch :
The version of the response headers policy that you are updating.
The version is returned in the cache policy's ETag field in
the response to GetResponseHeadersPolicyConfig.
Implementation
Future<UpdateResponseHeadersPolicyResult> updateResponseHeadersPolicy({
required String id,
required ResponseHeadersPolicyConfig responseHeadersPolicyConfig,
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/response-headers-policy/${Uri.encodeComponent(id)}',
headers: headers,
payload: responseHeadersPolicyConfig.toXml('ResponseHeadersPolicyConfig'),
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return UpdateResponseHeadersPolicyResult(
responseHeadersPolicy: ResponseHeadersPolicy.fromXml($elem),
eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
);
}