getResourcesV2 method

Future<GetResourcesV2Response> getResourcesV2({
  1. ResourcesFilters? filters,
  2. int? maxResults,
  3. String? nextToken,
  4. ResourceScopes? scopes,
  5. List<SortCriterion>? sortCriteria,
})

Returns a list of resources.

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

You can use the Filters parameter to refine results based on resource attributes. You can use Scopes and Filters independently or together. When both are provided, Scopes narrows the data set first, and then Filters refines results within that scoped data set.

For AI/ML resources, the response includes the ResourceSubCategory field. For self-hosted AI resources and their host resources, the response also includes ResourceInfo with AI-specific details. Self-hosted AI resources use a ResourceType with the SelfHosted::AI:: prefix, such as SelfHosted::AI::Model, SelfHosted::AI::Agent, SelfHosted::AI::InferenceEndpoint, and SelfHosted::AI::ExternalEndpoint.

If you filter by ResourceSubCategory, you must also include a ResourceCategory string filter with comparison set to EQUALS and value AI/ML in the same request.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw OrganizationalUnitNotFoundException. May throw OrganizationNotFoundException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter filters : Filters resources based on a set of criteria.

Parameter maxResults : The maximum number of results to return.

Parameter nextToken : The token required for pagination. On your first call, set the value of this parameter to NULL. For subsequent calls, to continue listing data, set the value of this parameter to the value returned in the previous response.

Parameter scopes : Limits the results to 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 resources from all accounts across the entire organization. Other accounts see only 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.

Parameter sortCriteria : The resource attributes used to sort the list of returned resources.

Implementation

Future<GetResourcesV2Response> getResourcesV2({
  ResourcesFilters? filters,
  int? maxResults,
  String? nextToken,
  ResourceScopes? scopes,
  List<SortCriterion>? sortCriteria,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final $payload = <String, dynamic>{
    if (filters != null) 'Filters': filters,
    if (maxResults != null) 'MaxResults': maxResults,
    if (nextToken != null) 'NextToken': nextToken,
    if (scopes != null) 'Scopes': scopes,
    if (sortCriteria != null) 'SortCriteria': sortCriteria,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/resourcesv2',
    exceptionFnMap: _exceptionFns,
  );
  return GetResourcesV2Response.fromJson(response);
}