Skip to content

get_findings async

get_findings(
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    filters: Optional[AwsSecurityFindingFilters] = None,
    sort_criteria: Optional[SortCriteria] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
) -> GetFindingsResponse

Returns a list of findings that match the specified criteria.

If cross-Region aggregation is enabled, then when you call GetFindings from the home Region, the results include all of the matching findings from both the home Region and linked Regions.

Parameters:

  • filters (Optional[AwsSecurityFindingFilters], default: None ) –

    The finding attributes used to define a condition to filter the returned findings.

    You can filter by up to 10 finding attributes. For each attribute, you can provide up to 20 filter values.

    Note that in the available filter fields, WorkflowState is deprecated. To search for a finding based on its workflow status, use WorkflowStatus.

  • sort_criteria (Optional[SortCriteria], default: None ) –

    The finding attributes used to sort the list of returned findings.

  • next_token (Optional[NextToken], default: None ) –

    The token that is required for pagination. On your first call to the GetFindings operation, set the value of this parameter to NULL.

    For subsequent calls to the operation, to continue listing data, set the value of this parameter to the value returned from the previous response.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of findings to return.

Raises:

  • InternalException –

    Internal server error.

  • InvalidAccessException –

    The account doesn't have permission to perform this action.

  • InvalidInputException –

    The request was rejected because you supplied an invalid or out-of-range value for an input parameter.

  • LimitExceededException –

    The request was rejected because it attempted to create resources beyond the current Amazon Web Services account or throttling limits. The error code describes the limit exceeded.

  • UnknownServiceError –

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

Examples:

To get a list of findings The following example returns a filtered and sorted list of Security Hub findings.

>>> await client.get_findings(filters={'AwsAccountId': [{'Value': '123456789012', 'Comparison': 'PREFIX'}]}, max_results=1)
Source code in docs_src/capo_securityhub/_services/async_security_hub.py
async def get_findings(
    self,
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    filters: Optional[
        "capo_securityhub.types.aws_security_finding_filters.AwsSecurityFindingFilters"
    ] = None,
    sort_criteria: Optional[
        "capo_securityhub.types.sort_criteria.SortCriteria"
    ] = None,
    next_token: Optional["capo_securityhub.types.next_token.NextToken"] = None,
    max_results: Optional["capo_securityhub.types.max_results.MaxResults"] = None,
) -> "capo_securityhub.types.get_findings_response.GetFindingsResponse":
    """<p>Returns a list of findings that match the specified criteria.</p> <p>If cross-Region aggregation is enabled, then when you call <code>GetFindings</code> from the home Region, the results include all of the matching findings from both the home Region and linked Regions.</p>

    Args:
        filters: <p>The finding attributes used to define a condition to filter the returned findings.</p> <p>You can filter by up to 10 finding attributes. For each attribute, you can provide up to 20 filter values.</p> <p>Note that in the available filter fields, <code>WorkflowState</code> is deprecated. To search for a finding based on its workflow status, use <code>WorkflowStatus</code>.</p>
        sort_criteria: <p>The finding attributes used to sort the list of returned findings.</p>
        next_token: <p>The token that is required for pagination. On your first call to the <code>GetFindings</code> operation, set the value of this parameter to <code>NULL</code>.</p> <p>For subsequent calls to the operation, to continue listing data, set the value of this parameter to the value returned from the previous response.</p>
        max_results: <p>The maximum number of findings to return.</p>

    Raises:
        capo_securityhub.errors.internal_exception.InternalException: <p>Internal server error.</p>
        capo_securityhub.errors.invalid_access_exception.InvalidAccessException: <p>The account doesn't have permission to perform this action.</p>
        capo_securityhub.errors.invalid_input_exception.InvalidInputException: <p>The request was rejected because you supplied an invalid or out-of-range value for an input parameter.</p>
        capo_securityhub.errors.limit_exceeded_exception.LimitExceededException: <p>The request was rejected because it attempted to create resources beyond the current Amazon Web Services account or throttling limits. The error code describes the limit exceeded.</p>
        capo_securityhub.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To get a list of findings
        The following example returns a filtered and sorted list of Security Hub findings.

        >>> await client.get_findings(filters={'AwsAccountId': [{'Value': '123456789012', 'Comparison': 'PREFIX'}]}, max_results=1)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityhub.types.get_findings_request.GetFindingsRequest]",
    ) -> AsyncOperationResponse[
        "capo_securityhub.types.get_findings_response.GetFindingsResponse"
    ]:
        import capo_securityhub._operations.security_hub_api_service.get_findings

        (
            output,
            http_response,
        ) = await capo_securityhub._operations.security_hub_api_service.get_findings.async_get_findings(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetFindings")
    )
    input_: capo_securityhub.types.get_findings_request.GetFindingsRequest = {}
    if filters is not None:
        input_["filters"] = filters
    if sort_criteria is not None:
        input_["sort_criteria"] = sort_criteria
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

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