completeLayerUpload method

Future<CompleteLayerUploadResponse> completeLayerUpload({
  1. required List<String> layerDigests,
  2. required String repositoryName,
  3. required String uploadId,
  4. String? registryId,
})

Informs Amazon ECR that the image layer upload has completed for a specified registry, repository name, and upload ID. You can optionally provide a sha256 digest of the image layer for data validation purposes.

When an image is pushed, the CompleteLayerUpload API is called once per each new image layer to verify that the upload has completed.

May throw ServerException. May throw InvalidParameterException. May throw RepositoryNotFoundException. May throw UploadNotFoundException. May throw InvalidLayerException. May throw LayerPartTooSmallException. May throw LayerAlreadyExistsException. May throw EmptyUploadException. May throw KmsException.

Parameter layerDigests : The sha256 digest of the image layer.

Parameter repositoryName : The name of the repository to associate with the image layer.

Parameter uploadId : The upload ID from a previous InitiateLayerUpload operation to associate with the image layer.

Parameter registryId : The AWS account ID associated with the registry to which to upload layers. If you do not specify a registry, the default registry is assumed.

Implementation

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

  return CompleteLayerUploadResponse.fromJson(jsonResponse.body);
}