putImage method

Future<PutImageResponse> putImage({
  1. required String imageManifest,
  2. required String repositoryName,
  3. String? imageDigest,
  4. String? imageManifestMediaType,
  5. String? imageTag,
  6. String? registryId,
})

Creates or updates the image manifest and tags associated with an image.

When an image is pushed and all new image layers have been uploaded, the PutImage API is called once to create or update the image manifest and the tags associated with the image.

May throw ServerException. May throw InvalidParameterException. May throw RepositoryNotFoundException. May throw ImageAlreadyExistsException. May throw LayersNotFoundException. May throw ReferencedImagesNotFoundException. May throw LimitExceededException. May throw ImageTagAlreadyExistsException. May throw ImageDigestDoesNotMatchException. May throw KmsException.

Parameter imageManifest : The image manifest corresponding to the image to be uploaded.

Parameter repositoryName : The name of the repository in which to put the image.

Parameter imageDigest : The image digest of the image manifest corresponding to the image.

Parameter imageManifestMediaType : The media type of the image manifest. If you push an image manifest that does not contain the mediaType field, you must specify the imageManifestMediaType in the request.

Parameter imageTag : The tag to associate with the image. This parameter is required for images that use the Docker Image Manifest V2 Schema 2 or Open Container Initiative (OCI) formats.

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

Implementation

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

  return PutImageResponse.fromJson(jsonResponse.body);
}