Skip to content

set_vault_access_policy async

set_vault_access_policy(
    account_id: string,
    vault_name: string,
    *,
    config_overrides: Optional[AsyncGlacierClientConfig] = None,
    policy: Optional[VaultAccessPolicy] = None,
) -> None

This operation configures an access policy for a vault and will overwrite an existing policy. To configure a vault access policy, send a PUT request to the access-policy subresource of the vault. An access policy is specific to a vault and is also called a vault subresource. You can set one access policy per vault and the policy can be up to 20 KB in size. For more information about vault access policies, see Amazon Glacier Access Control with Vault Access Policies.

Parameters:

  • account_id (string) –

    The AccountId value is the AWS account ID of the account that owns the vault. 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 use an account ID, do not include any hyphens ('-') in the ID.

  • vault_name (string) –

    The name of the vault.

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

    The vault access policy as a JSON string.

Raises:

Examples:

To set the access-policy on a vault The example configures an access policy for the vault named examplevault.

>>> await client.set_vault_access_policy(account_id='-', vault_name='examplevault', policy={'Policy': '{"Version":"2012-10-17","Statement":[{"Sid":"Define-owner-access-rights","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::999999999999:root"},"Action":"glacier:DeleteArchive","Resource":"arn:aws:glacier:us-west-2:999999999999:vaults/examplevault"}]}'})
Source code in docs_src/capo_glacier/_services/async_glacier.py
async def set_vault_access_policy(
    self,
    account_id: "capo_glacier.types.string.string",
    vault_name: "capo_glacier.types.string.string",
    *,
    config_overrides: Optional[AsyncGlacierClientConfig] = None,
    policy: Optional[
        "capo_glacier.types.vault_access_policy.VaultAccessPolicy"
    ] = None,
) -> None:
    """<p>This operation configures an access policy for a vault and will overwrite an existing policy. To configure a vault access policy, send a PUT request to the <code>access-policy</code> subresource of the vault. An access policy is specific to a vault and is also called a vault subresource. You can set one access policy per vault and the policy can be up to 20 KB in size. For more information about vault access policies, see <a href="https://docs.aws.amazon.com/amazonglacier/latest/dev/vault-access-policy.html">Amazon Glacier Access Control with Vault Access Policies</a>. </p>

    Args:
        account_id: <p>The <code>AccountId</code> value is the AWS account ID of the account that owns the vault. 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 use an account ID, do not include any hyphens ('-') in the ID.</p>
        vault_name: <p>The name of the vault.</p>
        policy: <p>The vault access policy as a JSON string.</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.resource_not_found_exception.ResourceNotFoundException: <p>Returned if the specified resource (such as a vault, upload ID, or job ID) doesn't exist.</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 the access-policy on a vault
        The example configures an access policy for the vault named examplevault.

        >>> await client.set_vault_access_policy(account_id='-', vault_name='examplevault', policy={'Policy': '{"Version":"2012-10-17","Statement":[{"Sid":"Define-owner-access-rights","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::999999999999:root"},"Action":"glacier:DeleteArchive","Resource":"arn:aws:glacier:us-west-2:999999999999:vaults/examplevault"}]}'})
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_glacier.types.set_vault_access_policy_input.SetVaultAccessPolicyInput]",
    ) -> AsyncOperationResponse[None]:
        import capo_glacier._operations.glacier.set_vault_access_policy

        (
            output,
            http_response,
        ) = await capo_glacier._operations.glacier.set_vault_access_policy.async_set_vault_access_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SetVaultAccessPolicy")
    )
    input_: capo_glacier.types.set_vault_access_policy_input.SetVaultAccessPolicyInput = {
        "account_id": account_id,
        "vault_name": vault_name,
    }
    if policy is not None:
        input_["policy"] = policy

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output