Class ContainerRepositoryAsync

java.lang.Object
com.azure.containers.containerregistry.ContainerRepositoryAsync

public final class ContainerRepositoryAsync extends Object
This class provides helper methods for operations on a given repository in Azure Container Registry. Operations included are listing, retrieving, deleting, setting writeable properties.

Instantiating an asynchronous Container Repository Helper class

 ContainerRepositoryAsync repositoryAsyncClient = new ContainerRegistryClientBuilder()
     .endpoint(endpoint)
     .credential(credential)
     .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
     .buildAsyncClient()
     .getRepository(repository);
 
  • Method Details

    • getName

      public String getName()
      Gets the Azure Container Registry service endpoint for the current instance.
      Returns:
      The service endpoint for the current instance.
    • getRegistryEndpoint

      public String getRegistryEndpoint()
      Gets the Azure Container Registry name for the current instance.
      Returns:
      Return the registry name.
    • deleteWithResponse

      public Mono<Response<Void>> deleteWithResponse()
      Delete the repository in the Azure Container Registry for the given repository.

      Code Samples

      Delete the repository.

       client.deleteWithResponse().subscribe(response -> {
           System.out.printf("Successfully initiated delete of the repository.");
       }, error -> {
           System.out.println("Failed to initiate a delete of the repository.");
       });
       
      Returns:
      A REST response containing the result of the repository delete operation. It returns the count of the tags and artifacts that are deleted as part of the repository delete.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • delete

      public Mono<Void> delete()
      Delete the repository in the Azure Container Registry for the given repository.

      Code Samples

      Delete the repository.

       client.delete().subscribe(response -> {
           System.out.printf("Successfully initiated delete of the repository.");
       }, error -> {
           System.out.println("Failed to initiate a delete of the repository.");
       });
       
      Returns:
      It returns the count of the tags and artifacts that are deleted as part of the repository delete.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • getArtifact

      public RegistryArtifactAsync getArtifact(String tagOrDigest)
      Creates a new instance of RegistryArtifactAsync object for the specified artifact.
      Parameters:
      tagOrDigest - Either a tag or digest that uniquely identifies the artifact.
      Returns:
      A new RegistryArtifactAsync object for the desired repository.
      Throws:
      NullPointerException - if tagOrDigest is null.
      IllegalArgumentException - if tagOrDigest is empty.
    • listManifestProperties

      public PagedFlux<ArtifactManifestProperties> listManifestProperties()
      Fetches all the artifacts associated with the given repository.

      If you would like to specify the order in which the tags are returned please use the overload that takes in the options parameter listManifestProperties(ArtifactManifestOrder) listManifestProperties} No assumptions on the order can be made if no options are provided to the service.

      Code Samples

      Retrieve all artifacts associated with the given repository.

       client.listManifestProperties().byPage(10)
           .subscribe(ManifestPropertiesPagedResponse -> {
               ManifestPropertiesPagedResponse.getValue().stream().forEach(
                   ManifestProperties -> System.out.println(ManifestProperties.getDigest()));
           });
       
      Returns:
      PagedFlux of ManifestProperties for all the artifacts in the given repository.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • listManifestProperties

      public PagedFlux<ArtifactManifestProperties> listManifestProperties(ArtifactManifestOrder order)
      Fetches all the artifacts associated with the given repository.

      The method supports options to select the order in which the artifacts are returned by the service. Currently the service supports an ascending or descending order based on the last updated time for the artifacts. No assumptions on the order can be made if no options are provided to the service.

      Code Samples

      Retrieve all artifacts associated with the given repository from the most recently updated to the last.

       client.listManifestProperties(ArtifactManifestOrder.LAST_UPDATED_ON_DESCENDING).byPage(10)
           .subscribe(ManifestPropertiesPagedResponse -> {
               ManifestPropertiesPagedResponse.getValue().stream().forEach(
                   ManifestProperties -> System.out.println(ManifestProperties.getDigest()));
           });
       
      Parameters:
      order - The order in which the artifacts are returned by the service.
      Returns:
      PagedFlux of the artifacts for the given repository in the order specified by the options.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • getPropertiesWithResponse

      public Mono<Response<ContainerRepositoryProperties>> getPropertiesWithResponse()
      Gets the properties associated with the given repository.

      Code Samples

      Get the properties for the given repository.

       client.getPropertiesWithResponse().subscribe(response -> {
           final ContainerRepositoryProperties properties = response.getValue();
           System.out.printf("Name:%s,", properties.getName());
       });
       
      Returns:
      A REST response with the properties associated with the given repository.
      Throws:
      ClientAuthenticationException - thrown if the client have access to the repository.
      ResourceNotFoundException - thrown if the repository with the given name was not found.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • getProperties

      public Mono<ContainerRepositoryProperties> getProperties()
      Gets the properties associated with the given repository.

      Code Samples

      Get the properties for the given repository.

       client.getProperties().subscribe(response -> {
           System.out.printf("Name:%s,", response.getName());
       });
       
      Returns:
      The properties associated with the given repository.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      ResourceNotFoundException - thrown if the repository with the given name was not found.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • updatePropertiesWithResponse

      public Mono<Response<ContainerRepositoryProperties>> updatePropertiesWithResponse(ContainerRepositoryProperties repositoryProperties)
      Update the repository properties ContainerRepositoryProperties of the given repository. These properties set the update, delete and retrieve options of the repository.

      Code Samples

      Update the writeable properties for the given repository.

       ContainerRepositoryProperties properties = getRepositoryProperties();
       client.updatePropertiesWithResponse(properties).subscribe();
       
      Parameters:
      repositoryProperties - repository properties that need to be updated for the repository.
      Returns:
      The updated repository properties .
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      ResourceNotFoundException - thrown if the repository with the given name was not found.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
      NullPointerException - thrown if repositoryProperties is null.
    • updateProperties

      public Mono<ContainerRepositoryProperties> updateProperties(ContainerRepositoryProperties repositoryProperties)
      Update the repository properties ContainerRepositoryProperties of the given repository. These properties set the update, delete and retrieve options of the repository.

      Code Samples

      Update the writeable properties for the given repository.

       ContainerRepositoryProperties properties = getRepositoryProperties();
       client.updateProperties(properties).subscribe();
       
      Parameters:
      repositoryProperties - writeable properties that need to be updated for the repository.
      Returns:
      The completion.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      ResourceNotFoundException - thrown if the repository with the given name was not found.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
      NullPointerException - thrown if the repositoryProperties is null.