Skip to content

set_data_retrieval_policy

set_data_retrieval_policy(
    account_id: string,
    *,
    config_overrides: Optional[GlacierClientConfig] = None,
    policy: Optional[DataRetrievalPolicy] = None,
) -> None

This operation sets and then enacts a data retrieval policy in the region specified in the PUT request. You can set one policy per region for an AWS account. The policy is enacted within a few minutes of a successful PUT operation.

The set policy operation does not affect retrieval jobs that were in progress before the policy was enacted. For more information about data retrieval policies, see Amazon Glacier Data Retrieval Policies.

Parameters:

  • account_id (string) –

    The AccountId value is the AWS account ID. This value must match the AWS account ID associated with the credentials used to sign the request. You can either specify an AWS account ID or optionally a single '-' (hyphen), in which case Amazon Glacier uses the AWS account ID associated with the credentials used to sign the request. If you specify your account ID, do not include any hyphens ('-') in the ID.

  • policy (Optional[DataRetrievalPolicy], default: None ) –

    The data retrieval policy in JSON format.

Raises:

Examples:

To set and then enact a data retrieval policy The example sets and then enacts a data retrieval policy.

>>> client.set_data_retrieval_policy(account_id='-', policy={'Rules': [{'Strategy': 'BytesPerHour', 'BytesPerHour': 10737418240}]})
Source code in docs_src/capo_glacier/_services/glacier.py
def set_data_retrieval_policy(
    self,
    account_id: "capo_glacier.types.string.string",
    *,
    config_overrides: Optional[GlacierClientConfig] = None,
    policy: Optional[
        "capo_glacier.types.data_retrieval_policy.DataRetrievalPolicy"
    ] = None,
) -> None:
    """<p>This operation sets and then enacts a data retrieval policy in the region specified in the PUT request. You can set one policy per region for an AWS account. The policy is enacted within a few minutes of a successful PUT operation.</p> <p>The set policy operation does not affect retrieval jobs that were in progress before the policy was enacted. For more information about data retrieval policies, see <a href="https://docs.aws.amazon.com/amazonglacier/latest/dev/data-retrieval-policy.html">Amazon Glacier Data Retrieval Policies</a>. </p>

    Args:
        account_id: <p>The <code>AccountId</code> value is the AWS account ID. This value must match the AWS account ID associated with the credentials used to sign the request. You can either specify an AWS account ID or optionally a single '<code>-</code>' (hyphen), in which case Amazon Glacier uses the AWS account ID associated with the credentials used to sign the request. If you specify your account ID, do not include any hyphens ('-') in the ID.</p>
        policy: <p>The data retrieval policy in JSON format.</p>

    Raises:
        capo_glacier.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>Returned if a parameter of the request is incorrectly specified.</p>
        capo_glacier.errors.missing_parameter_value_exception.MissingParameterValueException: <p>Returned if a required header or parameter is missing from the request.</p>
        capo_glacier.errors.no_longer_supported_exception.NoLongerSupportedException: <p>Returned if the request was made by a customer with no Amazon Glacier storage. The request is denied as the API is no longer supported for new customers. Please use Amazon S3 Glacier storage classes instead.</p>
        capo_glacier.errors.service_unavailable_exception.ServiceUnavailableException: <p>Returned if the service cannot complete the request.</p>
        capo_glacier.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To set and then enact a data retrieval policy
        The example sets and then enacts a data retrieval policy.

        >>> client.set_data_retrieval_policy(account_id='-', policy={'Rules': [{'Strategy': 'BytesPerHour', 'BytesPerHour': 10737418240}]})
    """

    def _handler(
        req: "OperationRequest[capo_glacier.types.set_data_retrieval_policy_input.SetDataRetrievalPolicyInput]",
    ) -> OperationResponse[None]:
        import capo_glacier._operations.glacier.set_data_retrieval_policy

        output, http_response = (
            capo_glacier._operations.glacier.set_data_retrieval_policy.set_data_retrieval_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SetDataRetrievalPolicy")
    )
    input_: capo_glacier.types.set_data_retrieval_policy_input.SetDataRetrievalPolicyInput = {
        "account_id": account_id
    }
    if policy is not None:
        input_["policy"] = policy

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output