Class ContainerRegistryApi

java.lang.Object
org.gitlab4j.api.AbstractApi
org.gitlab4j.api.ContainerRegistryApi
All Implemented Interfaces:
Constants

public class ContainerRegistryApi extends AbstractApi

This class implements the client side API for the GitLab Container Registry API. See Container Registry API at GitLab for more information.

  • Constructor Details

    • ContainerRegistryApi

      public ContainerRegistryApi(GitLabApi gitLabApi)
  • Method Details

    • getRepositories

      public List<RegistryRepository> getRepositories(Object projectIdOrPath) throws GitLabApiException
      Get a list of registry repositories in a project.
      GitLab Endpoint: GET /projects/:id/registry/repositories
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      Returns:
      a list of pages in the project's registry repositories
      Throws:
      GitLabApiException - if any exception occurs
    • getRepositories

      public List<RegistryRepository> getRepositories(Object projectIdOrPath, int page, int perPage) throws GitLabApiException
      Get a list of registry repositories in a project that fall within the specified page parameters.
      GitLab Endpoint: GET /projects/:id/registry/repositories
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      page - the page to get
      perPage - the number of Package instances per page
      Returns:
      a list of registry repositories for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getRepositories

      public Pager<RegistryRepository> getRepositories(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
      Get a Pager of registry repositories in a project.
      GitLab Endpoint: GET /projects/:id/registry/repositories
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      itemsPerPage - the number of RegistryRepository instances per page
      Returns:
      a Pager of registry repositories for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getRepositoriesStream

      public Stream<RegistryRepository> getRepositoriesStream(Object projectIdOrPath) throws GitLabApiException
      Get a Stream of registry repositories in a project.
      GitLab Endpoint: GET /projects/:id/registry/repositories
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      Returns:
      a Stream of pages in the project's registry repositories
      Throws:
      GitLabApiException - if any exception occurs
    • deleteRepository

      public void deleteRepository(Object projectIdOrPath, Long repositoryId) throws GitLabApiException
      Delete a repository in registry.

      This operation is executed asynchronously and might take some time to get executed.

      GitLab Endpoint: DELETE /projects/:id/registry/repositories/:repository_id
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      Throws:
      GitLabApiException - if any exception occurs
    • getRepositoryTags

      public List<RegistryRepositoryTag> getRepositoryTags(Object projectIdOrPath, Long repositoryId) throws GitLabApiException
      Get a list of tags for given registry repository.
      GitLab Endpoint: GET /projects/:id/registry/repositories/:repository_id/tags
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      Returns:
      a list of Repository Tags for the specified repository ID
      Throws:
      GitLabApiException - if any exception occurs
    • getRepositoryTags

      public Pager<RegistryRepositoryTag> getRepositoryTags(Object projectIdOrPath, Long repositoryId, int itemsPerPage) throws GitLabApiException
      Get a Pager of tags for given registry repository.
      GitLab Endpoint: GET /projects/:id/registry/repositories/:repository_id/tags
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      itemsPerPage - the number of RegistryRepositoryTag instances per page
      Returns:
      a Pager of Repository Tags for the specified repository ID
      Throws:
      GitLabApiException - if any exception occurs
    • getRepositoryTagsStream

      public Stream<RegistryRepositoryTag> getRepositoryTagsStream(Object projectIdOrPath, Long repositoryId) throws GitLabApiException
      Get a Stream of tags for given registry repository.
      GitLab Endpoint: GET /projects/:id/registry/repositories/:repository_id/tags
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      Returns:
      a list of Repository Tags for the specified repository ID
      Throws:
      GitLabApiException - if any exception occurs
    • getRepositoryTag

      public RegistryRepositoryTag getRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName) throws GitLabApiException
      Get details of a registry repository tag.
      GitLab Endpoint: GET /projects/:id/registry/repositories/:repository_id/tags/:tag_name
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      tagName - the name of tag
      Returns:
      the Repository Tag for the specified repository ID
      Throws:
      GitLabApiException - if any exception occurs
    • getOptionalRepositoryTag

      public Optional<RegistryRepositoryTag> getOptionalRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName)
      Get details of a registry repository tag as the value of an Optional.
      GitLab Endpoint: GET /projects/:id/registry/repositories/:repository_id/tags/:tag_name
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      tagName - the name of tag
      Returns:
      the Repository Tag for the specified repository ID as the value of the Optional
    • deleteRepositoryTag

      public void deleteRepositoryTag(Object projectIdOrPath, Long repositoryId, String tagName) throws GitLabApiException
      Delete a registry repository tag.
      GitLab Endpoint: DELETE /projects/:id/registry/repositories/:repository_id/tags/:tag_name
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      tagName - the name of the tag to delete
      Throws:
      GitLabApiException - if any exception occurs
    • deleteRepositoryTags

      public void deleteRepositoryTags(Object projectIdOrPath, Long repositoryId, String nameRegex, Integer keepN, String olderThan) throws GitLabApiException
      Delete repository tags in bulk based on given criteria.
      GitLab Endpoint: DELETE /projects/:id/registry/repositories/:repository_id/tags

      This API call performs the following operations:

      1. It orders all tags by creation date. The creation date is the time of the manifest creation, not the time of tag push.
      2. It removes only the tags matching the given name_regex.
      3. It never removes the tag named latest.
      4. It keeps N latest matching tags (if keep_n is specified).
      5. It only removes tags that are older than X amount of time (if older_than is specified).
      6. It schedules the asynchronous job to be executed in the background.

      These operations are executed asynchronously and it might take time to get executed. You can run this at most once an hour for a given container repository.

      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      repositoryId - the ID of registry repository
      nameRegex - the regex of the name to delete. To delete all tags specify .*.
      keepN - the amount of latest tags of given name to keep.
      olderThan - tags to delete that are older than the given time, written in human readable form 1h, 1d, 1month.
      Throws:
      GitLabApiException - if any exception occurs