Skip to content

update_rule async

update_rule(
    rule_identifier: RuleIdentifier,
    update_token: UpdateToken,
    is_published: IsPublished,
    *,
    config_overrides: Optional[AsyncNetworkSecurityManagerClientConfig] = None,
    rule_type: Optional[RuleType] = None,
    rule_description: Optional[Description] = None,
    configuration: Optional[JsonDocument] = None,
    client_token: Optional[IdempotencyToken] = None,
) -> UpdateRuleOutput

Updates the specified rule. To prevent conflicting concurrent updates, provide the current updateToken. Use isPublished to publish the update or keep the rule as a draft.

Parameters:

  • rule_identifier (RuleIdentifier) –

    The identifier of the rule. This is the rule's Amazon Resource Name (ARN).

  • update_token (UpdateToken) –

    A token used for optimistic concurrency control. Each read and write returns an updateToken. Provide the most recent value on your next update to detect and prevent conflicting concurrent modifications.

  • rule_type (Optional[RuleType], default: None ) –

    The type of the rule. CONFIGURATION rules contain firewall settings, and INSPECTION rules contain rule groups.

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

    A description of the rule.

  • configuration (Optional[JsonDocument], default: None ) –

    The firewall configuration for the rule, as a JSON document. The structure depends on the rule's firewall type and rule type. For an AWS WAF INSPECTION rule, provide an AWS WAF rule group. For an AWS WAF CONFIGURATION rule, provide a single web ACL setting, such as DefaultAction or VisibilityConfig; use wafConfigDataType to declare which setting the document contains. For the schema of each setting and complete examples, see Writing rule configurations in the AWS Network Security Manager Developer Guide.

  • is_published (IsPublished) –

    Specifies whether to publish the resource. When true, the resource is saved in published (ACTIVE) state. When false, it is saved as a draft (DRAFT).

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

    A unique, case-sensitive token that you provide to ensure that the operation completes no more than one time. If you retry a request with the same client token and the same parameters, the service returns the result of the original successful request.

Raises:

  • AccessDeniedException –

    You do not have sufficient permissions to perform this action.

  • ConflictException –

    The request conflicts with the current state of the resource. For example, the resource was modified concurrently, or it is in a state that does not allow the requested operation.

  • InternalServerException –

    The request processing failed because of an internal error in the service. This is a retryable error.

  • ResourceNotFoundException –

    The specified resource was not found. Verify that the resource identifier is correct and that the resource exists, then try your request again.

  • ServiceQuotaExceededException –

    The request would exceed a service quota.

  • ThrottlingException –

    The request was denied because of request throttling. Reduce your request rate and try again.

  • ValidationException –

    The request failed validation. For details, see the reason and fieldList members of the response.

  • UnknownServiceError –

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

Examples:

Update a rule and publish it Updates the rule's description and configuration and publishes the change. The updateToken from the most recent read is required for optimistic locking.

