Skip to content

create_filter

create_filter(
    action: FilterAction,
    filter_criteria: FilterCriteria,
    name: FilterName,
    *,
    config_overrides: Optional[Inspector2ClientConfig] = None,
    description: Optional[FilterDescription] = None,
    tags: Optional[TagMap] = None,
    reason: Optional[FilterReason] = None,
) -> CreateFilterResponse

Creates a filter resource using specified filter criteria. When the filter action is set to SUPPRESS this action creates a suppression rule.

Parameters:

  • action (FilterAction) –

    Defines the action that is to be applied to the findings that match the filter.

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

    A description of the filter.

  • filter_criteria (FilterCriteria) –

    Defines the criteria to be used in the filter for querying findings.

  • name (FilterName) –

    The name of the filter. Minimum length of 3. Maximum length of 64. Valid characters include alphanumeric characters, dot (.), underscore (_), and dash (-). Spaces are not allowed.

  • tags (Optional[TagMap], default: None ) –

    A list of tags for the filter.

  • reason (Optional[FilterReason], default: None ) –

    The reason for creating the filter.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

    For Enable, you receive this error if you attempt to use a feature in an unsupported Amazon Web Services Region.

  • BadRequestException –

    One or more tags submitted as part of the request is not valid.

  • InternalServerException –

    The request has failed due to an internal failure of the Amazon Inspector service.

  • ServiceQuotaExceededException –

    You have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.

  • ThrottlingException –

    The limit on the number of requests per second was exceeded.

  • ValidationException –

    The request has failed validation due to missing required fields or having invalid inputs.

  • UnknownServiceError –

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

Source code in docs_src/capo_inspector2/_services/inspector2.py
def create_filter(
    self,
    action: "capo_inspector2.types.filter_action.FilterAction",
    filter_criteria: "capo_inspector2.types.filter_criteria.FilterCriteria",
    name: "capo_inspector2.types.filter_name.FilterName",
    *,
    config_overrides: Optional[Inspector2ClientConfig] = None,
    description: Optional[
        "capo_inspector2.types.filter_description.FilterDescription"
    ] = None,
    tags: Optional["capo_inspector2.types.tag_map.TagMap"] = None,
    reason: Optional["capo_inspector2.types.filter_reason.FilterReason"] = None,
) -> "capo_inspector2.types.create_filter_response.CreateFilterResponse":
    """<p>Creates a filter resource using specified filter criteria. When the filter action is set to <code>SUPPRESS</code> this action creates a suppression rule.</p>

    Args:
        action: <p>Defines the action that is to be applied to the findings that match the filter.</p>
        description: <p>A description of the filter.</p>
        filter_criteria: <p>Defines the criteria to be used in the filter for querying findings.</p>
        name: <p>The name of the filter. Minimum length of 3. Maximum length of 64. Valid characters include alphanumeric characters, dot (.), underscore (_), and dash (-). Spaces are not allowed.</p>
        tags: <p>A list of tags for the filter.</p>
        reason: <p>The reason for creating the filter.</p>

    Raises:
        capo_inspector2.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p> <p> For <code>Enable</code>, you receive this error if you attempt to use a feature in an unsupported Amazon Web Services Region. </p>
        capo_inspector2.errors.bad_request_exception.BadRequestException: <p>One or more tags submitted as part of the request is not valid.</p>
        capo_inspector2.errors.internal_server_exception.InternalServerException: <p>The request has failed due to an internal failure of the Amazon Inspector service.</p>
        capo_inspector2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.</p>
        capo_inspector2.errors.throttling_exception.ThrottlingException: <p>The limit on the number of requests per second was exceeded.</p>
        capo_inspector2.errors.validation_exception.ValidationException: <p>The request has failed validation due to missing required fields or having invalid inputs.</p>
        capo_inspector2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_inspector2.types.create_filter_request.CreateFilterRequest]",
    ) -> OperationResponse[
        "capo_inspector2.types.create_filter_response.CreateFilterResponse"
    ]:
        import capo_inspector2._operations.inspector2.create_filter

        output, http_response = (
            capo_inspector2._operations.inspector2.create_filter.create_filter(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateFilter")
    )
    input_: capo_inspector2.types.create_filter_request.CreateFilterRequest = {
        "action": action,
        "filter_criteria": filter_criteria,
        "name": name,
    }
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if reason is not None:
        input_["reason"] = reason

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