Skip to content

create_insight async

create_insight(
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    name: Optional[NonEmptyString] = None,
    filters: Optional[AwsSecurityFindingFilters] = None,
    group_by_attribute: Optional[NonEmptyString] = None,
) -> CreateInsightResponse

Creates a custom insight in Security Hub CSPM. An insight is a consolidation of findings that relate to a security issue that requires attention or remediation.

To group the related findings in the insight, use the GroupByAttribute.

Parameters:

  • name (Optional[NonEmptyString], default: None ) –

    The name of the custom insight to create.

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

    One or more attributes used to filter the findings included in the insight. The insight only includes findings that match the criteria defined in the filters.

  • group_by_attribute (Optional[NonEmptyString], default: None ) –

    The attribute used to group the findings for the insight. The grouping attribute identifies the type of item that the insight applies to. For example, if an insight is grouped by resource identifier, then the insight produces a list of resource identifiers.

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.

  • ResourceConflictException –

    The resource specified in the request conflicts with an existing resource.

  • UnknownServiceError –

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

Examples:

To create a custom insight The following example creates a custom insight in Security Hub. An insight is a collection of findings that relate to a security issue.

>>> await client.create_insight(name='Critical role findings', filters={'ResourceType': [{'Comparison': 'EQUALS', 'Value': 'AwsIamRole'}], 'SeverityLabel': [{'Comparison': 'EQUALS', 'Value': 'CRITICAL'}]}, group_by_attribute='ResourceId')
Source code in docs_src/capo_securityhub/_services/async_security_hub.py
async def create_insight(
    self,
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    name: Optional["capo_securityhub.types.non_empty_string.NonEmptyString"] = None,
    filters: Optional[
        "capo_securityhub.types.aws_security_finding_filters.AwsSecurityFindingFilters"
    ] = None,
    group_by_attribute: Optional[
        "capo_securityhub.types.non_empty_string.NonEmptyString"
    ] = None,
) -> "capo_securityhub.types.create_insight_response.CreateInsightResponse":
    """<p>Creates a custom insight in Security Hub CSPM. An insight is a consolidation of findings that relate to a security issue that requires attention or remediation.</p> <p>To group the related findings in the insight, use the <code>GroupByAttribute</code>.</p>

    Args:
        name: <p>The name of the custom insight to create.</p>
        filters: <p>One or more attributes used to filter the findings included in the insight. The insight only includes findings that match the criteria defined in the filters.</p>
        group_by_attribute: <p>The attribute used to group the findings for the insight. The grouping attribute identifies the type of item that the insight applies to. For example, if an insight is grouped by resource identifier, then the insight produces a list of resource identifiers.</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.resource_conflict_exception.ResourceConflictException: <p>The resource specified in the request conflicts with an existing resource.</p>
        capo_securityhub.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a custom insight
        The following example creates a custom insight in Security Hub. An insight is a collection of findings that relate to a security issue.

        >>> await client.create_insight(name='Critical role findings', filters={'ResourceType': [{'Comparison': 'EQUALS', 'Value': 'AwsIamRole'}], 'SeverityLabel': [{'Comparison': 'EQUALS', 'Value': 'CRITICAL'}]}, group_by_attribute='ResourceId')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityhub.types.create_insight_request.CreateInsightRequest]",
    ) -> AsyncOperationResponse[
        "capo_securityhub.types.create_insight_response.CreateInsightResponse"
    ]:
        import capo_securityhub._operations.security_hub_api_service.create_insight

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateInsight")
    )
    input_: capo_securityhub.types.create_insight_request.CreateInsightRequest = {}
    if name is not None:
        input_["name"] = name
    if filters is not None:
        input_["filters"] = filters
    if group_by_attribute is not None:
        input_["group_by_attribute"] = group_by_attribute

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