Skip to content

get_software_statistics_v2

get_software_statistics_v2(
    *,
    config_overrides: Optional[SecurityHubClientConfig] = None,
    group_by_rules: Optional[SoftwareGroupByRules] = None,
    scopes: Optional[SoftwareScopes] = None,
    sort_order: Optional[SortOrder] = None,
    max_statistic_results: Optional[MaxStatisticResults] = None,
) -> GetSoftwareStatisticsV2Response

Retrieves aggregated counts of software packages installed on your resources, grouped by a field that you specify. For example, you can return the most common package types or the accounts with the most installed packages.

Each count is the number of package-to-resource pairs that match the grouping value. A package installed on three resources contributes three to the count.

You can use the Scopes parameter to define the data boundary for the query. Currently, Scopes supports AwsOrganizations. With AwsOrganizations, you can aggregate software from your entire organization or from specific organizational units. Only the delegated administrator account can use Scopes.

This operation doesn't paginate. Use MaxStatisticResults to control how many grouping values are returned.

Parameters:

  • group_by_rules (Optional[SoftwareGroupByRules], default: None ) –

    How software statistics should be aggregated and organized in the response.

  • scopes (Optional[SoftwareScopes], default: None ) –

    Limits the results to software on resources from specific organizational units or from the delegated administrator's organization. Only the delegated administrator account can use this parameter. Other accounts receive an AccessDeniedException.

    This parameter is optional. If you omit it, the delegated administrator sees statistics from all accounts across the entire organization. Other accounts see only statistics for software on their own resources.

    You can specify up to 10 entries in Scopes.AwsOrganizations. If multiple entries are specified, the entries are combined using OR logic.

  • sort_order (Optional[SortOrder], default: None ) –

    Sorts aggregated statistics by count. The default is descending, which returns the values with the highest counts first.

  • max_statistic_results (Optional[MaxStatisticResults], default: None ) –

    The maximum number of grouping values to return. Valid values are 1–400. The default is 400.

Raises:

Source code in docs_src/capo_securityhub/_services/security_hub.py
def get_software_statistics_v2(
    self,
    *,
    config_overrides: Optional[SecurityHubClientConfig] = None,
    group_by_rules: Optional[
        "capo_securityhub.types.software_group_by_rules.SoftwareGroupByRules"
    ] = None,
    scopes: Optional[
        "capo_securityhub.types.software_scopes.SoftwareScopes"
    ] = None,
    sort_order: Optional["capo_securityhub.types.sort_order.SortOrder"] = None,
    max_statistic_results: Optional[
        "capo_securityhub.types.max_statistic_results.MaxStatisticResults"
    ] = None,
) -> "capo_securityhub.types.get_software_statistics_v2_response.GetSoftwareStatisticsV2Response":
    """<p>Retrieves aggregated counts of software packages installed on your resources, grouped by a field that you specify. For example, you can return the most common package types or the accounts with the most installed packages.</p> <p>Each count is the number of package-to-resource pairs that match the grouping value. A package installed on three resources contributes three to the count.</p> <p>You can use the <code>Scopes</code> parameter to define the data boundary for the query. Currently, <code>Scopes</code> supports <code>AwsOrganizations</code>. With <code>AwsOrganizations</code>, you can aggregate software from your entire organization or from specific organizational units. Only the delegated administrator account can use <code>Scopes</code>.</p> <p>This operation doesn't paginate. Use <code>MaxStatisticResults</code> to control how many grouping values are returned.</p>

    Args:
        group_by_rules: <p>How software statistics should be aggregated and organized in the response.</p>
        scopes: <p>Limits the results to software on resources from specific organizational units or from the delegated administrator's organization. Only the delegated administrator account can use this parameter. Other accounts receive an <code>AccessDeniedException</code>.</p> <p>This parameter is optional. If you omit it, the delegated administrator sees statistics from all accounts across the entire organization. Other accounts see only statistics for software on their own resources.</p> <p>You can specify up to 10 entries in <code>Scopes.AwsOrganizations</code>. If multiple entries are specified, the entries are combined using OR logic.</p>
        sort_order: <p>Sorts aggregated statistics by count. The default is descending, which returns the values with the highest counts first.</p>
        max_statistic_results: <p>The maximum number of grouping values to return. Valid values are 1–400. The default is 400.</p>

    Raises:
        capo_securityhub.errors.access_denied_exception.AccessDeniedException: <p>You don't have permission to perform the action specified in the request.</p>
        capo_securityhub.errors.conflict_exception.ConflictException: <p>The request causes conflict with the current state of the service resource.</p>
        capo_securityhub.errors.internal_server_exception.InternalServerException: <p> The request has failed due to an internal failure of the service. </p>
        capo_securityhub.errors.organizational_unit_not_found_exception.OrganizationalUnitNotFoundException: <p>The request failed because one or more organizational units specified in the request don't exist within the caller's organization.</p>
        capo_securityhub.errors.organization_not_found_exception.OrganizationNotFoundException: <p>The request failed because one or more organizations specified in the request don't exist or don't belong to the caller's organization.</p>
        capo_securityhub.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request was rejected because we can't find the specified resource.</p>
        capo_securityhub.errors.throttling_exception.ThrottlingException: <p> The limit on the number of requests per second was exceeded. </p>
        capo_securityhub.errors.validation_exception.ValidationException: <p>The request has failed validation because it's missing required fields or has invalid inputs.</p>
        capo_securityhub.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_securityhub.types.get_software_statistics_v2_request.GetSoftwareStatisticsV2Request]",
    ) -> OperationResponse[
        "capo_securityhub.types.get_software_statistics_v2_response.GetSoftwareStatisticsV2Response"
    ]:
        import capo_securityhub._operations.security_hub_api_service.get_software_statistics_v2

        output, http_response = (
            capo_securityhub._operations.security_hub_api_service.get_software_statistics_v2.get_software_statistics_v2(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetSoftwareStatisticsV2")
    )
    input_: capo_securityhub.types.get_software_statistics_v2_request.GetSoftwareStatisticsV2Request = {}
    if group_by_rules is not None:
        input_["group_by_rules"] = group_by_rules
    if scopes is not None:
        input_["scopes"] = scopes
    if sort_order is not None:
        input_["sort_order"] = sort_order
    if max_statistic_results is not None:
        input_["max_statistic_results"] = max_statistic_results

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