Class RegistryArtifact

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

public final class RegistryArtifact extends Object
This class provides a helper type that contains all the operations for artifacts in a given repository.

Instantiating Registry Artifact

 RegistryArtifact registryArtifact = new ContainerRegistryClientBuilder()
     .endpoint(endpoint)
     .credential(credential)
     .audience(ContainerRegistryAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD)
     .buildClient().getArtifact(repository, digest);
 
  • Method Details

    • getRegistryEndpoint

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

      public String getRepositoryName()
      Gets the repository name for the current instance. Gets the repository name for the current instance.
      Returns:
      Name of the repository for the current instance.
    • getFullyQualifiedReference

      public String getFullyQualifiedReference()
      Gets the fully qualified reference for the current instance.
      Returns:
      Fully qualified reference of the current instance.
    • deleteWithResponse

      public Response<Void> deleteWithResponse(Context context)
      Deletes the registry artifact with the digest and repository associated with the instance.

      Code Samples

      Delete the registry artifact.

       client.deleteWithResponse(Context.NONE);
       
      Parameters:
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A REST response containing the result of the service call.
      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 void delete()
      Deletes the registry artifact with the digest and repository associated with the instance.

      Code Samples

      Delete the registry artifact.

       client.delete();
       
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to modify the namespace.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • deleteTagWithResponse

      public Response<Void> deleteTagWithResponse(String tag, Context context)
      Deletes the tag with the matching tag name for the given repository.

      Code Samples

      Delete the tag for the given repository.

       String tag = getTag();
       client.deleteTagWithResponse(tag, Context.NONE);
       
      Parameters:
      tag - The name of the tag that needs to be deleted.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A REST response containing the result of the service call.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to modify the namespace.
      NullPointerException - thrown if tag is null.
      IllegalArgumentException - thrown if tag is empty.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • deleteTag

      public void deleteTag(String tag)
      Deletes the tag with the matching tag name for the given repository.

      Code Samples

      Delete the tag for the given repository.

       String tag = getTag();
       client.deleteTag(tag);
       
      Parameters:
      tag - The name of the tag that needs to be deleted.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to modify the namespace.
      NullPointerException - thrown if tag is null.
      IllegalArgumentException - throws if tag is empty.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • getManifestPropertiesWithResponse

      public Response<ArtifactManifestProperties> getManifestPropertiesWithResponse(Context context)
      Gets the properties associated with an artifact in given repository.

      This method can take in both a digest as well as a tag.
      In case a tag is provided it calls the service to get the digest associated with the given tag.

      Code Samples

      Get the properties for the given repository.

       Response<ArtifactManifestProperties> response = client.getManifestPropertiesWithResponse(
           Context.NONE);
       final ArtifactManifestProperties properties = response.getValue();
       System.out.printf("Digest:%s,", properties.getDigest());
       
      Parameters:
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A REST response containing properties associated with the given Digest.
      Throws:
      ClientAuthenticationException - thrown if the client's credentials do not have access to modify the namespace.
      ResourceNotFoundException - thrown if the given digest was not found.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • getManifestProperties

      public ArtifactManifestProperties getManifestProperties()
      Gets the properties associated with an artifact in given repository.

      This method can take in both a digest as well as a tag.
      In case a tag is provided it calls the service to get the digest associated with the given tag.

      Code Samples

      Get the registry artifact properties for a given tag or digest.

       ArtifactManifestProperties properties = client.getManifestProperties();
       System.out.printf("Digest:%s,", properties.getDigest());
       
      Returns:
      The properties associated with the given Digest.
      Throws:
      ClientAuthenticationException - thrown if the client's credentials do not have access to modify the namespace.
      ResourceNotFoundException - thrown if the given digest was not found.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • getTagPropertiesWithResponse

      public Response<ArtifactTagProperties> getTagPropertiesWithResponse(String tag, Context context)
      Gets the tag properties associated with a given tag in the repository.

      Code Samples

      Retrieve the properties associated with the given tag.

       String tag = getTag();
       Response<ArtifactTagProperties> response = client.getTagPropertiesWithResponse(tag, Context.NONE);
       final ArtifactTagProperties properties = response.getValue();
       System.out.printf("Digest:%s,", properties.getDigest());
       
      Parameters:
      tag - name of the tag.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A REST response with the properties associated with the given tag.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      ResourceNotFoundException - thrown if the given tag was not found.
      NullPointerException - thrown if tag is null.
      IllegalArgumentException - throws if tag is empty.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • getTagProperties

      public ArtifactTagProperties getTagProperties(String tag)
      Gets the tag properties associated with a given tag in the repository.

      Code Samples

      Retrieve the properties associated with the given tag.

       String tag = getTag();
       ArtifactTagProperties properties = client.getTagProperties(tag);
       System.out.printf("Digest:%s,", properties.getDigest());
       
      Parameters:
      tag - name of the tag.
      Returns:
      The properties associated with the given tag.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to the repository.
      ResourceNotFoundException - thrown if the given tag was not found.
      NullPointerException - thrown if tag is null.
      IllegalArgumentException - throws if tag is empty.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • listTagProperties

      public PagedIterable<ArtifactTagProperties> listTagProperties()
      Fetches all the tags 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 listTagProperties(ArtifactTagOrder, Context) listTagProperties} No assumptions on the order can be made if no options are provided to the service.

      Code Samples

      Retrieve all the tags associated with the given repository.

       client.listTagProperties().iterableByPage(10).forEach(pagedResponse -> {
           pagedResponse.getValue().stream().forEach(
               tagProperties -> System.out.println(tagProperties.getDigest()));
       });
       
      Returns:
      PagedIterable 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.
    • listTagProperties

      public PagedIterable<ArtifactTagProperties> listTagProperties(ArtifactTagOrder order)
      Fetches all the tags associated with the given repository.

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

      Code Samples

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

       client.listTagProperties(ArtifactTagOrder.LAST_UPDATED_ON_DESCENDING)
           .iterableByPage(10)
           .forEach(pagedResponse -> {
               pagedResponse.getValue()
                   .stream()
                   .forEach(tagProperties -> System.out.println(tagProperties.getDigest()));
           });
       
      Parameters:
      order - The order in which the tags should be returned by the service.
      Returns:
      PagedIterable 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.
    • listTagProperties

      public PagedIterable<ArtifactTagProperties> listTagProperties(ArtifactTagOrder order, Context context)
      Fetches all the tags associated with the given repository.

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

      Code Samples

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

       client.listTagProperties(ArtifactTagOrder.LAST_UPDATED_ON_DESCENDING, Context.NONE)
           .iterableByPage(10)
           .forEach(pagedResponse -> {
               pagedResponse.getValue()
                   .stream()
                   .forEach(tagProperties -> System.out.println(tagProperties.getDigest()));
           });
       
      Parameters:
      order - The order in which the tags should be returned by the service.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      PagedIterable 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.
    • updateTagPropertiesWithResponse

      public Response<ArtifactTagProperties> updateTagPropertiesWithResponse(String tag, ArtifactTagProperties tagProperties, Context context)
      Update the properties ArtifactTagProperties of the given tag in repository. These properties set whether the given tag can be updated, deleted and retrieved.

      Code Samples

      Update the writeable properties of a given tag.

       ArtifactTagProperties properties = getArtifactTagProperties();
       String tag = getTag();
       client.updateTagPropertiesWithResponse(tag, properties, Context.NONE);
       
      Parameters:
      tag - Name of the tag.
      tagProperties - tagProperties to be set.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A REST response for the completion.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to repository.
      ResourceNotFoundException - thrown if the given tag was not found.
      NullPointerException - thrown if tag or tagProperties is null.
      IllegalArgumentException - thrown if tag or tagProperties is empty.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • updateTagProperties

      public ArtifactTagProperties updateTagProperties(String tag, ArtifactTagProperties tagProperties)
      Update the properties ArtifactTagProperties of the given tag. These properties set whether the given tag can be updated, deleted and retrieved.

      Code Samples

      Update the writeable properties of a given tag.

       ArtifactTagProperties properties = getArtifactTagProperties();
       String tag = getTag();
       client.updateTagProperties(tag, properties);
       
      Parameters:
      tag - Name of the tag.
      tagProperties - tagProperties to be set.
      Returns:
      The updated properties
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to repository.
      ResourceNotFoundException - thrown if the given tag was not found.
      NullPointerException - thrown if tag or tagProperties is null.
      IllegalArgumentException - thrown if tag or tagProperties is empty.
      HttpResponseException - thrown if any other unexpected exception is returned by the service.
    • updateManifestPropertiesWithResponse

      public Response<ArtifactManifestProperties> updateManifestPropertiesWithResponse(ArtifactManifestProperties manifestProperties, Context context)
      Update the properties ArtifactTagProperties of the artifact with the given digest. These properties set whether the given manifest can be updated, deleted and retrieved.

      Code Samples

      Update the writeable properties of a given artifact.

       ArtifactManifestProperties properties = getArtifactManifestProperties();
       client.updateManifestPropertiesWithResponse(properties, Context.NONE);
       
      Parameters:
      manifestProperties - tagProperties to be set.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A REST response for the completion.
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to repository.
      NullPointerException - thrown if the manifestProperties is null.
      ResourceNotFoundException - thrown if the given digest was not found.
    • updateManifestProperties

      public ArtifactManifestProperties updateManifestProperties(ArtifactManifestProperties manifestProperties)
      Update the writeable properties ArtifactTagProperties of the artifact with the given digest. These properties set whether the given manifest can be updated, deleted and retrieved.

      Code Samples

      Update the writeable properties of a given manifest.

       ArtifactManifestProperties properties = getArtifactManifestProperties();
       client.updateManifestProperties(properties);
       
      Parameters:
      manifestProperties - manifestProperties to be set.
      Returns:
      The updated properties
      Throws:
      ClientAuthenticationException - thrown if the client does not have access to repository.
      ResourceNotFoundException - thrown if the given digest was not found.
      NullPointerException - thrown if the manifestProperties is null.