Class ContainerRegistryContentAsyncClient
java.lang.Object
com.azure.containers.containerregistry.ContainerRegistryContentAsyncClient
This class provides a client that exposes operations to push and pull images into container registry.
It exposes methods that upload, download and delete artifacts from the registry i.e. images and manifests.
View this for additional ways to construct the client.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondeleteBlob(String digest) Delete the image identified by the given digestdeleteBlobWithResponse(String digest) Delete the image identified by the given digestdeleteManifest(String digest) Delete the manifest identified by the given digest.deleteManifestWithResponse(String digest) Delete the manifest identified by the given digest.Mono<com.azure.core.util.BinaryData>downloadStream(String digest) Download the blob identified by the given digest.This method returns the complete registry endpoint.getManifest(String tagOrDigest) Download the manifest identified by the given tag or digest.Mono<com.azure.core.http.rest.Response<GetManifestResult>>getManifestWithResponse(String tagOrDigest) Download the manifest identified by the given tag or digest.This method returns the registry's repository on which operations are being performed.setManifest(OciImageManifest manifest, String tag) Upload the Oci manifest to the repository.Mono<com.azure.core.http.rest.Response<SetManifestResult>>Uploads a manifest to the repository.uploadBlob(com.azure.core.util.BinaryData content) Uploads a blob to the repository.
-
Method Details
-
getRepositoryName
This method returns the registry's repository on which operations are being performed.- Returns:
- The name of the repository
-
getEndpoint
This method returns the complete registry endpoint.- Returns:
- The registry endpoint including the authority.
-
setManifest
Upload the Oci manifest to the repository.Code Samples:
OciImageManifest manifest = new OciImageManifest() .setConfiguration(configDescriptor) .setSchemaVersion(2) .setLayers(Collections.singletonList(layerDescriptor)); Mono<SetManifestResult> result = contentClient.setManifest(manifest, "latest");- Parameters:
manifest- TheOciImageManifestthat needs to be uploaded.tag- Tag to apply on uploaded manifest. Ifnullis passed, no tags will be applied.- Returns:
- upload result.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if themanifestis null.- See Also:
-
setManifestWithResponse
public Mono<com.azure.core.http.rest.Response<SetManifestResult>> setManifestWithResponse(SetManifestOptions options) Uploads a manifest to the repository.Code Samples:
SetManifestOptions options = new SetManifestOptions(manifestList, DOCKER_MANIFEST_LIST_TYPE) .setTag("v2"); contentClient.setManifestWithResponse(options) .subscribe(response -> System.out.println("Manifest uploaded, digest - " + response.getValue().getDigest()));- Parameters:
options- The options for the upload manifest operation.- Returns:
- The rest response containing the upload result.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thedatais null.- See Also:
-
uploadBlob
Uploads a blob to the repository.Code Samples:
BinaryData configContent = BinaryData.fromObject(Collections.singletonMap("hello", "world")); contentClient .uploadBlob(configContent) .subscribe(uploadResult -> System.out.printf("Uploaded blob: digest - '%s', size - %s\n", uploadResult.getDigest(), uploadResult.getSizeInBytes()));contentClient.uploadBlob(BinaryData.fromFile(Paths.get("artifact.tar.gz"), CHUNK_SIZE)) .subscribe(uploadResult -> System.out.printf("Uploaded blob: digest - '%s', size - %s\n", uploadResult.getDigest(), uploadResult.getSizeInBytes()));layerContent .flatMap(content -> contentClient.uploadBlob(content)) .doOnError(HttpResponseException.class, (ex) -> { if (ex.getCause() instanceof AcrErrorsException) { AcrErrorsException acrErrors = (AcrErrorsException) ex.getCause(); for (AcrErrorInfo info : acrErrors.getValue().getErrors()) { System.out.printf("Uploaded blob failed: code '%s'\n", info.getCode()); } } });Note:
Content may be uploaded in chunks of up to 4MB size. Chunk size depends on the passedBinaryDatacontent. WhenBinaryDatais created usingBinaryData.fromFlux(Flux, Long, boolean), it may be uploaded in chunks matching individualByteBufferin theFluxand up to 4MB size. Buffers that are bigger than 4MB can be broken down into smaller chunks, but small buffers are not aggregated. To decrease number of chunks for big content, use buffers of 4MB size.- Parameters:
content- The blob content that needs to be uploaded.- Returns:
- The operation result.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thedatais null.
-
getManifest
Download the manifest identified by the given tag or digest.Code Samples:
contentClient.getManifest("latest") .doOnNext(downloadResult -> { if (ManifestMediaType.OCI_IMAGE_MANIFEST.equals(downloadResult.getManifestMediaType()) || ManifestMediaType.DOCKER_MANIFEST.equals(downloadResult.getManifestMediaType())) { OciImageManifest manifest = downloadResult.getManifest().toObject(OciImageManifest.class); System.out.println("Got OCI manifest"); } else { throw new IllegalArgumentException("Unexpected manifest type: " + downloadResult.getManifestMediaType()); } }) .block();- Parameters:
tagOrDigest- Manifest reference which can be tag or digest.- Returns:
- The manifest identified by the given tag or digest.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thetagOrDigestis null.- See Also:
-
getManifestWithResponse
public Mono<com.azure.core.http.rest.Response<GetManifestResult>> getManifestWithResponse(String tagOrDigest) Download the manifest identified by the given tag or digest.Code Samples:
contentClient.getManifestWithResponse("latest") .doOnNext(response -> { GetManifestResult manifestResult = response.getValue(); if (ManifestMediaType.OCI_IMAGE_MANIFEST.equals(manifestResult.getManifestMediaType()) || ManifestMediaType.DOCKER_MANIFEST.equals(manifestResult.getManifestMediaType())) { OciImageManifest manifest = manifestResult.getManifest().toObject(OciImageManifest.class); System.out.println("Got OCI manifest"); } else { throw new IllegalArgumentException("Unexpected manifest type: " + manifestResult.getManifestMediaType()); } }) .block();- Parameters:
tagOrDigest- Manifest reference which can be tag or digest.- Returns:
- The response for the manifest identified by the given tag or digest.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thetagOrDigestis null.
-
downloadStream
Download the blob identified by the given digest. Content is downloaded in chunks of 4MB size each.Code Samples:
Write content to synchronous channel, for exampleFileChannel:contentClient .downloadStream(digest) .flatMap(downloadResult -> Mono.using(() -> new FileOutputStream(trimSha(digest)), fileStream -> FluxUtil.writeToWritableByteChannel( downloadResult.toFluxByteBuffer(), fileStream.getChannel()), fileStream -> closeStream(fileStream))) .block();Write content to asynchronous byte channel, for exampleAsynchronousSocketChannel:contentClient .downloadStream(digest) .flatMap(downloadResult -> Mono.using( () -> openSocket(), socket -> FluxUtil.writeToAsynchronousByteChannel(downloadResult.toFluxByteBuffer(), socket), socket -> closeStream(socket))) .block();- Parameters:
digest- The digest for the given image layer.- Returns:
- The image identified by the given digest.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thedigestis null.
-
deleteBlob
Delete the image identified by the given digestCode Samples:
contentClient.getManifest("latest") .flatMap(manifest -> contentClient.deleteBlob(manifest.getDigest())) .block();- Parameters:
digest- The digest for the given image layer.- Returns:
- The completion signal.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thedigestis null.
-
deleteBlobWithResponse
Delete the image identified by the given digest- Parameters:
digest- The digest for the given image layer.- Returns:
- The REST response for the completion.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thedigestis null.
-
deleteManifest
Delete the manifest identified by the given digest.Code Samples:
contentClient.getManifest("latest") .flatMap(manifest -> contentClient.deleteManifest(manifest.getDigest())) .block();- Parameters:
digest- The digest of the manifest.- Returns:
- The completion.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thedigestis null.
-
deleteManifestWithResponse
Delete the manifest identified by the given digest.- Parameters:
digest- The digest of the manifest.- Returns:
- The REST response for completion.
- Throws:
com.azure.core.exception.ClientAuthenticationException- thrown if the client's credentials do not have access to modify the namespace.NullPointerException- thrown if thedigestis null.
-