You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::ECR::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::ECR::Client
- Defined in:
- (unknown)
Overview
An API client for Amazon EC2 Container Registry. To construct a client, you need to configure a :region
and :credentials
.
ecr = Aws::ECR::Client.new(
region: region_name,
credentials: credentials,
# ...
)
See #initialize for a full list of supported configuration options.
Region
You can configure a default region in the following locations:
ENV['AWS_REGION']
Aws.config[:region]
Go here for a list of supported regions.
Credentials
Default credentials are loaded automatically from the following locations:
ENV['AWS_ACCESS_KEY_ID']
andENV['AWS_SECRET_ACCESS_KEY']
Aws.config[:credentials]
- The shared credentials ini file at
~/.aws/credentials
(more information) - From an instance profile when running on EC2
You can also construct a credentials object from one of the following classes:
Alternatively, you configure credentials with :access_key_id
and
:secret_access_key
:
# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))
Aws::ECR::Client.new(
access_key_id: creds['access_key_id'],
secret_access_key: creds['secret_access_key']
)
Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.
Instance Attribute Summary
Attributes inherited from Seahorse::Client::Base
Constructor collapse
-
#initialize(options = {}) ⇒ Aws::ECR::Client
constructor
Constructs an API client.
API Operations collapse
-
#batch_check_layer_availability(options = {}) ⇒ Types::BatchCheckLayerAvailabilityResponse
Checks the availability of one or more image layers in a repository.
When an image is pushed to a repository, each image layer is checked to verify if it has been uploaded before.
-
#batch_delete_image(options = {}) ⇒ Types::BatchDeleteImageResponse
Deletes a list of specified images within a repository.
-
#batch_get_image(options = {}) ⇒ Types::BatchGetImageResponse
Gets detailed information for an image.
-
#complete_layer_upload(options = {}) ⇒ Types::CompleteLayerUploadResponse
Informs Amazon ECR that the image layer upload has completed for a specified registry, repository name, and upload ID.
-
#create_repository(options = {}) ⇒ Types::CreateRepositoryResponse
Creates a repository.
-
#delete_lifecycle_policy(options = {}) ⇒ Types::DeleteLifecyclePolicyResponse
Deletes the lifecycle policy associated with the specified repository.
.
-
#delete_repository(options = {}) ⇒ Types::DeleteRepositoryResponse
Deletes a repository.
-
#delete_repository_policy(options = {}) ⇒ Types::DeleteRepositoryPolicyResponse
Deletes the repository policy associated with the specified repository.
.
-
#describe_image_scan_findings(options = {}) ⇒ Types::DescribeImageScanFindingsResponse
Returns the scan findings for the specified image.
.
-
#describe_images(options = {}) ⇒ Types::DescribeImagesResponse
Returns metadata about the images in a repository.
Beginning with Docker version 1.9, the Docker client compresses image layers before pushing them to a V2 Docker registry.
-
#describe_repositories(options = {}) ⇒ Types::DescribeRepositoriesResponse
Describes image repositories in a registry.
.
-
#get_authorization_token(options = {}) ⇒ Types::GetAuthorizationTokenResponse
Retrieves an authorization token.
-
#get_download_url_for_layer(options = {}) ⇒ Types::GetDownloadUrlForLayerResponse
Retrieves the pre-signed Amazon S3 download URL corresponding to an image layer.
-
#get_lifecycle_policy(options = {}) ⇒ Types::GetLifecyclePolicyResponse
Retrieves the lifecycle policy for the specified repository.
.
-
#get_lifecycle_policy_preview(options = {}) ⇒ Types::GetLifecyclePolicyPreviewResponse
Retrieves the results of the lifecycle policy preview request for the specified repository.
.
-
#get_repository_policy(options = {}) ⇒ Types::GetRepositoryPolicyResponse
Retrieves the repository policy for the specified repository.
.
-
#initiate_layer_upload(options = {}) ⇒ Types::InitiateLayerUploadResponse
Notifies Amazon ECR that you intend to upload an image layer.
When an image is pushed, the InitiateLayerUpload API is called once per image layer that has not already been uploaded.
-
#list_images(options = {}) ⇒ Types::ListImagesResponse
Lists all the image IDs for the specified repository.
You can filter images based on whether or not they are tagged by using the
tagStatus
filter and specifying eitherTAGGED
,UNTAGGED
orANY
. -
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
List the tags for an Amazon ECR resource.
.
-
#put_image(options = {}) ⇒ Types::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.
-
#put_image_scanning_configuration(options = {}) ⇒ Types::PutImageScanningConfigurationResponse
Updates the image scanning configuration for the specified repository.
.
-
#put_image_tag_mutability(options = {}) ⇒ Types::PutImageTagMutabilityResponse
Updates the image tag mutability settings for the specified repository.
-
#put_lifecycle_policy(options = {}) ⇒ Types::PutLifecyclePolicyResponse
Creates or updates the lifecycle policy for the specified repository.
-
#set_repository_policy(options = {}) ⇒ Types::SetRepositoryPolicyResponse
Applies a repository policy to the specified repository to control access permissions.
-
#start_image_scan(options = {}) ⇒ Types::StartImageScanResponse
Starts an image vulnerability scan.
-
#start_lifecycle_policy_preview(options = {}) ⇒ Types::StartLifecyclePolicyPreviewResponse
Starts a preview of a lifecycle policy for the specified repository.
-
#tag_resource(options = {}) ⇒ Struct
Adds specified tags to a resource with the specified ARN.
-
#untag_resource(options = {}) ⇒ Struct
Deletes specified tags from a resource.
.
-
#upload_layer_part(options = {}) ⇒ Types::UploadLayerPartResponse
Uploads an image layer part to Amazon ECR.
When an image is pushed, each new image layer is uploaded in parts.
Instance Method Summary collapse
-
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
-
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters.
Methods inherited from Seahorse::Client::Base
add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options = {}) ⇒ Aws::ECR::Client
Constructs an API client.
Instance Method Details
#batch_check_layer_availability(options = {}) ⇒ Types::BatchCheckLayerAvailabilityResponse
Checks the availability of one or more image layers in a repository.
When an image is pushed to a repository, each image layer is checked to verify if it has been uploaded before. If it has been uploaded, then the image layer is skipped.
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.
#batch_delete_image(options = {}) ⇒ Types::BatchDeleteImageResponse
Deletes a list of specified images within a repository. Images are specified with either an imageTag
or imageDigest
.
You can remove a tag from an image by specifying the image's tag in your request. When you remove the last tag from an image, the image is deleted from your repository.
You can completely delete an image (and all of its tags) by specifying the image's digest in your request.
#batch_get_image(options = {}) ⇒ Types::BatchGetImageResponse
Gets detailed information for an image. Images are specified with either an imageTag
or imageDigest
.
When an image is pulled, the BatchGetImage API is called once to retrieve the image manifest.
#complete_layer_upload(options = {}) ⇒ Types::CompleteLayerUploadResponse
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.
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.
#create_repository(options = {}) ⇒ Types::CreateRepositoryResponse
Creates a repository. For more information, see Amazon ECR Repositories in the Amazon Elastic Container Registry User Guide.
#delete_lifecycle_policy(options = {}) ⇒ Types::DeleteLifecyclePolicyResponse
Deletes the lifecycle policy associated with the specified repository.
#delete_repository(options = {}) ⇒ Types::DeleteRepositoryResponse
Deletes a repository. If the repository contains images, you must either delete all images in the repository or use the force
option to delete the repository.
#delete_repository_policy(options = {}) ⇒ Types::DeleteRepositoryPolicyResponse
Deletes the repository policy associated with the specified repository.
#describe_image_scan_findings(options = {}) ⇒ Types::DescribeImageScanFindingsResponse
Returns the scan findings for the specified image.
#describe_images(options = {}) ⇒ Types::DescribeImagesResponse
Returns metadata about the images in a repository.
Beginning with Docker version 1.9, the Docker client compresses image layers before pushing them to a V2 Docker registry. The output of the docker images
command shows the uncompressed image size, so it may return a larger image size than the image sizes returned by DescribeImages.
#describe_repositories(options = {}) ⇒ Types::DescribeRepositoriesResponse
Describes image repositories in a registry.
#get_authorization_token(options = {}) ⇒ Types::GetAuthorizationTokenResponse
Retrieves an authorization token. An authorization token represents your IAM authentication credentials and can be used to access any Amazon ECR registry that your IAM principal has access to. The authorization token is valid for 12 hours.
The authorizationToken
returned is a base64 encoded string that can be decoded and used in a docker login
command to authenticate to a registry. The AWS CLI offers an get-login-password
command that simplifies the login process. For more information, see Registry Authentication in the Amazon Elastic Container Registry User Guide.
#get_download_url_for_layer(options = {}) ⇒ Types::GetDownloadUrlForLayerResponse
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.
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.
#get_lifecycle_policy(options = {}) ⇒ Types::GetLifecyclePolicyResponse
Retrieves the lifecycle policy for the specified repository.
#get_lifecycle_policy_preview(options = {}) ⇒ Types::GetLifecyclePolicyPreviewResponse
Retrieves the results of the lifecycle policy preview request for the specified repository.
#get_repository_policy(options = {}) ⇒ Types::GetRepositoryPolicyResponse
Retrieves the repository policy for the specified repository.
#initiate_layer_upload(options = {}) ⇒ Types::InitiateLayerUploadResponse
Notifies Amazon ECR that you intend to upload an image layer.
When an image is pushed, the InitiateLayerUpload API is called once per image layer that has not already been uploaded. Whether or not an image layer has been uploaded is determined by the BatchCheckLayerAvailability API action.
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.
#list_images(options = {}) ⇒ Types::ListImagesResponse
Lists all the image IDs for the specified repository.
You can filter images based on whether or not they are tagged by using the tagStatus
filter and specifying either TAGGED
, UNTAGGED
or ANY
. For example, you can filter your results to return only UNTAGGED
images and then pipe that result to a BatchDeleteImage operation to delete them. Or, you can filter your results to return only TAGGED
images to list all of the tags in your repository.
#list_tags_for_resource(options = {}) ⇒ Types::ListTagsForResourceResponse
List the tags for an Amazon ECR resource.
#put_image(options = {}) ⇒ Types::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.
#put_image_scanning_configuration(options = {}) ⇒ Types::PutImageScanningConfigurationResponse
Updates the image scanning configuration for the specified repository.
#put_image_tag_mutability(options = {}) ⇒ Types::PutImageTagMutabilityResponse
Updates the image tag mutability settings for the specified repository. For more information, see Image Tag Mutability in the Amazon Elastic Container Registry User Guide.
#put_lifecycle_policy(options = {}) ⇒ Types::PutLifecyclePolicyResponse
Creates or updates the lifecycle policy for the specified repository. For more information, see Lifecycle Policy Template.
#set_repository_policy(options = {}) ⇒ Types::SetRepositoryPolicyResponse
Applies a repository policy to the specified repository to control access permissions. For more information, see Amazon ECR Repository Policies in the Amazon Elastic Container Registry User Guide.
#start_image_scan(options = {}) ⇒ Types::StartImageScanResponse
Starts an image vulnerability scan. An image scan can only be started once per day on an individual image. This limit includes if an image was scanned on initial push. For more information, see Image Scanning in the Amazon Elastic Container Registry User Guide.
#start_lifecycle_policy_preview(options = {}) ⇒ Types::StartLifecyclePolicyPreviewResponse
Starts a preview of a lifecycle policy for the specified repository. This allows you to see the results before associating the lifecycle policy with the repository.
#tag_resource(options = {}) ⇒ Struct
Adds specified tags to a resource with the specified ARN. Existing tags on a resource are not changed if they are not specified in the request parameters.
#untag_resource(options = {}) ⇒ Struct
Deletes specified tags from a resource.
#upload_layer_part(options = {}) ⇒ Types::UploadLayerPartResponse
Uploads an image layer part to Amazon ECR.
When an image is pushed, each new image layer is uploaded in parts. The maximum size of each image layer part can be 20971520 bytes (or about 20MB). The UploadLayerPart API is called once per each new image layer part.
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.
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
Basic Usage
Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)
Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:
# poll for ~25 seconds
client.wait_until(...) do |w|
w.max_attempts = 5
w.delay = 5
end
Callbacks
You can be notified before each polling attempt and before each
delay. If you throw :success
or :failure
from these callbacks,
it will terminate the waiter.
started_at = Time.now
client.wait_until(...) do |w|
# disable max attempts
w.max_attempts = nil
# poll for 1 hour, instead of a number of attempts
w.before_wait do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
end
Handling Errors
When a waiter is successful, it returns true
. When a waiter
fails, it raises an error. All errors raised extend from
Waiters::Errors::WaiterFailed.
begin
client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:
Waiter Name | Client Method | Default Delay: | Default Max Attempts: |
---|---|---|---|
:image_scan_complete | #describe_image_scan_findings | 5 | 60 |
:lifecycle_policy_preview_complete | #get_lifecycle_policy_preview | 5 | 20 |