Skip to content

get_recommended_policy_v2 async

get_recommended_policy_v2(
    metadata_uid: NonEmptyString,
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
) -> GetRecommendedPolicyV2Response

Retrieves the recommended policy to remediate a Security Hub finding. GetRecommendedPolicyV2 only supports findings for unused permissions.

Parameters:

  • metadata_uid (NonEmptyString) –

    The unique identifier (ID) of Security Hub OCSF findings found under the metadata.uid field of the finding.

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

    The token used to paginate the RecommendationSteps list returned. On your first call to GetRecommendedPolicyV2, omit this parameter or set it to NULL. For subsequent calls, use the NextToken value returned in the previous response to retrieve the next page of results.

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

    The maximum number of recommendation steps to return.

Raises:

Source code in docs_src/capo_securityhub/_services/async_security_hub.py
async def get_recommended_policy_v2(
    self,
    metadata_uid: "capo_securityhub.types.non_empty_string.NonEmptyString",
    *,
    config_overrides: Optional[AsyncSecurityHubClientConfig] = 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_recommended_policy_v2_response.GetRecommendedPolicyV2Response":
    """<p>Retrieves the recommended policy to remediate a Security Hub finding. <code>GetRecommendedPolicyV2</code> only supports findings for unused permissions.</p>

    Args:
        metadata_uid: <p>The unique identifier (ID) of Security Hub OCSF findings found under the <code>metadata.uid</code> field of the finding.</p>
        next_token: <p>The token used to paginate the <code>RecommendationSteps</code> list returned. On your first call to <code>GetRecommendedPolicyV2</code>, omit this parameter or set it to <code>NULL</code>. For subsequent calls, use the <code>NextToken</code> value returned in the previous response to retrieve the next page of results.</p>
        max_results: <p>The maximum number of recommendation steps to return.</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.internal_server_exception.InternalServerException: <p> The request has failed due to an internal failure of the service. </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.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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityhub.types.get_recommended_policy_v2_request.GetRecommendedPolicyV2Request]",
    ) -> AsyncOperationResponse[
        "capo_securityhub.types.get_recommended_policy_v2_response.GetRecommendedPolicyV2Response"
    ]:
        import capo_securityhub._operations.security_hub_api_service.get_recommended_policy_v2

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetRecommendedPolicyV2")
    )
    input_: capo_securityhub.types.get_recommended_policy_v2_request.GetRecommendedPolicyV2Request = {
        "metadata_uid": metadata_uid
    }
    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