Skip to content

get_recommendation_preferences

get_recommendation_preferences(
    resource_type: ResourceType,
    *,
    config_overrides: Optional[ComputeOptimizerClientConfig] = None,
    scope: Optional[Scope] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
) -> GetRecommendationPreferencesResponse

Returns existing recommendation preferences, such as enhanced infrastructure metrics.

Use the scope parameter to specify which preferences to return. You can specify to return preferences for an organization, a specific account ID, or a specific EC2 instance or Auto Scaling group Amazon Resource Name (ARN).

For more information, see Activating enhanced infrastructure metrics in the Compute Optimizer User Guide.

Parameters:

  • resource_type (ResourceType) –

    The target resource type of the recommendation preference for which to return preferences.

    The Ec2Instance option encompasses standalone instances and instances that are part of Auto Scaling groups. The AutoScalingGroup option encompasses only instances that are part of an Auto Scaling group.

  • scope (Optional[Scope], default: None ) –

    An object that describes the scope of the recommendation preference to return.

    You can return recommendation preferences that are created at the organization level (for management accounts of an organization only), account level, and resource level. For more information, see Activating enhanced infrastructure metrics in the Compute Optimizer User Guide.

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

    The token to advance to the next page of recommendation preferences.

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

    The maximum number of recommendation preferences to return with a single request.

    To retrieve the remaining results, make another request with the returned nextToken value.

Raises:

Source code in docs_src/capo_compute_optimizer/_services/compute_optimizer.py
def get_recommendation_preferences(
    self,
    resource_type: "capo_compute_optimizer.types.resource_type.ResourceType",
    *,
    config_overrides: Optional[ComputeOptimizerClientConfig] = None,
    scope: Optional["capo_compute_optimizer.types.scope.Scope"] = None,
    next_token: Optional[
        "capo_compute_optimizer.types.next_token.NextToken"
    ] = None,
    max_results: Optional[
        "capo_compute_optimizer.types.max_results.MaxResults"
    ] = None,
) -> "capo_compute_optimizer.types.get_recommendation_preferences_response.GetRecommendationPreferencesResponse":
    """<p>Returns existing recommendation preferences, such as enhanced infrastructure metrics.</p> <p>Use the <code>scope</code> parameter to specify which preferences to return. You can specify to return preferences for an organization, a specific account ID, or a specific EC2 instance or Auto Scaling group Amazon Resource Name (ARN).</p> <p>For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/enhanced-infrastructure-metrics.html">Activating enhanced infrastructure metrics</a> in the <i>Compute Optimizer User Guide</i>.</p>

    Args:
        resource_type: <p>The target resource type of the recommendation preference for which to return preferences.</p> <p>The <code>Ec2Instance</code> option encompasses standalone instances and instances that are part of Auto Scaling groups. The <code>AutoScalingGroup</code> option encompasses only instances that are part of an Auto Scaling group.</p>
        scope: <p>An object that describes the scope of the recommendation preference to return.</p> <p>You can return recommendation preferences that are created at the organization level (for management accounts of an organization only), account level, and resource level. For more information, see <a href="https://docs.aws.amazon.com/compute-optimizer/latest/ug/enhanced-infrastructure-metrics.html">Activating enhanced infrastructure metrics</a> in the <i>Compute Optimizer User Guide</i>.</p>
        next_token: <p>The token to advance to the next page of recommendation preferences.</p>
        max_results: <p>The maximum number of recommendation preferences to return with a single request.</p> <p>To retrieve the remaining results, make another request with the returned <code>nextToken</code> value.</p>

    Raises:
        capo_compute_optimizer.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_compute_optimizer.errors.internal_server_exception.InternalServerException: <p>An internal error has occurred. Try your call again.</p>
        capo_compute_optimizer.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The value supplied for the input parameter is out of range or not valid.</p>
        capo_compute_optimizer.errors.missing_authentication_token.MissingAuthenticationToken: <p>The request must contain either a valid (registered) Amazon Web Services access key ID or X.509 certificate.</p>
        capo_compute_optimizer.errors.opt_in_required_exception.OptInRequiredException: <p>The account is not opted in to Compute Optimizer.</p>
        capo_compute_optimizer.errors.resource_not_found_exception.ResourceNotFoundException: <p>A resource that is required for the action doesn't exist.</p>
        capo_compute_optimizer.errors.service_unavailable_exception.ServiceUnavailableException: <p>The request has failed due to a temporary failure of the server.</p>
        capo_compute_optimizer.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_compute_optimizer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_compute_optimizer.types.get_recommendation_preferences_request.GetRecommendationPreferencesRequest]",
    ) -> OperationResponse[
        "capo_compute_optimizer.types.get_recommendation_preferences_response.GetRecommendationPreferencesResponse"
    ]:
        import capo_compute_optimizer._operations.compute_optimizer_service.get_recommendation_preferences

        output, http_response = (
            capo_compute_optimizer._operations.compute_optimizer_service.get_recommendation_preferences.get_recommendation_preferences(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetRecommendationPreferences")
    )
    input_: capo_compute_optimizer.types.get_recommendation_preferences_request.GetRecommendationPreferencesRequest = {
        "resource_type": resource_type
    }
    if scope is not None:
        input_["scope"] = scope
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

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