>>> await client.update_rule(rule_identifier='arn:aws:network-security-manager:us-east-1:123456789012:rule:abc123', update_token='c1d2e3f4-4a5b-4c6d-9e7f-8a9b0c1d2e3f', rule_type='INSPECTION', rule_description='Blocks requests from known malicious IP addresses - updated list', configuration={}, is_published=True)
Source code in docs_src/capo_network_security_manager/_services/async_network_security_manager.py
async def update_rule(
    self,
    rule_identifier: "capo_network_security_manager.types.rule_identifier.RuleIdentifier",
    update_token: "capo_network_security_manager.types.update_token.UpdateToken",
    is_published: "capo_network_security_manager.types.is_published.IsPublished",
    *,
    config_overrides: Optional[AsyncNetworkSecurityManagerClientConfig] = None,
    rule_type: Optional[
        "capo_network_security_manager.types.rule_type.RuleType"
    ] = None,
    rule_description: Optional[
        "capo_network_security_manager.types.description.Description"
    ] = None,
    configuration: Optional[
        "capo_network_security_manager.types.json_document.JsonDocument"
    ] = None,
    client_token: Optional[
        "capo_network_security_manager.types.idempotency_token.IdempotencyToken"
    ] = None,
) -> "capo_network_security_manager.types.update_rule_output.UpdateRuleOutput":
    """<p>Updates the specified rule. To prevent conflicting concurrent updates, provide the current <code>updateToken</code>. Use <code>isPublished</code> to publish the update or keep the rule as a draft.</p>

    Args:
        rule_identifier: <p>The identifier of the rule. This is the rule's Amazon Resource Name (ARN).</p>
        update_token: <p>A token used for optimistic concurrency control. Each read and write returns an <code>updateToken</code>. Provide the most recent value on your next update to detect and prevent conflicting concurrent modifications.</p>
        rule_type: <p>The type of the rule. <code>CONFIGURATION</code> rules contain firewall settings, and <code>INSPECTION</code> rules contain rule groups.</p>
        rule_description: <p>A description of the rule.</p>
        configuration: <p>The firewall configuration for the rule, as a JSON document. The structure depends on the rule's firewall type and rule type. For an AWS WAF <code>INSPECTION</code> rule, provide an AWS WAF rule group. For an AWS WAF <code>CONFIGURATION</code> rule, provide a single web ACL setting, such as <code>DefaultAction</code> or <code>VisibilityConfig</code>; use <code>wafConfigDataType</code> to declare which setting the document contains. For the schema of each setting and complete examples, see <a href="https://docs.aws.amazon.com/network-security-manager/latest/devguide/what-is.html">Writing rule configurations</a> in the <i>AWS Network Security Manager Developer Guide</i>.</p>
        is_published: <p>Specifies whether to publish the resource. When <code>true</code>, the resource is saved in published (<code>ACTIVE</code>) state. When <code>false</code>, it is saved as a draft (<code>DRAFT</code>).</p>
        client_token: <p>A unique, case-sensitive token that you provide to ensure that the operation completes no more than one time. If you retry a request with the same client token and the same parameters, the service returns the result of the original successful request.</p>

    Raises:
        capo_network_security_manager.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient permissions to perform this action.</p>
        capo_network_security_manager.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. For example, the resource was modified concurrently, or it is in a state that does not allow the requested operation.</p>
        capo_network_security_manager.errors.internal_server_exception.InternalServerException: <p>The request processing failed because of an internal error in the service. This is a retryable error.</p>
        capo_network_security_manager.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found. Verify that the resource identifier is correct and that the resource exists, then try your request again.</p>
        capo_network_security_manager.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service quota.</p>
        capo_network_security_manager.errors.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling. Reduce your request rate and try again.</p>
        capo_network_security_manager.errors.validation_exception.ValidationException: <p>The request failed validation. For details, see the <code>reason</code> and <code>fieldList</code> members of the response.</p>
        capo_network_security_manager.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Update a rule and publish it
        Updates the rule's description and configuration and publishes the change. The updateToken from the most recent read is required for optimistic locking.

        >>> await client.update_rule(rule_identifier='arn:aws:network-security-manager:us-east-1:123456789012:rule:abc123', update_token='c1d2e3f4-4a5b-4c6d-9e7f-8a9b0c1d2e3f', rule_type='INSPECTION', rule_description='Blocks requests from known malicious IP addresses - updated list', configuration={}, is_published=True)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_network_security_manager.types.update_rule_input.UpdateRuleInput]",
    ) -> AsyncOperationResponse[
        "capo_network_security_manager.types.update_rule_output.UpdateRuleOutput"
    ]:
        import capo_network_security_manager._operations.piccolo_customer_api_service.update_rule

        (
            output,
            http_response,
        ) = await capo_network_security_manager._operations.piccolo_customer_api_service.update_rule.async_update_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateRule")
    )
    input_: capo_network_security_manager.types.update_rule_input.UpdateRuleInput = {
        "rule_identifier": rule_identifier,
        "update_token": update_token,
        "is_published": is_published,
    }
    if rule_type is not None:
        input_["rule_type"] = rule_type
    if rule_description is not None:
        input_["rule_description"] = rule_description
    if configuration is not None:
        input_["configuration"] = configuration
    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