Class EnvironmentsApi

  • All Implemented Interfaces:
    Constants

    public class EnvironmentsApi
    extends AbstractApi
    This class provides an entry point to all the GitLab API Environments API calls.
    See Also:
    Environments API
    • Constructor Detail

      • EnvironmentsApi

        public EnvironmentsApi​(GitLabApi gitLabApi)
    • Method Detail

      • getEnvironments

        public java.util.List<Environment> getEnvironments​(java.lang.Object projectIdOrPath)
                                                    throws GitLabApiException
        Get all environments for a given project.
        GitLab Endpoint: GET /projects/:id/environments
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        Returns:
        a List of Environment instances
        Throws:
        GitLabApiException - if any exception occurs
      • getEnvironmentsStream

        public java.util.stream.Stream<Environment> getEnvironmentsStream​(java.lang.Object projectIdOrPath)
                                                                   throws GitLabApiException
        Get a Stream of all environments for a given project.
        GitLab Endpoint: GET /projects/:id/environments
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        Returns:
        a Stream of Environment instances
        Throws:
        GitLabApiException - if any exception occurs
      • getEnvironments

        public Pager<Environment> getEnvironments​(java.lang.Object projectIdOrPath,
                                                  int itemsPerPage)
                                           throws GitLabApiException
        Get a Pager of all environments for a given project.
        GitLab Endpoint: GET /projects/:id/environments
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        itemsPerPage - the number of Environment instances that will be fetched per page
        Returns:
        a Pager of Environment instances
        Throws:
        GitLabApiException - if any exception occurs
      • getEnvironment

        public Environment getEnvironment​(java.lang.Object projectIdOrPath,
                                          java.lang.Long environmentId)
                                   throws GitLabApiException
        Get a specific environment.
        GitLab Endpoint: GET /projects/:id/environments/:environment_id
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        environmentId - the ID of the environment to get
        Returns:
        an Environment instance
        Throws:
        GitLabApiException - if any exception occurs
      • getOptionalEnvironment

        public java.util.Optional<Environment> getOptionalEnvironment​(java.lang.Object projectIdOrPath,
                                                                      java.lang.Long environmentId)
        Get a specific environment. as an Optional instance.
        GitLab Endpoint: GET /projects/:id/environments/:environment_id
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        environmentId - the ID of the environment to get
        Returns:
        the Environment as an Optional instance
      • createEnvironment

        public Environment createEnvironment​(java.lang.Object projectIdOrPath,
                                             java.lang.String name,
                                             java.lang.String externalUrl)
                                      throws GitLabApiException
        Create a new environment with the given name and external_url.
        GitLab Endpoint:POST /projects/:id/environments
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        name - the name of the environment
        externalUrl - the place to link to for this environment
        Returns:
        the created Environment instance
        Throws:
        GitLabApiException - if any exception occurs
      • updateEnvironment

        public Environment updateEnvironment​(java.lang.Object projectIdOrPath,
                                             java.lang.Long environmentId,
                                             java.lang.String name,
                                             java.lang.String externalUrl)
                                      throws GitLabApiException
        Update an existing environment.
        GitLab Endpoint:POST /projects/:id/environments
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        environmentId - the ID of the environment to update
        name - the name of the environment
        externalUrl - the place to link to for this environment
        Returns:
        the created Environment instance
        Throws:
        GitLabApiException - if any exception occurs
      • stopEnvironment

        public Environment stopEnvironment​(java.lang.Object projectIdOrPath,
                                           java.lang.Long environmentId)
                                    throws GitLabApiException
        Stop an environment.
        GitLab Endpoint: POST /projects/:id/environments/:environment_id/stop
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        environmentId - the ID of the environment to stop
        Returns:
        the stopped Environment instance
        Throws:
        GitLabApiException - if any exception occurs
      • deleteEnvironment

        public void deleteEnvironment​(java.lang.Object projectIdOrPath,
                                      java.lang.Long environmentId)
                               throws GitLabApiException
        Delete an environment.
        GitLab Endpoint: DELETE /projects/:id/environments/:environment_id
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        environmentId - the ID of the environment to delete
        Throws:
        GitLabApiException - if any exception occurs
      • createEnvironment

        public Environment createEnvironment​(java.lang.Object projectIdOrPath,
                                             java.lang.Long environmentId)
                                      throws GitLabApiException
        Stop an environment.
        GitLab Endpoint:POST /projects/:id/environments/:environment_id/stop
        Parameters:
        projectIdOrPath - id, path of the project, or a Project instance holding the project ID or path
        environmentId - the ID of the environment to stop
        Returns:
        the Environment instance of the stopped environment
        Throws:
        GitLabApiException - if any exception occurs