Skip to content

put_repository_permissions_policy async

put_repository_permissions_policy(
    domain: DomainName,
    repository: RepositoryName,
    policy_document: PolicyDocument,
    *,
    config_overrides: Optional[AsynccodeartifactClientConfig] = None,
    domain_owner: Optional[AccountId] = None,
    policy_revision: Optional[PolicyRevision] = None,
) -> PutRepositoryPermissionsPolicyResult

Sets the resource policy on a repository that specifies permissions to access it.

When you call PutRepositoryPermissionsPolicy, the resource policy on the repository is ignored when evaluting permissions. This ensures that the owner of a repository cannot lock themselves out of the repository, which would prevent them from being able to update the resource policy.

Parameters:

  • domain (DomainName) –

    The name of the domain containing the repository to set the resource policy on.

  • domain_owner (Optional[AccountId], default: None ) –

    The 12-digit account number of the Amazon Web Services account that owns the domain. It does not include dashes or spaces.

  • repository (RepositoryName) –

    The name of the repository to set the resource policy on.

  • policy_revision (Optional[PolicyRevision], default: None ) –

    Sets the revision of the resource policy that specifies permissions to access the repository. This revision is used for optimistic locking, which prevents others from overwriting your changes to the repository's resource policy.

  • policy_document (PolicyDocument) –

    A valid displayable JSON Aspen policy string to be set as the access control resource policy on the provided repository.

Raises:

  • AccessDeniedException –

    The operation did not succeed because of an unauthorized access attempt.

  • ConflictException –

    The operation did not succeed because prerequisites are not met.

  • InternalServerException –

    The operation did not succeed because of an error that occurred inside CodeArtifact.

  • ResourceNotFoundException –

    The operation did not succeed because the resource requested is not found in the service.

  • ServiceQuotaExceededException –

    The operation did not succeed because it would have exceeded a service limit for your account.

  • ThrottlingException –

    The operation did not succeed because too many requests are sent to the service.

  • ValidationException –

    The operation did not succeed because a parameter in the request was sent with an invalid value.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_codeartifact/_services/async_codeartifact.py
async def put_repository_permissions_policy(
    self,
    domain: "capo_codeartifact.types.domain_name.DomainName",
    repository: "capo_codeartifact.types.repository_name.RepositoryName",
    policy_document: "capo_codeartifact.types.policy_document.PolicyDocument",
    *,
    config_overrides: Optional[AsynccodeartifactClientConfig] = None,
    domain_owner: Optional["capo_codeartifact.types.account_id.AccountId"] = None,
    policy_revision: Optional[
        "capo_codeartifact.types.policy_revision.PolicyRevision"
    ] = None,
) -> "capo_codeartifact.types.put_repository_permissions_policy_result.PutRepositoryPermissionsPolicyResult":
    """<p> Sets the resource policy on a repository that specifies permissions to access it. </p> <p> When you call <code>PutRepositoryPermissionsPolicy</code>, the resource policy on the repository is ignored when evaluting permissions. This ensures that the owner of a repository cannot lock themselves out of the repository, which would prevent them from being able to update the resource policy. </p>

    Args:
        domain: <p> The name of the domain containing the repository to set the resource policy on. </p>
        domain_owner: <p> The 12-digit account number of the Amazon Web Services account that owns the domain. It does not include dashes or spaces. </p>
        repository: <p> The name of the repository to set the resource policy on. </p>
        policy_revision: <p> Sets the revision of the resource policy that specifies permissions to access the repository. This revision is used for optimistic locking, which prevents others from overwriting your changes to the repository's resource policy. </p>
        policy_document: <p> A valid displayable JSON Aspen policy string to be set as the access control resource policy on the provided repository. </p>

    Raises:
        capo_codeartifact.errors.access_denied_exception.AccessDeniedException: <p> The operation did not succeed because of an unauthorized access attempt. </p>
        capo_codeartifact.errors.conflict_exception.ConflictException: <p> The operation did not succeed because prerequisites are not met. </p>
        capo_codeartifact.errors.internal_server_exception.InternalServerException: <p> The operation did not succeed because of an error that occurred inside CodeArtifact. </p>
        capo_codeartifact.errors.resource_not_found_exception.ResourceNotFoundException: <p> The operation did not succeed because the resource requested is not found in the service. </p>
        capo_codeartifact.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p> The operation did not succeed because it would have exceeded a service limit for your account. </p>
        capo_codeartifact.errors.throttling_exception.ThrottlingException: <p> The operation did not succeed because too many requests are sent to the service. </p>
        capo_codeartifact.errors.validation_exception.ValidationException: <p> The operation did not succeed because a parameter in the request was sent with an invalid value. </p>
        capo_codeartifact.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codeartifact.types.put_repository_permissions_policy_request.PutRepositoryPermissionsPolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_codeartifact.types.put_repository_permissions_policy_result.PutRepositoryPermissionsPolicyResult"
    ]:
        import capo_codeartifact._operations.code_artifact_control_plane_service.put_repository_permissions_policy

        (
            output,
            http_response,
        ) = await capo_codeartifact._operations.code_artifact_control_plane_service.put_repository_permissions_policy.async_put_repository_permissions_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutRepositoryPermissionsPolicy")
    )
    input_: capo_codeartifact.types.put_repository_permissions_policy_request.PutRepositoryPermissionsPolicyRequest = {
        "domain": domain,
        "repository": repository,
        "policy_document": policy_document,
    }
    if domain_owner is not None:
        input_["domain_owner"] = domain_owner
    if policy_revision is not None:
        input_["policy_revision"] = policy_revision

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