Class DeployKeysApi

  • All Implemented Interfaces:
    Constants

    public class DeployKeysApi
    extends AbstractApi
    This class implements the client side API for the GitLab Deploy Keys API calls.
    • Constructor Detail

      • DeployKeysApi

        public DeployKeysApi​(GitLabApi gitLabApi)
    • Method Detail

      • getDeployKeys

        public List<DeployKey> getDeployKeys()
                                      throws GitLabApiException
        Get a list of all deploy keys across all projects of the GitLab instance. This method requires admin access.
        GitLab Endpoint: GET /deploy_keys
        Returns:
        a list of DeployKey
        Throws:
        GitLabApiException - if any exception occurs
      • getDeployKeys

        public List<DeployKey> getDeployKeys​(int page,
                                             int perPage)
                                      throws GitLabApiException
        Get a list of all deploy keys across all projects of the GitLab instance using the specified page and per page settings. This method requires admin access.
        GitLab Endpoint: GET /deploy_keys
        Parameters:
        page - the page to get
        perPage - the number of deploy keys per page
        Returns:
        the list of DeployKey in the specified range
        Throws:
        GitLabApiException - if any exception occurs
      • getDeployKeys

        public Pager<DeployKey> getDeployKeys​(int itemsPerPage)
                                       throws GitLabApiException
        Get a Pager of all deploy keys across all projects of the GitLab instance. This method requires admin access.
        GitLab Endpoint: GET /deploy_keys
        Parameters:
        itemsPerPage - the number of DeployKey instances that will be fetched per page
        Returns:
        a Pager of DeployKey
        Throws:
        GitLabApiException - if any exception occurs
      • getDeployKeysStream

        public Stream<DeployKey> getDeployKeysStream()
                                              throws GitLabApiException
        Get a Stream of all deploy keys across all projects of the GitLab instance. This method requires admin access.
        GitLab Endpoint: GET /deploy_keys
        Returns:
        a list of DeployKey
        Throws:
        GitLabApiException - if any exception occurs
      • getProjectDeployKeys

        public List<DeployKey> getProjectDeployKeys​(Object projectIdOrPath)
                                             throws GitLabApiException
        Get a list of the deploy keys for the specified project. This method requires admin access.
        GitLab Endpoint: GET /projects/:id/deploy_keys
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        Returns:
        a list of DeployKey
        Throws:
        GitLabApiException - if any exception occurs
      • getProjectDeployKeys

        public List<DeployKey> getProjectDeployKeys​(Object projectIdOrPath,
                                                    int page,
                                                    int perPage)
                                             throws GitLabApiException
        Get a list of the deploy keys for the specified project using the specified page and per page settings. This method requires admin access.
        GitLab Endpoint: GET /projects/:id/deploy_keys
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        page - the page to get
        perPage - the number of deploy keys per page
        Returns:
        the list of DeployKey in the specified range
        Throws:
        GitLabApiException - if any exception occurs
      • getProjectDeployKeys

        public Pager<DeployKey> getProjectDeployKeys​(Object projectIdOrPath,
                                                     int itemsPerPage)
                                              throws GitLabApiException
        Get a Pager of the deploy keys for the specified project. This method requires admin access.
        GitLab Endpoint: GET /projects/:id/deploy_keys
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance@param projectId the ID of the project
        itemsPerPage - the number of DeployKey instances that will be fetched per page
        Returns:
        a Pager of DeployKey
        Throws:
        GitLabApiException - if any exception occurs
      • getProjectDeployKeysStream

        public Stream<DeployKey> getProjectDeployKeysStream​(Object projectIdOrPath)
                                                     throws GitLabApiException
        Get a list of the deploy keys for the specified project. This method requires admin access.
        GitLab Endpoint: GET /projects/:id/deploy_keys
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        Returns:
        a list of DeployKey
        Throws:
        GitLabApiException - if any exception occurs
      • getDeployKey

        public DeployKey getDeployKey​(Object projectIdOrPath,
                                      Integer keyId)
                               throws GitLabApiException
        Get a single deploy key for the specified project.
        GitLab Endpoint: GET /projects/:id/deploy_keys/:key_id
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        keyId - the ID of the deploy key to delete
        Returns:
        the DeployKey instance for the specified project ID and key ID
        Throws:
        GitLabApiException - if any exception occurs
      • getOptionalDeployKey

        public Optional<DeployKey> getOptionalDeployKey​(Object projectIdOrPath,
                                                        Integer keyId)
        Get a single deploy key for the specified project as an Optional instance.
        GitLab Endpoint: GET /projects/:id/deploy_keys/:key_id
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        keyId - the ID of the deploy key to delete
        Returns:
        the DeployKey for the specified project ID and key ID as an Optional instance
      • addDeployKey

        public DeployKey addDeployKey​(Object projectIdOrPath,
                                      String title,
                                      String key,
                                      Boolean canPush)
                               throws GitLabApiException
        Creates a new deploy key for a project.
        GitLab Endpoint: POST /projects/:id/deploy_keys
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        title - the new deploy key's title, required
        key - the new deploy key, required
        canPush - can deploy key push to the project's repository, optional
        Returns:
        an DeployKey instance with info on the added deploy key
        Throws:
        GitLabApiException - if any exception occurs
      • deleteDeployKey

        public void deleteDeployKey​(Object projectIdOrPath,
                                    Integer keyId)
                             throws GitLabApiException
        Removes a deploy key from the project. If the deploy key is used only for this project,it will be deleted from the system.
        GitLab Endpoint: DELETE /projects/:id/deploy_keys/:key_id
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        keyId - the ID of the deploy key to delete
        Throws:
        GitLabApiException - if any exception occurs
      • enableDeployKey

        public DeployKey enableDeployKey​(Object projectIdOrPath,
                                         Integer keyId)
                                  throws GitLabApiException
        Enables a deploy key for a project so this can be used. Returns the enabled key when successful.
        GitLab Endpoint: POST /projects/:id/deploy_keys/:key_id/enable
        Parameters:
        projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
        keyId - the ID of the deploy key to enable
        Returns:
        an DeployKey instance with info on the enabled deploy key
        Throws:
        GitLabApiException - if any exception occurs