listPackages method

Future<ListPackagesResult> listPackages({
  1. required String domain,
  2. required String repository,
  3. String? domainOwner,
  4. PackageFormat? format,
  5. int? maxResults,
  6. String? namespace,
  7. String? nextToken,
  8. String? packagePrefix,
  9. AllowPublish? publish,
  10. AllowUpstream? upstream,
})

Returns a list of PackageSummary objects for packages in a repository that match the request parameters.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter domain : The name of the domain that contains the repository that contains the requested packages.

Parameter repository : The name of the repository that contains the requested packages.

Parameter domainOwner : The 12-digit account number of the Amazon Web Services account that owns the domain. It does not include dashes or spaces.

Parameter format : The format used to filter requested packages. Only packages from the provided format will be returned.

Parameter maxResults : The maximum number of results to return per page.

Parameter namespace : The namespace prefix used to filter requested packages. Only packages with a namespace that starts with the provided string value are returned. Note that although this option is called --namespace and not --namespace-prefix, it has prefix-matching behavior.

Each package format uses namespace as follows:

  • The namespace of a Maven package version is its groupId.
  • The namespace of an npm or Swift package version is its scope.
  • The namespace of a generic package is its namespace.
  • Python, NuGet, Ruby, and Cargo package versions do not contain a corresponding component, package versions of those formats do not have a namespace.

Parameter nextToken : The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

Parameter packagePrefix : A prefix used to filter requested packages. Only packages with names that start with packagePrefix are returned.

Parameter publish : The value of the Publish package origin control restriction used to filter requested packages. Only packages with the provided restriction are returned. For more information, see PackageOriginRestrictions.

Parameter upstream : The value of the Upstream package origin control restriction used to filter requested packages. Only packages with the provided restriction are returned. For more information, see PackageOriginRestrictions.

Implementation

Future<ListPackagesResult> listPackages({
  required String domain,
  required String repository,
  String? domainOwner,
  PackageFormat? format,
  int? maxResults,
  String? namespace,
  String? nextToken,
  String? packagePrefix,
  AllowPublish? publish,
  AllowUpstream? upstream,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    1000,
  );
  final $query = <String, List<String>>{
    'domain': [domain],
    'repository': [repository],
    if (domainOwner != null) 'domain-owner': [domainOwner],
    if (format != null) 'format': [format.value],
    if (maxResults != null) 'max-results': [maxResults.toString()],
    if (namespace != null) 'namespace': [namespace],
    if (nextToken != null) 'next-token': [nextToken],
    if (packagePrefix != null) 'package-prefix': [packagePrefix],
    if (publish != null) 'publish': [publish.value],
    if (upstream != null) 'upstream': [upstream.value],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'POST',
    requestUri: '/v1/packages',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListPackagesResult.fromJson(response);
}