Skip to content

put_image

put_image(
    repository_name: RepositoryName,
    image_manifest: ImageManifest,
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional[RegistryId] = None,
    image_manifest_media_type: Optional[MediaType] = None,
    image_tag: Optional[ImageTag] = None,
    image_digest: Optional[ImageDigest] = None,
) -> PutImageResponse

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.

This operation is used by the Amazon ECR proxy and is not generally used by customers for pulling and pushing images. In most cases, you should use the docker CLI to pull, tag, and push images.

Parameters:

  • registry_id (Optional[RegistryId], default: None ) –

    The Amazon Web Services 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.

  • repository_name (RepositoryName) –

    The name of the repository in which to put the image.

  • image_manifest (ImageManifest) –

    The image manifest corresponding to the image to be uploaded.

  • image_manifest_media_type (Optional[MediaType], default: None ) –

    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.

  • image_tag (Optional[ImageTag], default: None ) –

    The tag to associate with the image. This parameter is optional.

  • image_digest (Optional[ImageDigest], default: None ) –

    The image digest of the image manifest corresponding to the image.

Raises:

Source code in docs_src/capo_ecr/_services/ecr.py
def put_image(
    self,
    repository_name: "capo_ecr.types.repository_name.RepositoryName",
    image_manifest: "capo_ecr.types.image_manifest.ImageManifest",
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional["capo_ecr.types.registry_id.RegistryId"] = None,
    image_manifest_media_type: Optional[
        "capo_ecr.types.media_type.MediaType"
    ] = None,
    image_tag: Optional["capo_ecr.types.image_tag.ImageTag"] = None,
    image_digest: Optional["capo_ecr.types.image_digest.ImageDigest"] = None,
) -> "capo_ecr.types.put_image_response.PutImageResponse":
    """<p>Creates or updates the image manifest and tags associated with an image.</p> <p>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.</p> <note> <p>This operation is used by the Amazon ECR proxy and is not generally used by customers for pulling and pushing images. In most cases, you should use the <code>docker</code> CLI to pull, tag, and push images.</p> </note>

    Args:
        registry_id: <p>The Amazon Web Services 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.</p>
        repository_name: <p>The name of the repository in which to put the image.</p>
        image_manifest: <p>The image manifest corresponding to the image to be uploaded.</p>
        image_manifest_media_type: <p>The media type of the image manifest. If you push an image manifest that does not contain the <code>mediaType</code> field, you must specify the <code>imageManifestMediaType</code> in the request.</p>
        image_tag: <p>The tag to associate with the image. This parameter is optional.</p>
        image_digest: <p>The image digest of the image manifest corresponding to the image.</p>

    Raises:
        capo_ecr.errors.image_already_exists_exception.ImageAlreadyExistsException: <p>The specified image has already been pushed, and there were no changes to the manifest or image tag after the last push.</p>
        capo_ecr.errors.image_digest_does_not_match_exception.ImageDigestDoesNotMatchException: <p>The specified image digest does not match the digest that Amazon ECR calculated for the image.</p>
        capo_ecr.errors.image_tag_already_exists_exception.ImageTagAlreadyExistsException: <p>The specified image is tagged with a tag that already exists. The repository is configured for tag immutability.</p>
        capo_ecr.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_ecr.errors.kms_exception.KmsException: <p>The operation failed due to a KMS exception.</p>
        capo_ecr.errors.layers_not_found_exception.LayersNotFoundException: <p>The specified layers could not be found, or the specified layer is not valid for this repository.</p>
        capo_ecr.errors.limit_exceeded_exception.LimitExceededException: <p>The operation did not succeed because it would have exceeded a service limit for your account. For more information, see <a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/service-quotas.html">Amazon ECR service quotas</a> in the Amazon Elastic Container Registry User Guide.</p>
        capo_ecr.errors.referenced_images_not_found_exception.ReferencedImagesNotFoundException: <p>The manifest list is referencing an image that does not exist.</p>
        capo_ecr.errors.repository_not_found_exception.RepositoryNotFoundException: <p>The specified repository could not be found. Check the spelling of the specified repository and ensure that you are performing operations on the correct registry.</p>
        capo_ecr.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue.</p>
        capo_ecr.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ecr.types.put_image_request.PutImageRequest]",
    ) -> OperationResponse["capo_ecr.types.put_image_response.PutImageResponse"]:
        import capo_ecr._operations.amazon_ec2_container_registry_v20150921.put_image

        output, http_response = (
            capo_ecr._operations.amazon_ec2_container_registry_v20150921.put_image.put_image(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutImage")
    )
    input_: capo_ecr.types.put_image_request.PutImageRequest = {
        "repository_name": repository_name,
        "image_manifest": image_manifest,
    }
    if registry_id is not None:
        input_["registry_id"] = registry_id
    if image_manifest_media_type is not None:
        input_["image_manifest_media_type"] = image_manifest_media_type
    if image_tag is not None:
        input_["image_tag"] = image_tag
    if image_digest is not None:
        input_["image_digest"] = image_digest

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output