getDownloadUrlForLayer method

Future<GetDownloadUrlForLayerResponse> getDownloadUrlForLayer({
  1. required String layerDigest,
  2. required String repositoryName,
  3. String? registryId,
})

Retrieves the pre-signed Amazon S3 download URL corresponding to an image layer. You can only get URLs for image layers that are referenced in an image.

When an image is pulled, the GetDownloadUrlForLayer API is called once per image layer that is not already cached.

May throw ServerException. May throw InvalidParameterException. May throw LayersNotFoundException. May throw LayerInaccessibleException. May throw RepositoryNotFoundException.

Parameter layerDigest : The digest of the image layer to download.

Parameter repositoryName : The name of the repository that is associated with the image layer to download.

Parameter registryId : The AWS account ID associated with the registry that contains the image layer to download. If you do not specify a registry, the default registry is assumed.

Implementation

Future<GetDownloadUrlForLayerResponse> getDownloadUrlForLayer({
  required String layerDigest,
  required String repositoryName,
  String? registryId,
}) async {
  ArgumentError.checkNotNull(layerDigest, 'layerDigest');
  ArgumentError.checkNotNull(repositoryName, 'repositoryName');
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    2,
    256,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AmazonEC2ContainerRegistry_V20150921.GetDownloadUrlForLayer'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'layerDigest': layerDigest,
      'repositoryName': repositoryName,
      if (registryId != null) 'registryId': registryId,
    },
  );

  return GetDownloadUrlForLayerResponse.fromJson(jsonResponse.body);
}