Class RunnersApi

  • All Implemented Interfaces:
    Constants

    public class RunnersApi
    extends AbstractApi
    This class provides an entry point to all the GitLab API repository files calls.
    • Constructor Detail

      • RunnersApi

        public RunnersApi​(GitLabApi gitLabApi)
    • Method Detail

      • getRunners

        public List<Runner> getRunners()
                                throws GitLabApiException
        Get a list of all available runners available to the user.
        GitLab Endpoint: GET /runners
        Returns:
        List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getRunners

        public List<Runner> getRunners​(int page,
                                       int perPage)
                                throws GitLabApiException
        Get a list of all available runners available to the user with pagination support.
        GitLab Endpoint: GET /runners
        Parameters:
        page - The page offset of runners
        perPage - The number of runners to get after the page offset
        Returns:
        List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getRunners

        public Pager<Runner> getRunners​(int itemsPerPage)
                                 throws GitLabApiException
        Get a list of all available runners available to the user.
        GitLab Endpoint: GET /runners
        Parameters:
        itemsPerPage - the number of Runner instances that will be fetched per page
        Returns:
        a Pager containing the Runners for the user
        Throws:
        GitLabApiException - if any exception occurs
      • getRunnersStream

        public Stream<Runner> getRunnersStream()
                                        throws GitLabApiException
        Get a Stream of all available runners available to the user.
        GitLab Endpoint: GET /runners
        Returns:
        Stream of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getRunners

        public List<Runner> getRunners​(Runner.RunnerType type,
                                       Runner.RunnerStatus status)
                                throws GitLabApiException
        Get a list of all available runners available to the user with pagination support.
        GitLab Endpoint: GET /runners
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        Returns:
        List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getRunners

        public List<Runner> getRunners​(Runner.RunnerType type,
                                       Runner.RunnerStatus status,
                                       int page,
                                       int perPage)
                                throws GitLabApiException
        Get a list of specific runners available to the user.
        GitLab Endpoint: GET /runners
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        page - the page offset of runners
        perPage - the number of runners to get after the page offset
        Returns:
        List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getRunners

        public Pager<Runner> getRunners​(Runner.RunnerType type,
                                        Runner.RunnerStatus status,
                                        int itemsPerPage)
                                 throws GitLabApiException
        Get a list of specific runners available to the user.
        GitLab Endpoint: GET /runners
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        itemsPerPage - The number of Runner instances that will be fetched per page
        Returns:
        a Pager containing the Runners for the user
        Throws:
        GitLabApiException - if any exception occurs
      • getRunnersStream

        public Stream<Runner> getRunnersStream​(Runner.RunnerType type,
                                               Runner.RunnerStatus status)
                                        throws GitLabApiException
        Get a Stream of all available runners available to the user with pagination support.
        GitLab Endpoint: GET /runners
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        Returns:
        Stream of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        public List<Runner> getAllRunners()
                                   throws GitLabApiException
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Returns:
        a List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        public List<Runner> getAllRunners​(int page,
                                          int perPage)
                                   throws GitLabApiException
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        page - The page offset of runners
        perPage - The number of runners to get after the page offset
        Returns:
        a list of all runners in the GitLab instance
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        public Pager<Runner> getAllRunners​(int itemsPerPage)
                                    throws GitLabApiException
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        itemsPerPage - The number of Runner instances that will be fetched per page
        Returns:
        List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunnersStream

        public Stream<Runner> getAllRunnersStream()
                                           throws GitLabApiException
        Get a Stream of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Returns:
        a Stream of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        public List<Runner> getAllRunners​(Runner.RunnerType type,
                                          Runner.RunnerStatus status)
                                   throws GitLabApiException
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        Returns:
        a List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        public List<Runner> getAllRunners​(Runner.RunnerType type,
                                          Runner.RunnerStatus status,
                                          int page,
                                          int perPage)
                                   throws GitLabApiException
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        page - The page offset of runners
        perPage - The number of runners to get after the page offset
        Returns:
        List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        public Pager<Runner> getAllRunners​(Runner.RunnerType type,
                                           Runner.RunnerStatus status,
                                           int itemsPerPage)
                                    throws GitLabApiException
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        itemsPerPage - The number of Runner instances that will be fetched per page
        Returns:
        a Pager containing the Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunnersStream

        public Stream<Runner> getAllRunnersStream​(Runner.RunnerType type,
                                                  Runner.RunnerStatus status)
                                           throws GitLabApiException
        Get a Stream of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        type - the type of runners to show, one of: instance_type, group_type, project_type, or null
        status - the status of runners to show, one of: active, paused, online, offline, or null
        Returns:
        a Stream of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        @Deprecated
        public List<Runner> getAllRunners​(Runner.RunnerStatus scope,
                                          int page,
                                          int perPage)
                                   throws GitLabApiException
        Deprecated.
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        scope - The scope of specific runners to show, one of: active, paused, online; showing all runners null
        page - The page offset of runners
        perPage - The number of runners to get after the page offset
        Returns:
        List of Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getAllRunners

        @Deprecated
        public Pager<Runner> getAllRunners​(Runner.RunnerStatus scope,
                                           int itemsPerPage)
                                    throws GitLabApiException
        Deprecated.
        Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
        GitLab Endpoint: GET /runners/all
        Parameters:
        scope - the scope of specific runners to show, one of: active, paused, online; showing all runners null
        itemsPerPage - The number of Runner instances that will be fetched per page
        Returns:
        a Pager containing the Runners
        Throws:
        GitLabApiException - if any exception occurs
      • getRunnerDetail

        public RunnerDetail getRunnerDetail​(Integer runnerId)
                                     throws GitLabApiException
        Get details of a runner.
        GitLab Endpoint: GET /runners/:id
        Parameters:
        runnerId - Runner id to get details for
        Returns:
        RunnerDetail instance.
        Throws:
        GitLabApiException - if any exception occurs
      • updateRunner

        public RunnerDetail updateRunner​(Integer runnerId,
                                         String description,
                                         Boolean active,
                                         List<String> tagList,
                                         Boolean runUntagged,
                                         Boolean locked,
                                         RunnerDetail.RunnerAccessLevel accessLevel)
                                  throws GitLabApiException
        Update details of a runner.
        GitLab Endpoint: PUT /runners/:id
        Parameters:
        runnerId - The ID of a runner
        description - The description of a runner
        active - The state of a runner; can be set to true or false
        tagList - The list of tags for a runner; put array of tags, that should be finally assigned to a runner
        runUntagged - Flag indicating the runner can execute untagged jobs
        locked - Flag indicating the runner is locked
        accessLevel - The access_level of the runner; not_protected or ref_protected
        Returns:
        RunnerDetail instance.
        Throws:
        GitLabApiException - if any exception occurs
      • removeRunner

        public void removeRunner​(Integer runnerId)
                          throws GitLabApiException
        Remove a runner.
        GitLab Endpoint: DELETE /runners/:id
        Parameters:
        runnerId - The ID of a runner
        Throws:
        GitLabApiException - if any exception occurs
      • getJobs

        public List<Job> getJobs​(Integer runnerId)
                          throws GitLabApiException
        List jobs that are being processed or were processed by specified Runner.
        GitLab Endpoint: GET /runners/:id/jobs
        Parameters:
        runnerId - The ID of a runner
        Returns:
        List jobs that are being processed or were processed by specified Runner
        Throws:
        GitLabApiException - if any exception occurs
      • getJobsStream

        public Stream<Job> getJobsStream​(Integer runnerId)
                                  throws GitLabApiException
        Get a Stream of jobs that are being processed or were processed by specified Runner.
        GitLab Endpoint: GET /runners/:id/jobs
        Parameters:
        runnerId - The ID of a runner
        Returns:
        a Stream of jobs that are being processed or were processed by specified Runner
        Throws:
        GitLabApiException - if any exception occurs
      • getJobs

        public List<Job> getJobs​(Integer runnerId,
                                 JobStatus status)
                          throws GitLabApiException
        List jobs that are being processed or were processed by specified Runner.
        GitLab Endpoint: GET /runners/:id/jobs
        Parameters:
        runnerId - The ID of a runner
        status - Status of the job; one of: running, success, failed, canceled
        Returns:
        List jobs that are being processed or were processed by specified Runner
        Throws:
        GitLabApiException - if any exception occurs
      • getJobsStream

        public Stream<Job> getJobsStream​(Integer runnerId,
                                         JobStatus status)
                                  throws GitLabApiException
        Get a Stream of jobs that are being processed or were processed by specified Runner.
        GitLab Endpoint: GET /runners/:id/jobs
        Parameters:
        runnerId - The ID of a runner
        status - Status of the job; one of: running, success, failed, canceled
        Returns:
        a Stream of jobs that are being processed or were processed by specified Runner
        Throws:
        GitLabApiException - if any exception occurs
      • getJobs

        public Pager<Job> getJobs​(Integer runnerId,
                                  int itemsPerPage)
                           throws GitLabApiException
        List jobs that are being processed or were processed by specified Runner.
        GitLab Endpoint: GET /runners/:id/jobs
        Parameters:
        runnerId - The ID of a runner
        itemsPerPage - The number of Runner instances that will be fetched per page
        Returns:
        a Pager containing the Jobs for the Runner
        Throws:
        GitLabApiException - if any exception occurs
      • getJobs

        public Pager<Job> getJobs​(Integer runnerId,
                                  JobStatus status,
                                  int itemsPerPage)
                           throws GitLabApiException
        List jobs that are being processed or were processed by specified Runner.
        GitLab Endpoint: GET /runners/:id/jobs
        Parameters:
        runnerId - The ID of a runner
        status - Status of the job; one of: running, success, failed, canceled
        itemsPerPage - The number of Runner instances that will be fetched per page
        Returns:
        a Pager containing the Jobs for the Runner
        Throws:
        GitLabApiException - if any exception occurs
      • getProjectRunners

        public List<Runner> getProjectRunners​(Object projectIdOrPath)
                                       throws GitLabApiException
        List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
        GitLab Endpoint: GET /projects/:id/runners
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        Returns:
        List of all Runner available in the project
        Throws:
        GitLabApiException - if any exception occurs
      • getProjectRunnersStream

        public Stream<Runner> getProjectRunnersStream​(Object projectIdOrPath)
                                               throws GitLabApiException
        Get a Stream all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
        GitLab Endpoint: GET /projects/:id/runners
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        Returns:
        a Stream of all Runner available in the project
        Throws:
        GitLabApiException - if any exception occurs
      • getProjectRunners

        public Pager<Runner> getProjectRunners​(Object projectIdOrPath,
                                               int itemsPerPage)
                                        throws GitLabApiException
        List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
        GitLab Endpoint: GET /projects/:id/runners
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        itemsPerPage - the number of Project instances that will be fetched per page
        Returns:
        Pager of all Runner available in the project
        Throws:
        GitLabApiException - if any exception occurs
      • enableRunner

        public Runner enableRunner​(Object projectIdOrPath,
                                   Integer runnerId)
                            throws GitLabApiException
        Enable an available specific runner in the project.
        GitLab Endpoint: POST /projects/:id/runners
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        runnerId - The ID of a runner
        Returns:
        Runner instance of the Runner enabled
        Throws:
        GitLabApiException - if any exception occurs
      • disableRunner

        public Runner disableRunner​(Object projectIdOrPath,
                                    Integer runnerId)
                             throws GitLabApiException
        Disable a specific runner from the project. It works only if the project isn't the only project associated with the specified runner. If so, an error is returned. Use the removeRunner(Integer) instead.
        GitLab Endpoint: DELETE /projects/:id/runners/:runner_id
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        runnerId - The ID of a runner
        Returns:
        Runner instance of the Runner disabled
        Throws:
        GitLabApiException - if any exception occurs
      • registerRunner

        public RunnerDetail registerRunner​(String token,
                                           String description,
                                           Boolean active,
                                           List<String> tagList,
                                           Boolean runUntagged,
                                           Boolean locked,
                                           Integer maximumTimeout)
                                    throws GitLabApiException
        Register a new runner for the gitlab instance.
        GitLab Endpoint: POST /runners/
        Parameters:
        token - the token of the project (for project specific runners) or the token from the admin page
        description - The description of a runner
        active - The state of a runner; can be set to true or false
        tagList - The list of tags for a runner; put array of tags, that should be finally assigned to a runner
        runUntagged - Flag indicating the runner can execute untagged jobs
        locked - Flag indicating the runner is locked
        maximumTimeout - the maximum timeout set when this Runner will handle the job
        Returns:
        RunnerDetail instance.
        Throws:
        GitLabApiException - if any exception occurs
      • deleteRunner

        public void deleteRunner​(String token)
                          throws GitLabApiException
        Deletes a registered Runner.
        GitLab Endpoint: DELETE /runners/
        Parameters:
        token - the runners authentication token
        Throws:
        GitLabApiException - if any exception occurs