Skip to content

put_policy_assignment

put_policy_assignment(
    account_id: AwsAccountId,
    policy_arn: PolicyArn,
    principal_arn: PrincipalArn,
    *,
    config_overrides: Optional[QuickSightClientConfig] = None,
    existing_policy_arn: Optional[PolicyArn] = None,
    revision: Optional[Revision] = None,
) -> PutPolicyAssignmentResponse

Assigns a governance policy to an Amazon Quick Sight principal. A principal can have one policy of each policy type. If the principal already has a policy of the same type, this operation replaces it.

To make the change conditional, specify ExistingPolicyArn, Revision, or both. If the current assignment doesn't match, the request fails with a ConflictException and makes no change. If the principal already has the specified policy, the request succeeds and makes no change.

Parameters:

  • account_id (AwsAccountId) –

    The ID of the Amazon Web Services account that contains the policy and the principal.

  • policy_arn (PolicyArn) –

    The Amazon Resource Name (ARN) of the policy to assign.

  • principal_arn (PrincipalArn) –

    The ARN of the user, group, or account to assign the policy to.

  • existing_policy_arn (Optional[PolicyArn], default: None ) –

    The ARN of the policy that you expect the principal to have before this request. If the principal has a different policy of the same type, or no policy of that type, the request fails with a ConflictException and makes no change. If you don't specify a value, the operation doesn't check the existing assignment.

  • revision (Optional[Revision], default: None ) –

    The revision of the assignment from your most recent read. If the assignment has changed since that revision, the request fails with a ConflictException. If you don't specify a value, the operation doesn't check the revision.

Raises:

  • AccessDeniedException –

    You don't have access to this item. The provided credentials couldn't be validated. You might not be authorized to carry out the request. Make sure that your account is authorized to use the Amazon Quick Sight service, that your policies have the correct permissions, and that you are using the correct credentials.

  • ConflictException –

    Updating or deleting a resource can cause an inconsistent state.

  • InternalFailureException –

    An internal failure occurred.

  • ResourceNotFoundException –

    One or more resources can't be found.

  • ThrottlingException –

    Access is throttled.

  • ValidationException –

    The input fails to satisfy the constraints specified by the service.

  • UnknownServiceError –

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

Source code in docs_src/capo_quicksight/_services/quick_sight.py
def put_policy_assignment(
    self,
    account_id: "capo_quicksight.types.aws_account_id.AwsAccountId",
    policy_arn: "capo_quicksight.types.policy_arn.PolicyArn",
    principal_arn: "capo_quicksight.types.principal_arn.PrincipalArn",
    *,
    config_overrides: Optional[QuickSightClientConfig] = None,
    existing_policy_arn: Optional[
        "capo_quicksight.types.policy_arn.PolicyArn"
    ] = None,
    revision: Optional["capo_quicksight.types.revision.Revision"] = None,
) -> "capo_quicksight.types.put_policy_assignment_response.PutPolicyAssignmentResponse":
    """<p>Assigns a governance policy to an Amazon Quick Sight principal. A principal can have one policy of each policy type. If the principal already has a policy of the same type, this operation replaces it.</p> <p>To make the change conditional, specify <code>ExistingPolicyArn</code>, <code>Revision</code>, or both. If the current assignment doesn't match, the request fails with a <code>ConflictException</code> and makes no change. If the principal already has the specified policy, the request succeeds and makes no change.</p>

    Args:
        account_id: <p>The ID of the Amazon Web Services account that contains the policy and the principal.</p>
        policy_arn: <p>The Amazon Resource Name (ARN) of the policy to assign.</p>
        principal_arn: <p>The ARN of the user, group, or account to assign the policy to.</p>
        existing_policy_arn: <p>The ARN of the policy that you expect the principal to have before this request. If the principal has a different policy of the same type, or no policy of that type, the request fails with a <code>ConflictException</code> and makes no change. If you don't specify a value, the operation doesn't check the existing assignment.</p>
        revision: <p>The revision of the assignment from your most recent read. If the assignment has changed since that revision, the request fails with a <code>ConflictException</code>. If you don't specify a value, the operation doesn't check the revision.</p>

    Raises:
        capo_quicksight.errors.access_denied_exception.AccessDeniedException: <p>You don't have access to this item. The provided credentials couldn't be validated. You might not be authorized to carry out the request. Make sure that your account is authorized to use the Amazon Quick Sight service, that your policies have the correct permissions, and that you are using the correct credentials.</p>
        capo_quicksight.errors.conflict_exception.ConflictException: <p>Updating or deleting a resource can cause an inconsistent state.</p>
        capo_quicksight.errors.internal_failure_exception.InternalFailureException: <p>An internal failure occurred.</p>
        capo_quicksight.errors.resource_not_found_exception.ResourceNotFoundException: <p>One or more resources can't be found.</p>
        capo_quicksight.errors.throttling_exception.ThrottlingException: <p>Access is throttled.</p>
        capo_quicksight.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_quicksight.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_quicksight.types.put_policy_assignment_request.PutPolicyAssignmentRequest]",
    ) -> OperationResponse[
        "capo_quicksight.types.put_policy_assignment_response.PutPolicyAssignmentResponse"
    ]:
        import capo_quicksight._operations.quick_sight_20180401.put_policy_assignment

        output, http_response = (
            capo_quicksight._operations.quick_sight_20180401.put_policy_assignment.put_policy_assignment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutPolicyAssignment")
    )
    input_: capo_quicksight.types.put_policy_assignment_request.PutPolicyAssignmentRequest = {
        "account_id": account_id,
        "policy_arn": policy_arn,
        "principal_arn": principal_arn,
    }
    if existing_policy_arn is not None:
        input_["existing_policy_arn"] = existing_policy_arn
    if revision is not None:
        input_["revision"] = revision

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