Skip to content

create_rule async

create_rule(
    domain_identifier: DomainId,
    name: RuleName,
    target: RuleTarget,
    action: RuleAction,
    scope: RuleScope,
    detail: RuleDetail,
    *,
    config_overrides: Optional[AsyncDataZoneClientConfig] = None,
    description: Optional[Description] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateRuleOutput

Creates a rule in Amazon DataZone. A rule is a formal agreement that enforces specific requirements across user workflows (e.g., publishing assets to the catalog, requesting subscriptions, creating projects) within the Amazon DataZone data portal. These rules help maintain consistency, ensure compliance, and uphold governance standards in data management processes. For instance, a metadata enforcement rule can specify the required information for creating a subscription request or publishing a data asset to the catalog, ensuring alignment with organizational standards.

Parameters:

  • domain_identifier (DomainId) –

    The ID of the domain where the rule is created.

  • name (RuleName) –

    The name of the rule.

  • target (RuleTarget) –

    The target of the rule.

  • action (RuleAction) –

    The action of the rule.

  • scope (RuleScope) –

    The scope of the rule.

  • detail (RuleDetail) –

    The detail of the rule.

  • description (Optional[Description], default: None ) –

    The description of the rule.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that is provided to ensure the idempotency of the request.

Raises:

Source code in docs_src/capo_datazone/_services/async_data_zone.py
async def create_rule(
    self,
    domain_identifier: "capo_datazone.types.domain_id.DomainId",
    name: "capo_datazone.types.rule_name.RuleName",
    target: "capo_datazone.types.rule_target.RuleTarget",
    action: "capo_datazone.types.rule_action.RuleAction",
    scope: "capo_datazone.types.rule_scope.RuleScope",
    detail: "capo_datazone.types.rule_detail.RuleDetail",
    *,
    config_overrides: Optional[AsyncDataZoneClientConfig] = None,
    description: Optional["capo_datazone.types.description.Description"] = None,
    client_token: Optional["capo_datazone.types.client_token.ClientToken"] = None,
) -> "capo_datazone.types.create_rule_output.CreateRuleOutput":
    """<p>Creates a rule in Amazon DataZone. A rule is a formal agreement that enforces specific requirements across user workflows (e.g., publishing assets to the catalog, requesting subscriptions, creating projects) within the Amazon DataZone data portal. These rules help maintain consistency, ensure compliance, and uphold governance standards in data management processes. For instance, a metadata enforcement rule can specify the required information for creating a subscription request or publishing a data asset to the catalog, ensuring alignment with organizational standards.</p>

    Args:
        domain_identifier: <p>The ID of the domain where the rule is created.</p>
        name: <p>The name of the rule.</p>
        target: <p>The target of the rule.</p>
        action: <p>The action of the rule.</p>
        scope: <p>The scope of the rule.</p>
        detail: <p>The detail of the rule.</p>
        description: <p>The description of the rule.</p>
        client_token: <p>A unique, case-sensitive identifier that is provided to ensure the idempotency of the request.</p>

    Raises:
        capo_datazone.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_datazone.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_datazone.errors.unauthorized_exception.UnauthorizedException: <p>You do not have permission to perform this action.</p>
        capo_datazone.errors.conflict_exception.ConflictException: <p>There is a conflict while performing this action.</p>
        capo_datazone.errors.internal_server_exception.InternalServerException: <p>The request has failed because of an unknown error, exception or failure.</p>
        capo_datazone.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource cannot be found.</p>
        capo_datazone.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request has exceeded the specified service quota.</p>
        capo_datazone.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the Amazon Web Services service.</p>
        capo_datazone.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_datazone.types.create_rule_input.CreateRuleInput]",
    ) -> AsyncOperationResponse[
        "capo_datazone.types.create_rule_output.CreateRuleOutput"
    ]:
        import capo_datazone._operations.data_zone.create_rule

        (
            output,
            http_response,
        ) = await capo_datazone._operations.data_zone.create_rule.async_create_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_datazone.types.create_rule_input.CreateRuleInput",
    ) -> dict[str, Any]:
        import capo_datazone.types.create_rule_input

        return capo_datazone.types.create_rule_input.redact_sensitive(input_)

    def _redact_output(
        output: "capo_datazone.types.create_rule_output.CreateRuleOutput",
    ) -> dict[str, Any]:
        import capo_datazone.types.create_rule_output

        return capo_datazone.types.create_rule_output.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateRule", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_datazone.types.create_rule_input.CreateRuleInput = {
        "domain_identifier": domain_identifier,
        "name": name,
        "target": target,
        "action": action,
        "scope": scope,
        "detail": detail,
    }
    if description is not None:
        input_["description"] = description
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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