getPackageVersionAsset method

Future<GetPackageVersionAssetResult> getPackageVersionAsset({
  1. required String asset,
  2. required String domain,
  3. required PackageFormat format,
  4. required String package,
  5. required String packageVersion,
  6. required String repository,
  7. String? domainOwner,
  8. String? namespace,
  9. String? packageVersionRevision,
})

Returns an asset (or file) that is in a package. For example, for a Maven package version, use GetPackageVersionAsset to download a JAR file, a POM file, or any other assets in the package version.

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

Parameter asset : The name of the requested asset.

Parameter domain : The name of the domain that contains the repository that contains the package version with the requested asset.

Parameter format : A format that specifies the type of the package version with the requested asset file.

Parameter package : The name of the package that contains the requested asset.

Parameter packageVersion : A string that contains the package version (for example, 3.5.2).

Parameter repository : The repository that contains the package version with the requested asset.

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 namespace : The namespace of the package version with the requested asset file. The package component that specifies its namespace depends on its type. For example:

  • Maven
  • Swift
  • generic
  • 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 packageVersionRevision : The name of the package version revision that contains the requested asset.

Implementation

Future<GetPackageVersionAssetResult> getPackageVersionAsset({
  required String asset,
  required String domain,
  required PackageFormat format,
  required String package,
  required String packageVersion,
  required String repository,
  String? domainOwner,
  String? namespace,
  String? packageVersionRevision,
}) async {
  final $query = <String, List<String>>{
    'asset': [asset],
    'domain': [domain],
    'format': [format.value],
    'package': [package],
    'version': [packageVersion],
    'repository': [repository],
    if (domainOwner != null) 'domain-owner': [domainOwner],
    if (namespace != null) 'namespace': [namespace],
    if (packageVersionRevision != null) 'revision': [packageVersionRevision],
  };
  final response = await _protocol.sendRaw(
    payload: null,
    method: 'GET',
    requestUri: '/v1/package/version/asset',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return GetPackageVersionAssetResult(
    asset: await response.stream.toBytes(),
    assetName: _s.extractHeaderStringValue(response.headers, 'X-AssetName'),
    packageVersion:
        _s.extractHeaderStringValue(response.headers, 'X-PackageVersion'),
    packageVersionRevision: _s.extractHeaderStringValue(
        response.headers, 'X-PackageVersionRevision'),
  );
}