Skip to content

attach_rls_policy

attach_rls_policy(
    name: NameString,
    resource: Resource,
    *,
    config_overrides: Optional[LakeFormationClientConfig] = None,
    principal: Optional[DataLakePrincipal] = None,
    condition: Optional[Condition] = None,
    set_default: Optional[NullableBoolean] = None,
) -> AttachRLSPolicyResponse

Attaches a row-level security policy to a resource for a principal. When the principal queries the resource, Lake Formation applies the policy's filter expression so that only the permitted rows are returned.

Parameters:

  • name (NameString) –

    The name of the row-level security policy to attach.

  • resource (Resource) –

    The resource to which the row-level security policy is attached.

  • principal (Optional[DataLakePrincipal], default: None ) –

    The principal to which the row-level security policy applies.

  • condition (Optional[Condition], default: None ) –

    A Lake Formation condition, which applies to the row-level security policy attachment and contains an expression.

  • set_default (Optional[NullableBoolean], default: None ) –

    Indicates whether this policy becomes the default row-level security policy for the resource. The default policy applies to all principals by default.

Raises:

Source code in docs_src/capo_lakeformation/_services/lake_formation.py
def attach_rls_policy(
    self,
    name: "capo_lakeformation.types.name_string.NameString",
    resource: "capo_lakeformation.types.resource.Resource",
    *,
    config_overrides: Optional[LakeFormationClientConfig] = None,
    principal: Optional[
        "capo_lakeformation.types.data_lake_principal.DataLakePrincipal"
    ] = None,
    condition: Optional["capo_lakeformation.types.condition.Condition"] = None,
    set_default: Optional[
        "capo_lakeformation.types.nullable_boolean.NullableBoolean"
    ] = None,
) -> "capo_lakeformation.types.attach_rls_policy_response.AttachRLSPolicyResponse":
    """<p>Attaches a row-level security policy to a resource for a principal. When the principal queries the resource, Lake Formation applies the policy's filter expression so that only the permitted rows are returned.</p>

    Args:
        name: <p>The name of the row-level security policy to attach.</p>
        resource: <p>The resource to which the row-level security policy is attached.</p>
        principal: <p>The principal to which the row-level security policy applies.</p>
        condition: <p>A Lake Formation condition, which applies to the row-level security policy attachment and contains an expression.</p>
        set_default: <p>Indicates whether this policy becomes the default row-level security policy for the resource. The default policy applies to all principals by default.</p>

    Raises:
        capo_lakeformation.errors.access_denied_exception.AccessDeniedException: <p>Access to a resource was denied.</p>
        capo_lakeformation.errors.already_exists_exception.AlreadyExistsException: <p>A resource to be created or added already exists.</p>
        capo_lakeformation.errors.concurrent_modification_exception.ConcurrentModificationException: <p>Two processes are trying to modify a resource simultaneously.</p>
        capo_lakeformation.errors.entity_not_found_exception.EntityNotFoundException: <p>A specified entity does not exist.</p>
        capo_lakeformation.errors.internal_service_exception.InternalServiceException: <p>An internal service error occurred.</p>
        capo_lakeformation.errors.invalid_input_exception.InvalidInputException: <p>The input provided was not valid.</p>
        capo_lakeformation.errors.operation_timeout_exception.OperationTimeoutException: <p>The operation timed out.</p>
        capo_lakeformation.errors.resource_number_limit_exceeded_exception.ResourceNumberLimitExceededException: <p>A resource numerical limit was exceeded.</p>
        capo_lakeformation.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lakeformation.types.attach_rls_policy_request.AttachRLSPolicyRequest]",
    ) -> OperationResponse[
        "capo_lakeformation.types.attach_rls_policy_response.AttachRLSPolicyResponse"
    ]:
        import capo_lakeformation._operations.aws_lake_formation.attach_rls_policy

        output, http_response = (
            capo_lakeformation._operations.aws_lake_formation.attach_rls_policy.attach_rls_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AttachRLSPolicy")
    )
    input_: capo_lakeformation.types.attach_rls_policy_request.AttachRLSPolicyRequest = {
        "name": name,
        "resource": resource,
    }
    if principal is not None:
        input_["principal"] = principal
    if condition is not None:
        input_["condition"] = condition
    if set_default is not None:
        input_["set_default"] = set_default

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