Class ContainerRegistryClient


  • public final class ContainerRegistryClient
    extends Object
    This class provides a client that exposes operations to managing container images and artifacts. synchronously. It exposes methods directly performed on the registry like listing the catalog. as well as helper types like getArtifact and getRepository that can be used to perform operations on repository and artifacts.

    Instantiating a synchronous Container Registry client

     ContainerRegistryClient registryAsyncClient = new ContainerRegistryClientBuilder()
         .endpoint(endpoint)
         .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
         .credential(credential)
         .buildClient();
     

    Instantiating a synchronous Container Registry client with custom pipeline

     HttpPipeline pipeline = new HttpPipelineBuilder()
         .policies(/* add policies */)
         .build();
    
     ContainerRegistryClient registryAsyncClient = new ContainerRegistryClientBuilder()
         .pipeline(pipeline)
         .endpoint(endpoint)
         .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
         .credential(credential)
         .buildClient();
     

    View this for additional ways to construct the client.

    See Also:
    ContainerRegistryClientBuilder
    • Method Detail

      • getEndpoint

        public String getEndpoint()
        This method returns the complete registry endpoint.
        Returns:
        The registry endpoint including the authority.
      • listRepositoryNames

        public com.azure.core.http.rest.PagedIterable<String> listRepositoryNames()
        List all the repository names in this registry.

        List the repository names in the registry.

         client.listRepositoryNames().stream().forEach(name -> {
             System.out.printf("Repository Name:%s,", name);
         });
         
        Returns:
        list of repository names.
        Throws:
        com.azure.core.exception.ClientAuthenticationException - thrown if the client credentials do not have access to perform this operation.
      • listRepositoryNames

        public com.azure.core.http.rest.PagedIterable<String> listRepositoryNames​(com.azure.core.util.Context context)
        List all the repository names in this registry.

        List the repository names in the registry.

         client.listRepositoryNames(Context.NONE).stream().forEach(name -> {
             System.out.printf("Repository Name:%s,", name);
         });
         
        Parameters:
        context - The context to associate with this operation.
        Returns:
        list of repositories.
        Throws:
        com.azure.core.exception.ClientAuthenticationException - thrown if the client credentials do not have access to perform this operation.
      • deleteRepository

        public void deleteRepository​(String repositoryName)
        Delete the repository identified by repositoryName.

        Delete a repository in the registry.

         client.deleteRepository(repositoryName);
         
        Parameters:
        repositoryName - Name of the repository (including the namespace).
        Throws:
        com.azure.core.exception.ClientAuthenticationException - thrown if the client's credentials do not have access to modify the namespace.
        NullPointerException - thrown if the repositoryName is null.
        IllegalArgumentException - thrown if the repositoryName is empty.
      • deleteRepositoryWithResponse

        public com.azure.core.http.rest.Response<Void> deleteRepositoryWithResponse​(String repositoryName,
                                                                                    com.azure.core.util.Context context)
        Delete the repository identified by repositoryName.

        Delete a repository in the registry.

         client.deleteRepositoryWithResponse(repositoryName, Context.NONE);
         
        Parameters:
        repositoryName - Name of the repository (including the namespace).
        context - The context to associate with this operation.
        Returns:
        Completion response.
        Throws:
        com.azure.core.exception.ClientAuthenticationException - thrown if the client's credentials do not have access to modify the namespace.
        NullPointerException - thrown if the repositoryName is null.
        IllegalArgumentException - thrown if the repositoryName is empty.
      • getRepository

        public ContainerRepository getRepository​(String repositoryName)
        Creates a new instance of ContainerRepository object for the specified repository.

        Create a ContainerRegistry helper instance.

         ContainerRepository repository = client.getRepository(repositoryName);
         ContainerRepositoryProperties properties = repository.getProperties();
         System.out.println(properties.getName());
         
        Parameters:
        repositoryName - Name of the repository to reference.
        Returns:
        A new ContainerRepository for the desired repository.
        Throws:
        NullPointerException - if repositoryName is null.
        IllegalArgumentException - if repositoryName is empty.
      • getArtifact

        public RegistryArtifact getArtifact​(String repositoryName,
                                            String tagOrDigest)
        Creates a new instance of RegistryArtifact object for the specified artifact.

        Create a RegistryArtifact helper instance.

         RegistryArtifact registryArtifact = client.getArtifact(repositoryName, tagOrDigest);
         ArtifactManifestProperties properties = registryArtifact.getManifestProperties();
         System.out.println(properties.getDigest());
         
        Parameters:
        repositoryName - Name of the repository to reference.
        tagOrDigest - Either a tag or digest that uniquely identifies the artifact.
        Returns:
        A new RegistryArtifact object for the desired repository.
        Throws:
        NullPointerException - if repositoryName or tagOrDigest is null.
        IllegalArgumentException - if repositoryName or tagOrDigest is empty.