getRecommendationPreferences method
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.
May throw AccessDeniedException.
May throw InternalServerException.
May throw InvalidParameterValueException.
May throw MissingAuthenticationToken.
May throw OptInRequiredException.
May throw ResourceNotFoundException.
May throw ServiceUnavailableException.
May throw ThrottlingException.
Parameter 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.
Parameter maxResults :
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.
Parameter nextToken :
The token to advance to the next page of recommendation preferences.
Parameter scope :
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.
Implementation
Future<GetRecommendationPreferencesResponse> getRecommendationPreferences({
required ResourceType resourceType,
int? maxResults,
String? nextToken,
Scope? scope,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
0,
1000,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'ComputeOptimizerService.GetRecommendationPreferences'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'resourceType': resourceType.value,
if (maxResults != null) 'maxResults': maxResults,
if (nextToken != null) 'nextToken': nextToken,
if (scope != null) 'scope': scope,
},
);
return GetRecommendationPreferencesResponse.fromJson(jsonResponse.body);
}