Package org.azd.git

Class GitApi

All Implemented Interfaces:
GitDetails

public class GitApi extends AzDAsyncApi<GitApi> implements GitDetails
GIT class to manage git API
  • Constructor Details

    • GitApi

      public GitApi(Connection connection)
      Pass the connection object to work with Git Api
      Parameters:
      connection - Connection object
  • Method Details

    • createRepository

      public GitRepository createRepository(String repositoryName, String projectId) throws AzDException
      Create a git repository in a team project.
      Specified by:
      createRepository in interface GitDetails
      Parameters:
      repositoryName - Name of the repository
      projectId - id of the project
      Returns:
      git repository object GitRepository
      Throws:
      AzDException - Default Api Exception handler.
    • deleteRepository

      public Void deleteRepository(String repositoryId) throws AzDException
      Delete a git repository
      Specified by:
      deleteRepository in interface GitDetails
      Parameters:
      repositoryId - pass the repository id
      Throws:
      AzDException - Default Api Exception handler.
    • deleteRepositoryFromRecycleBin

      public Void deleteRepositoryFromRecycleBin(String repositoryId) throws AzDException
      Destroy (hard delete) a soft-deleted Git repository.
      Specified by:
      deleteRepositoryFromRecycleBin in interface GitDetails
      Parameters:
      repositoryId - pass the repository id
      Throws:
      AzDException - Default Api Exception handler.
    • getDeletedRepositories

      public GitDeletedRepositories getDeletedRepositories() throws AzDException
      Retrieve deleted git repositories.
      Specified by:
      getDeletedRepositories in interface GitDetails
      Returns:
      Git deleted repository object
      Throws:
      AzDException - Default Api Exception handler.
    • getRecycleBinRepositories

      public GitDeletedRepositories getRecycleBinRepositories() throws AzDException
      Retrieve soft-deleted git repositories from the recycle bin.
      Specified by:
      getRecycleBinRepositories in interface GitDetails
      Returns:
      array of git deleted recycle bin repositories
      Throws:
      AzDException - Default Api Exception handler.
    • getRepository

      public GitRepository getRepository(String repositoryName) throws AzDException
      Retrieve a git repository.
      Specified by:
      getRepository in interface GitDetails
      Parameters:
      repositoryName - pass the repository name
      Returns:
      git repository object
      Throws:
      AzDException - Default Api Exception handler.
    • getRepositories

      public Repositories getRepositories() throws AzDException
      Retrieve git repositories.
      Specified by:
      getRepositories in interface GitDetails
      Returns:
      array of git repositories
      Throws:
      AzDException - Default Api Exception handler.
    • getRepositories

      public Repositories getRepositories(boolean includeHidden) throws AzDException
      Retrieve git repositories.
      Specified by:
      getRepositories in interface GitDetails
      Parameters:
      includeHidden - If true then includes hidden repositories.
      Returns:
      array of git repositories
      Throws:
      AzDException - Default Api Exception handler.
    • getRepositories

      public Repositories getRepositories(boolean includeLinks, boolean includeAllUrls) throws AzDException
      Retrieve git repositories.
      Specified by:
      getRepositories in interface GitDetails
      Parameters:
      includeLinks - Set this value to true to include reference links.
      includeAllUrls - If true then includes all remote URLs.
      Returns:
      array of git repositories
      Throws:
      AzDException - Default Api Exception handler.
    • getRepositories

      public Repositories getRepositories(boolean includeAllUrls, boolean includeLinks, boolean includeHidden) throws AzDException
      Retrieve git repositories.
      Specified by:
      getRepositories in interface GitDetails
      Parameters:
      includeAllUrls - If true then includes all remote URLs.
      includeLinks - Set this value to true to include reference links.
      includeHidden - If true then includes hidden repositories.
      Returns:
      array of git repositories
      Throws:
      AzDException - Default Api Exception handler.
    • restoreRepositoryFromRecycleBin

      public GitRepository restoreRepositoryFromRecycleBin(String repositoryId, boolean deleted) throws AzDException
      Recover a soft-deleted Git repository. Recently deleted repositories go into a soft-delete state for a period of time before they are hard deleted and become unrecoverable.
      Specified by:
      restoreRepositoryFromRecycleBin in interface GitDetails
      Parameters:
      repositoryId - pass the repository id
      deleted - Setting to false will undo earlier deletion and restore the repository.
      Returns:
      object of git repository GitRepository
      Throws:
      AzDException - Default Api Exception handler.
    • updateRepository

      public GitRepository updateRepository(String repositoryId, String repositoryName, String defaultBranchName) throws AzDException
      Updates the Git repository with either a new repo name or a new default branch.
      Specified by:
      updateRepository in interface GitDetails
      Parameters:
      repositoryId - provide the repository id
      repositoryName - pass the repository name to rename
      defaultBranchName - pass the default branch name to set
      Returns:
      repository object
      Throws:
      AzDException - Default Api Exception handler.
    • createPullRequest

      public GitPullRequest createPullRequest(String repositoryId, String sourceRefName, String targetRefName, String title, String description, String[] reviewers) throws AzDException
      Create a pull request.
      Specified by:
      createPullRequest in interface GitDetails
      Parameters:
      repositoryId - The repository ID of the pull request's target branch.
      sourceRefName - The name of the source branch of the pull request.
      targetRefName - The name of the target branch of the pull request.
      title - The title of the pull request.
      description - The description of the pull request.
      reviewers - A list of reviewers on the pull request along with the state of their votes.
      Returns:
      an object of git pull request GitPullRequest
      Throws:
      AzDException - Default Api Exception handler.
    • createPullRequest

      public GitPullRequest createPullRequest(String repositoryId, String sourceRefName, String targetRefName, String title, String description, boolean isDraft) throws AzDException
      Create a pull request and optionally make it a draft. You can specify only the source branch name such as develop and target branch name such as master.
      Specified by:
      createPullRequest in interface GitDetails
      Parameters:
      repositoryId - The repository ID of the pull request's target branch.
      sourceRefName - The name of the source branch of the pull request.
      targetRefName - The name of the target branch of the pull request.
      title - The title of the pull request.
      description - The description of the pull request.
      isDraft - if set to true the pull request will be in draft mode.
      Returns:
      an object of git pull request GitPullRequest
      Throws:
      AzDException - Default Api Exception handler.
    • createPullRequest

      public GitPullRequest createPullRequest(GitPullRequest gitPullRequest) throws AzDException
      Create a pull request.
      Specified by:
      createPullRequest in interface GitDetails
      Parameters:
      gitPullRequest - a GitPullRequest object.
      Returns:
      an object of git pull request GitPullRequest
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequest

      public GitPullRequest getPullRequest(String repositoryName, int pullRequestId) throws AzDException
      Retrieve a pull request.
      Specified by:
      getPullRequest in interface GitDetails
      Parameters:
      repositoryName - The repository name of the pull request's target branch.
      pullRequestId - The ID of the pull request to retrieve.
      Returns:
      GitPullRequest object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequest

      public GitPullRequest getPullRequest(String repositoryName, int pullRequestId, boolean includeCommits) throws AzDException
      Retrieve a pull request.
      Specified by:
      getPullRequest in interface GitDetails
      Parameters:
      repositoryName - The repository name of the pull request's target branch.
      pullRequestId - The ID of the pull request to retrieve.
      includeCommits - If true, the pull request will be returned with the associated commits.
      Returns:
      GitPullRequest object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequest

      public GitPullRequest getPullRequest(String repositoryName, int pullRequestId, boolean includeCommits, boolean includeWorkItemRefs) throws AzDException
      Retrieve a pull request.
      Specified by:
      getPullRequest in interface GitDetails
      Parameters:
      repositoryName - The repository name of the pull request's target branch.
      pullRequestId - The ID of the pull request to retrieve.
      includeCommits - If true, the pull request will be returned with the associated commits.
      includeWorkItemRefs - If true, the pull request will be returned with the associated work item references.
      Returns:
      GitPullRequest object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestById

      public GitPullRequest getPullRequestById(int pullRequestId) throws AzDException
      Retrieve a pull request.
      Specified by:
      getPullRequestById in interface GitDetails
      Parameters:
      pullRequestId - The ID of the pull request to retrieve.
      Returns:
      GitPullRequest object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequests

      public PullRequests getPullRequests(String repositoryName) throws AzDException
      Retrieve all pull requests from a repository
      Specified by:
      getPullRequests in interface GitDetails
      Parameters:
      repositoryName - specify the repository name
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequests

      public PullRequests getPullRequests(String repositoryName, int top) throws AzDException
      Retrieve all pull requests from a repository
      Specified by:
      getPullRequests in interface GitDetails
      Parameters:
      repositoryName - specify the repository name
      top - The number of pull requests to retrieve.
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequests

      public PullRequests getPullRequests(String repositoryName, int top, int skip) throws AzDException
      Retrieve all pull requests from a repository
      Specified by:
      getPullRequests in interface GitDetails
      Parameters:
      repositoryName - specify the repository name
      top - The number of pull requests to retrieve.
      skip - The number of pull requests to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequests

      public PullRequests getPullRequests(String repositoryName, int top, int skip, String creatorId) throws AzDException
      Retrieve all pull requests from a repository
      Specified by:
      getPullRequests in interface GitDetails
      Parameters:
      repositoryName - specify the repository name
      top - The number of pull requests to retrieve.
      skip - The number of pull requests to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.
      creatorId - If set, search for pull requests that were created by this identity.
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequests

      public PullRequests getPullRequests(String repositoryName, boolean includeLinks) throws AzDException
      Retrieve all pull requests from a repository
      Specified by:
      getPullRequests in interface GitDetails
      Parameters:
      repositoryName - specify the repository name
      includeLinks - Whether to include the _links field on the shallow references.
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequests

      public PullRequests getPullRequests(String repositoryName, PullRequestStatus status) throws AzDException
      Retrieve all pull requests from a repository
      Specified by:
      getPullRequests in interface GitDetails
      Parameters:
      repositoryName - specify the repository name
      status - If set, search for pull requests that are in this state. Defaults to Active if unset.
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequests

      public PullRequests getPullRequests(String repositoryName, GitPullRequestQueryParameters gitPullRequestQueryParameters) throws AzDException
      Retrieve all pull requests from a repository
      Specified by:
      getPullRequests in interface GitDetails
      Parameters:
      repositoryName - specify the repository name
      gitPullRequestQueryParameters - Property bag of query parameters pertaining to the pull requests.
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestsByProject

      public PullRequests getPullRequestsByProject() throws AzDException
      Gets all pull requests from a project. To get the pull requests from non-default project you have to call setProject method from Connection.
      Specified by:
      getPullRequestsByProject in interface GitDetails
      Returns:
      PullRequests object
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestsByProject

      public PullRequests getPullRequestsByProject(int top) throws AzDException
      Gets all pull requests from a project. To get the pull requests from non-default project you have to call setProject method from Connection.
      Specified by:
      getPullRequestsByProject in interface GitDetails
      Parameters:
      top - The number of pull requests to retrieve.
      Returns:
      PullRequests PullRequest
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestsByProject

      public PullRequests getPullRequestsByProject(PullRequestStatus status) throws AzDException
      Gets all pull requests from a project. To get the pull requests from non-default project you have to call setProject method from Connection.
      Specified by:
      getPullRequestsByProject in interface GitDetails
      Parameters:
      status - If set, search for pull requests that are in this state. Defaults to Active if unset.
      Returns:
      PullRequests PullRequest
      Throws:
      AzDException - Default Api Exception handler.
    • updatePullRequest

      public GitPullRequest updatePullRequest(String repositoryId, int pullRequestId, Object body) throws AzDException
      Update a pull request

      These are the properties that can be updated with the API: Status Title Description (up to 4000 characters) CompletionOptions MergeOptions AutoCompleteSetBy.Id TargetRefName (when the PR retargeting feature is enabled) Attempting to update other properties outside of this list will either cause the server to throw an InvalidArgumentValueException, or to silently ignore the update.

      Specified by:
      updatePullRequest in interface GitDetails
      Parameters:
      repositoryId - The repository ID of the pull request's target branch.
      pullRequestId - ID of the pull request to update.
      Returns:
      GitPullRequest Object GitPullRequest
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestsByProject

      public PullRequests getPullRequestsByProject(int skip, int top, String creatorId, boolean includeLinks, String repositoryId, String reviewerId, String sourceRefName, String sourceRepositoryId, PullRequestStatus status, String targetRefName) throws AzDException
      Gets all pull requests from a project. To get the pull requests from non-default project you have to call setProject method from Connection.
      Specified by:
      getPullRequestsByProject in interface GitDetails
      Parameters:
      skip - The number of pull requests to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.
      top - The number of pull requests to retrieve.
      creatorId - If set, search for pull requests that were created by this identity.
      includeLinks - Whether to include the _links field on the shallow references
      repositoryId - If set, search for pull requests whose target branch is in this repository.
      reviewerId - If set, search for pull requests that have this identity as a reviewer.
      sourceRefName - If set, search for pull requests from this branch.
      sourceRepositoryId - If set, search for pull requests whose source branch is in this repository.
      status - If set, search for pull requests that are in this state. Defaults to Active if unset.
      targetRefName - If set, search for pull requests into this branch.
      Returns:
      PullRequests PullRequest
      Throws:
      AzDException - Default Api Exception handler.
    • getBranch

      public GitRef getBranch(String repositoryName, String branchName) throws AzDException
      Get a specific branch from a repository.
      Specified by:
      getBranch in interface GitDetails
      Parameters:
      repositoryName - The name of the repository.
      branchName - The name of the branch.
      Returns:
      The branch as a GitRef object.
      Throws:
      AzDException - Default Api Exception handler.
    • getBranches

      public GitRefs getBranches(String repositoryName) throws AzDException
      Get the branches from a repository.
      Specified by:
      getBranches in interface GitDetails
      Parameters:
      repositoryName - The name of the repository.
      Returns:
      The GitRefs with the branches.
      Throws:
      AzDException - Default Api Exception handler.
    • updateBranchLock

      public GitRef updateBranchLock(String repositoryName, String branchName, boolean isLocked) throws AzDException
      Lock or Unlock a branch with repository name and branch name.
      Specified by:
      updateBranchLock in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      branchName - The name of the branch to lock/unlock
      isLocked - true to lock the branch and false to unlock.
      Returns:
      GitRef GitRef
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestWorkItems

      public ResourceRefs getPullRequestWorkItems(int pullRequestId, String repositoryName) throws AzDException
      Retrieve a list of work items associated with a pull request.
      Specified by:
      getPullRequestWorkItems in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryName - ID or name of the repository.
      Returns:
      ResourceRefs ResourceRefs
      Throws:
      AzDException - Default Api Exception handler.
    • createPullRequestLabel

      public WebApiTagDefinition createPullRequestLabel(String repositoryName, int pullRequestId, String labelName) throws AzDException
      Create a label for a specified pull request. The only required field is the name of the new label.
      Specified by:
      createPullRequestLabel in interface GitDetails
      Parameters:
      repositoryName - The repository name of the pull request’s target branch.
      pullRequestId - ID of the pull request.
      labelName - tag/label name
      Returns:
      WebApi tag object WebApiTagDefinition
      Throws:
      AzDException - Default Api Exception handler.
    • deletePullRequestLabel

      public Void deletePullRequestLabel(String repositoryName, int pullRequestId, String labelName) throws AzDException
      Removes a label from the set of those assigned to the pull request.
      Specified by:
      deletePullRequestLabel in interface GitDetails
      Parameters:
      repositoryName - The repository name of the pull request’s target branch.
      pullRequestId - ID of the pull request.
      labelName - tag/label name
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestLabel

      public WebApiTagDefinition getPullRequestLabel(String repositoryName, int pullRequestId, String labelName) throws AzDException
      Retrieves a single label that has been assigned to a pull request.
      Specified by:
      getPullRequestLabel in interface GitDetails
      Parameters:
      repositoryName - The repository name of the pull request’s target branch.
      pullRequestId - ID of the pull request.
      labelName - tag/label name
      Returns:
      WebApi tag object WebApiTagDefinition
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestLabels

      public WebApiTagDefinitions getPullRequestLabels(String repositoryName, int pullRequestId) throws AzDException
      Get all the labels assigned to a pull request.
      Specified by:
      getPullRequestLabels in interface GitDetails
      Parameters:
      repositoryName - The repository name of the pull request’s target branch.
      pullRequestId - ID of the pull request.
      Returns:
      List of WebApi tag object WebApiTagDefinitions
      Throws:
      AzDException - Default Api Exception handler.
    • createPullRequestReviewer

      public IdentityRefWithVote createPullRequestReviewer(int pullRequestId, String repositoryName, String reviewerId, int vote, boolean isRequired) throws AzDException
      Add a reviewer to a pull request or cast a vote.
      Specified by:
      createPullRequestReviewer in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryName - The repository name of the pull request's target branch.
      reviewerId - ID of the reviewer.
      vote - Vote on a pull request: 10 - approved 5 - approved with suggestions 0 - no vote -5 - waiting for author -10 - rejected
      isRequired - Indicates if this is a required reviewer for this pull request.
      Returns:
      PullRequestReviewer IdentityRefWithVote
      Throws:
      AzDException - Default Api Exception handler.
    • deletePullRequestReviewer

      public Void deletePullRequestReviewer(int pullRequestId, String repositoryName, String reviewerId) throws AzDException
      Remove a reviewer from a pull request.
      Specified by:
      deletePullRequestReviewer in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryName - The repository name of the pull request's target branch.
      reviewerId - ID of the reviewer.
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestReviewer

      public IdentityRefWithVote getPullRequestReviewer(int pullRequestId, String repositoryName, String reviewerId) throws AzDException
      Retrieve information about a particular reviewer on a pull request
      Specified by:
      getPullRequestReviewer in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryName - The repository name of the pull request's target branch.
      reviewerId - ID of the reviewer.
      Returns:
      PullRequestReviewer IdentityRefWithVote
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestReviewers

      public PullRequestReviewers getPullRequestReviewers(int pullRequestId, String repositoryName) throws AzDException
      Retrieve the reviewers for a pull request
      Specified by:
      getPullRequestReviewers in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryName - The repository name of the pull request's target branch.
      Returns:
      List of PullRequestReviewer PullRequestReviewers
      Throws:
      AzDException - Default Api Exception handler.
    • updatePullRequestReviewer

      public IdentityRefWithVote updatePullRequestReviewer(int pullRequestId, String repositoryName, String reviewerId, boolean isFlagged, boolean hasDeclined) throws AzDException
      Edit a reviewer entry. These fields are patchable: isFlagged, hasDeclined
      Specified by:
      updatePullRequestReviewer in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryName - The repository name of the pull request's target branch.
      reviewerId - ID of the reviewer.
      isFlagged - Indicates if this reviewer is flagged for attention on this pull request.
      hasDeclined - Indicates if this reviewer has declined to review this pull request.
      Returns:
      PullRequestReviewer IdentityRefWithVote
      Throws:
      AzDException - Default Api Exception handler.
    • createAnnotatedTag

      public GitAnnotatedTag createAnnotatedTag(String repositoryName, String tagName, String objectId, String message) throws AzDException
      Create an annotated tag.
      Specified by:
      createAnnotatedTag in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      tagName - The name of the annotated tag.
      objectId - The objectId (Sha1Id) of the tag.
      message - The tagging Message.
      Returns:
      A Git annotated tag object GitAnnotatedTag.
      Throws:
      AzDException - Default Api Exception handler.
    • getAnnotatedTag

      public GitAnnotatedTag getAnnotatedTag(String repositoryName, String objectId) throws AzDException
      Get an annotated tag.
      Specified by:
      getAnnotatedTag in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      objectId - ObjectId (Sha1Id) of tag to get.
      Returns:
      A Git annotated tag object GitAnnotatedTag.
      Throws:
      AzDException - Default Api Exception handler.
    • getCommit

      public GitCommit getCommit(String repositoryName, String commitId) throws AzDException
      Retrieve a particular commit.
      Specified by:
      getCommit in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      commitId - The id of the commit.
      Returns:
      Git commit object GitCommit
      Throws:
      AzDException - Default Api Exception handler.
    • getCommit

      public GitCommit getCommit(String repositoryName, String commitId, int changeCount) throws AzDException
      Retrieve a particular commit.
      Specified by:
      getCommit in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      commitId - The id of the commit.
      changeCount - The number of changes to include in the result.
      Returns:
      Git commit object GitCommit
      Throws:
      AzDException - Default Api Exception handler.
    • getChanges

      public GitCommitChanges getChanges(String repositoryName, String commitId) throws AzDException
      Retrieve changes for a particular commit.
      Specified by:
      getChanges in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      commitId - The id of the commit.
      Returns:
      Git commit changes object GitCommitChanges
      Throws:
      AzDException - Default Api Exception handler.
    • getChanges

      public GitCommitChanges getChanges(String repositoryName, String commitId, int top, int skip) throws AzDException
      Retrieve changes for a particular commit.
      Specified by:
      getChanges in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      commitId - The id of the commit.
      top - The maximum number of changes to return.
      skip - The number of changes to skip.
      Returns:
      Git commit changes object GitCommitChanges
      Throws:
      AzDException - Default Api Exception handler.
    • getCommits

      public GitCommits getCommits(String repositoryName) throws AzDException
      Retrieve git commits for a project.
      Specified by:
      getCommits in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      Returns:
      Array Git commit object GitCommits
      Throws:
      AzDException - Default Api Exception handler.
    • getCommits

      public GitCommits getCommits(String repositoryName, int top) throws AzDException
      Retrieve git commits for a project.
      Specified by:
      getCommits in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      top - Maximum number of entries to retrieve
      Returns:
      Array Git commit object GitCommits
      Throws:
      AzDException - Default Api Exception handler.
    • getCommits

      public GitCommits getCommits(String repositoryName, List<String> ids) throws AzDException
      Retrieve git commits for a project.
      Specified by:
      getCommits in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      ids - If provided, specifies the exact commit ids of the commits to fetch. May not be combined with other parameters.
      Returns:
      Array Git commit object GitCommits
      Throws:
      AzDException - Default Api Exception handler.
    • getCommits

      public GitCommits getCommits(String repositoryName, int top, int skip, String author, String version, GitVersionOptions versionOptions, GitVersionType versionType, boolean excludeDeletes, String fromCommitId, String toCommitId, String fromDate, String toDate, GitHistoryMode historyMode, List<String> ids, boolean includeLinks, boolean includePushData, boolean includeUserImageUrl, boolean includeWorkItems, String itemPath, boolean showOldestCommitsFirst, String user, String itemVersion, GitVersionOptions itemVersionOptions, GitVersionType itemVersionType) throws AzDException
      Retrieve git commits for a project.
      Specified by:
      getCommits in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      top - Maximum number of entries to retrieve.
      skip - Number of entries to skip.
      author - Alias or display name of the author.
      version - Version string identifier (name of tag/branch, SHA1 of commit).
      versionOptions - Version options - Specify additional modifiers to version (e.g Previous).
      versionType - Version type (branch, tag, or commit). Determines how Id is interpreted.
      excludeDeletes - Only applies when an itemPath is specified. This determines whether to exclude delete entries of the specified path.
      fromCommitId - If provided, a lower bound for filtering commits alphabetically.
      toCommitId - If provided, an upper bound for filtering commits alphabetically
      fromDate - If provided, only include history entries created after this date (string).
      toDate - If provided, only include history entries created before this date (string)
      historyMode - What Git history mode should be used. This only applies to the search criteria when Ids = null and an itemPath is specified.
      ids - If provided, specifies the exact commit ids of the commits to fetch. May not be combined with other parameters.
      includeLinks - Whether to include the _links field on the shallow references
      includePushData - Whether to include the push information
      includeUserImageUrl - Whether to include the image Url for committers and authors
      includeWorkItems - Whether to include linked work items
      itemPath - Path of item to search under
      showOldestCommitsFirst - If enabled, this option will ignore the itemVersion and compareVersion parameters.
      user - Alias or display name of the committer
      itemVersion - Version string identifier (name of tag/branch, SHA1 of commit)
      itemVersionOptions - Version options - Specify additional modifiers to version (e.g Previous)
      itemVersionType - Version type (branch, tag, or commit). Determines how Id is interpreted
      Returns:
      Array Git commit object GitCommits
      Throws:
      AzDException - Default Api Exception handler.
    • getPushCommits

      public GitCommits getPushCommits(String repositoryName, int pushId) throws AzDException
      Retrieve a list of commits associated with a particular push.
      Specified by:
      getPushCommits in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      pushId - The id of the push.
      Returns:
      Array Git commit object GitCommits
      Throws:
      AzDException - Default Api Exception handler.
    • getPushCommits

      public GitCommits getPushCommits(String repositoryName, int pushId, boolean includeLinks, int top, int skip) throws AzDException
      Retrieve a list of commits associated with a particular push.
      Specified by:
      getPushCommits in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      pushId - The id of the push.
      includeLinks - Set to false to avoid including REST Url links for resources. Defaults to true.
      top - The maximum number of commits to return ("get the top x commits").
      skip - The number of commits to skip.
      Returns:
      Array Git commit object GitCommits
      Throws:
      AzDException - Default Api Exception handler.
    • getCommitsBatch

      public GitCommitRefs getCommitsBatch(String repositoryId, GitCommitsBatch gitCommitsBatch) throws AzDException
      Retrieve git commits for a project matching the search criteria.
      Specified by:
      getCommitsBatch in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      gitCommitsBatch - request body GitCommitsBatch.
      Returns:
      GitCommitRefs object GitCommitRefs.
      Throws:
      AzDException - Default Api exception handler.
    • getRefs

      public GitRefs getRefs(String repositoryName) throws AzDException
      Queries the provided repository for its refs and returns them.
      Specified by:
      getRefs in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      Returns:
      Array Git ref object GitRefs
      Throws:
      AzDException - Default Api Exception handler.
    • getRefs

      public GitRefs getRefs(String repositoryName, String filter) throws AzDException
      Queries the provided repository for its refs and returns them.
      Specified by:
      getRefs in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      filter - A filter to apply to the refs (starts with).
      Returns:
      Array Git ref object GitRefs
      Throws:
      AzDException - Default Api Exception handler.
    • updateRef

      public GitRefUpdateResult updateRef(String repositoryName, String refName, String oldObjectId, String newObjectId) throws AzDException
      Creating, updating, or deleting git ref.
      Specified by:
      updateRef in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      refName - The ref to create, update, or delete.
      oldObjectId - The old object id of the ref.(SHA)
      newObjectId - The new object id of the ref.(SHA)
      Returns:
      Array Git update result object GitRefUpdateResults
      Throws:
      AzDException - Default Api Exception handler.
    • createTag

      public GitRefUpdateResult createTag(String repositoryName, String tagName, String ref) throws AzDException
      Creates a new tag in the repository that points to the supplied ref.
      Specified by:
      createTag in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      tagName - The name of the tag.
      ref - Create tag using commit SHA, another tag name, or branch name
      Returns:
      Git update result object GitRefUpdateResult
      Throws:
      AzDException - Default Api Exception handler.
    • deleteTag

      public GitRefUpdateResult deleteTag(String repositoryName, String tagName) throws AzDException
      Deletes a tag of a repository with given name.
      Specified by:
      deleteTag in interface GitDetails
      Parameters:
      repositoryName - Name of the repository.
      tagName - The name of the tag.
      Returns:
      Array Git update result object GitRefUpdateResults
      Throws:
      AzDException - Default Api Exception handler.
    • getBlob

      public GitBlobRef getBlob(String repositoryId, String sha1) throws AzDException
      Get a single blob.
      Specified by:
      getBlob in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint.
      Returns:
      GitBlobRef Object GitBlobRef
      Throws:
      AzDException - Default Api Exception handler.
    • getBlob

      public GitBlobRef getBlob(String repositoryId, String sha1, String fileName, boolean resolveLfs) throws AzDException
      Get a single blob.
      Specified by:
      getBlob in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint.
      fileName - Provide a fileName to use for a download.
      resolveLfs - If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types
      Returns:
      GitBlobRef Object GitBlobRef
      Throws:
      AzDException - Default Api Exception handler.
    • getBlobContent

      public String getBlobContent(String repositoryId, String sha1, boolean download, String fileName, boolean resolveLfs) throws AzDException
      Get a single blob content.
      Specified by:
      getBlobContent in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the getItems() method.
      download - If true, download the text. You can use StreamHelper to download the file.
      fileName - Provide a fileName to use for a download.
      resolveLfs - If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types
      Returns:
      String contents of the file.
      Throws:
      AzDException - Default Api Exception handler.
    • getBlobContentAsZip

      public InputStream getBlobContentAsZip(String repositoryId, String sha1, boolean download, String fileName, boolean resolveLfs) throws AzDException
      Get a single blob as zip of input stream. Use StreamHelper to download the file.
      Specified by:
      getBlobContentAsZip in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the getItems() method.
      download - If true, download the text. You can use StreamHelper to download the file.
      fileName - Provide a fileName to use for a download.
      resolveLfs - If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types
      Returns:
      Input stream for zip download. This gets the stream of a single file.
      Throws:
      AzDException - Default Api Exception handler.
    • getBlobContentAsStream

      public InputStream getBlobContentAsStream(String repositoryId, String sha1, boolean download, String fileName, boolean resolveLfs) throws AzDException
      Get a single blob content as input stream. Use StreamHelper to download the file.
      Specified by:
      getBlobContentAsStream in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      sha1 - SHA1 hash of the file. You can get the SHA1 of a file using the getItems() method.
      download - If true, download the text. You can use StreamHelper to download the file.
      fileName - Provide a fileName to use for a download.
      resolveLfs - If true, try to resolve a blob to its LFS contents, if it's an LFS pointer file. Only compatible with octet-stream Accept headers or $format types
      Returns:
      Input stream for zip download. This gets the stream of a single file.
      Throws:
      AzDException - Default Api Exception handler.
    • getBlobsZip

      public InputStream getBlobsZip(String repositoryId, List<String> sha1) throws AzDException
      Gets one or more blobs in a zip file download.
      Specified by:
      getBlobsZip in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      Throws:
      AzDException - Default Api Exception handler.
    • getBlobsZip

      public InputStream getBlobsZip(String repositoryId, String fileName, List<String> sha1) throws AzDException
      Gets one or more blobs in a zip file download.
      Specified by:
      getBlobsZip in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      fileName - Name of the file.
      Throws:
      AzDException - Default Api Exception handler.
    • getItems

      public GitItems getItems(String repositoryName) throws AzDException
      Get Item Metadata and/or Content for a collection of items.
      Specified by:
      getItems in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      Returns:
      GitItem Object GitItem
      Throws:
      AzDException - Default Api Exception handler.
    • getItems

      public GitItems getItems(String repositoryName, VersionControlRecursionType recursionType) throws AzDException
      Get Item Metadata and/or Content for a collection of items.
      Specified by:
      getItems in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      recursionType - The recursion level of this request. The default is 'none', no recursion.
      Returns:
      GitItem Object GitItem
      Throws:
      AzDException - Default Api Exception handler.
    • getItems

      public GitItems getItems(String repositoryName, boolean includeContentMetadata, boolean includeLinks, boolean latestProcessedChange, VersionControlRecursionType recursionType, String scopePath) throws AzDException
      Get Item Metadata and/or Content for a collection of items.
      Specified by:
      getItems in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      includeContentMetadata - Set to true to include content metadata. Default is false.
      includeLinks - Set to true to include links to items. Default is false.
      latestProcessedChange - Set to true to include the latest changes. Default is false.
      recursionType - The recursion level of this request. The default is 'none', no recursion.
      scopePath - The path scope. The default is null.
      Returns:
      GitItem Object GitItem
      Throws:
      AzDException - Default Api Exception handler.
    • getItems

      public GitItems getItems(String repositoryName, boolean includeContentMetadata, boolean includeLinks, boolean latestProcessedChange, VersionControlRecursionType recursionType, String scopePath, String version, GitVersionOptions versionOptions, GitVersionType versionType) throws AzDException
      Get Item Metadata and/or Content for a collection of items.
      Specified by:
      getItems in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      includeContentMetadata - Set to true to include content metadata. Default is false.
      includeLinks - Set to true to include links to items. Default is false.
      latestProcessedChange - Set to true to include the latest changes. Default is false.
      recursionType - The recursion level of this request. The default is 'none', no recursion.
      scopePath - The path scope. The default is null.
      version - Version string identifier (name of tag/branch, SHA1 of commit)
      versionOptions - Version options - Specify additional modifiers to version (e.g Previous)
      versionType - Version type (branch, tag, or commit). Determines how Id is interpreted
      Returns:
      GitItem Object GitItem
      Throws:
      AzDException - Default Api Exception handler.
    • createForkSyncRequest

      public GitForkSyncRequest createForkSyncRequest(String repositoryName, String sourceCollectionId, String sourceProjectId, String sourceRepositoryId, Boolean includeLinks) throws AzDException
      Request that another repository's refs be fetched into this one. It syncs two existing forks.
      Specified by:
      createForkSyncRequest in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      sourceCollectionId - Team Project Collection ID of the collection for the repository.
      sourceProjectId - Team Project ID of the project for the repository.
      sourceRepositoryId - ID of the repository.
      includeLinks - Set to true to include links to items. Default is false.
      Returns:
      GitForkSyncRequest Object GitForkSyncRequest
      Throws:
      AzDException - Default Api Exception handler.
    • createForkSyncRequest

      public GitForkSyncRequest createForkSyncRequest(String repositoryName, String collectionId, String projectId, String repositoryId, String sourceRef, String targetRef, Boolean includeLinks) throws AzDException
      Request that another repository's refs be fetched into this one. It syncs two existing forks.
      Specified by:
      createForkSyncRequest in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      collectionId - Team Project Collection ID of the collection for the repository.
      projectId - Team Project ID of the project for the repository.
      repositoryId - ID of the repository.
      sourceRef - The source ref to copy. For example, refs/heads/main.
      targetRef - The target ref to update. For example, refs/heads/main.
      includeLinks - Set to true to include links to items. Default is false.
      Returns:
      GitForkSyncRequest Object GitForkSyncRequest
      Throws:
      AzDException - Default Api Exception handler.
    • getForkSyncRequest

      public GitForkSyncRequest getForkSyncRequest(String repositoryName, int OperationId, boolean includeLinks) throws AzDException
      Get a specific fork sync operation's details.
      Specified by:
      getForkSyncRequest in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      OperationId - OperationId of the sync request.
      includeLinks - Set to true to include links to items. Default is false.
      Returns:
      GitForkSyncRequest Object GitForkSyncRequest
      Throws:
      AzDException - Default Api Exception handler.
    • getForkSyncRequests

      public GitForkSyncRequests getForkSyncRequests(String repositoryName, boolean includeLinks, boolean includeAbandoned) throws AzDException
      Retrieve all requested fork sync operations on this repository.
      Specified by:
      getForkSyncRequests in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      includeLinks - Set to true to include links to items. Default is false.
      includeAbandoned - Set to true to include abandoned requests. Default is false.
      Returns:
      GitForkSyncRequests Object GitForkSyncRequests
      Throws:
      AzDException - Default Api Exception handler.
    • getForks

      public GitRepositoryRefs getForks(String repositoryName, String collectionId, boolean includeLinks) throws AzDException
      Retrieve all forks of a repository in the collection.
      Specified by:
      getForks in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      collectionId - Team project collection ID.
      includeLinks - Set to true to include links to items. Default is false.
      Returns:
      GitRepositoryRefs Object GitRepositoryRefs
      Throws:
      AzDException - Default Api Exception handler.
    • createPush

      public GitPush createPush(String repositoryId, GitPush gitPush) throws AzDException
      Push changes to the repository.
      Specified by:
      createPush in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      Returns:
      GitPush Object GitPush
      Throws:
      AzDException - Default Api Exception handler.
    • getPush

      public GitPush getPush(String repositoryId, int pushId) throws AzDException
      Retrieves a particular push.
      Specified by:
      getPush in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      pushId - ID of the push.
      Returns:
      GitPush Object GitPush
      Throws:
      AzDException - Default Api Exception handler.
    • getPush

      public GitPush getPush(String repositoryId, int pushId, int includeCommits) throws AzDException
      Retrieves a particular push.
      Specified by:
      getPush in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      pushId - ID of the push.
      includeCommits - The number of commits to include in the result.
      Returns:
      GitPush Object GitPush
      Throws:
      AzDException - Default Api Exception handler.
    • getPush

      public GitPush getPush(String repositoryId, int pushId, boolean includeRefUpdates) throws AzDException
      Retrieves a particular push.
      Specified by:
      getPush in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      pushId - ID of the push.
      includeRefUpdates - If true, include the list of refs that were updated by the push.
      Returns:
      GitPush Object GitPush
      Throws:
      AzDException - Default Api Exception handler.
    • getPush

      public GitPush getPush(String repositoryId, int pushId, int includeCommits, boolean includeRefUpdates) throws AzDException
      Retrieves a particular push.
      Specified by:
      getPush in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      pushId - ID of the push.
      includeCommits - The number of commits to include in the result.
      includeRefUpdates - If true, include the list of refs that were updated by the push.
      Returns:
      GitPush Object GitPush
      Throws:
      AzDException - Default Api Exception handler.
    • getPushes

      public GitPushes getPushes(String repositoryId) throws AzDException
      Retrieves pushes associated with the specified repository.
      Specified by:
      getPushes in interface GitDetails
      Parameters:
      repositoryId - The name or ID of the repository.
      Returns:
      GitPush Object GitPush
      Throws:
      AzDException - Default Api Exception handler.
    • createPullRequestStatus

      public GitStatus createPullRequestStatus(int pullRequestId, String repositoryId, GitStatus gitPullRequestStatus) throws AzDException
      Create a pull request status. The only required field for the status is Context.Name that uniquely identifies the status. Note that you can specify iterationId in the request body to post the status on the iteration.
      Specified by:
      createPullRequestStatus in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryId - The repository ID of the pull request’s target branch.
      gitPullRequestStatus - Request body to create a new pull request status.
      Returns:
      GitStatus Object GitStatus
      Throws:
      AzDException - Default Api Exception handler.
    • deletePullRequestStatus

      public Void deletePullRequestStatus(int pullRequestId, String repositoryId, int statusId) throws AzDException
      Delete pull request status. You can remove multiple statuses in one call by using Update operation.
      Specified by:
      deletePullRequestStatus in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryId - The repository ID of the pull request’s target branch.
      statusId - ID of the pull request status.
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestStatus

      public GitStatus getPullRequestStatus(int pullRequestId, String repositoryId, int statusId) throws AzDException
      Get the specific pull request status by ID. The status ID is unique within the pull request across all iterations.
      Specified by:
      getPullRequestStatus in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryId - The repository ID of the pull request’s target branch.
      statusId - ID of the pull request status.
      Returns:
      GitStatus Object GitStatus
      Throws:
      AzDException - Default Api Exception handler.
    • getPullRequestStatuses

      public GitStatuses getPullRequestStatuses(int pullRequestId, String repositoryId) throws AzDException
      Get all the statuses associated with a pull request.
      Specified by:
      getPullRequestStatuses in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryId - The repository ID of the pull request’s target branch.
      Returns:
      GitStatuses Object GitStatuses
      Throws:
      AzDException - Default Api Exception handler.
    • updatePullRequestStatuses

      public Void updatePullRequestStatuses(int pullRequestId, String repositoryId, List<JsonPatchDocument> propertiesToUpdate) throws AzDException
      Update pull request statuses collection. The only supported operation type is remove. This operation allows to delete multiple statuses in one call. The path of the remove operation should refer to the ID of the pull request status. For example path="/1" refers to the pull request status with ID 1.
      Specified by:
      updatePullRequestStatuses in interface GitDetails
      Parameters:
      pullRequestId - ID of the pull request.
      repositoryId - The repository ID of the pull request’s target branch.
      propertiesToUpdate - Collection of properties to update. E.g., [ { "op": "remove", "path": "/1", "from": null, "value": null }, { "op": "remove", "path": "/2", "from": null, "value": null } ]
      Throws:
      AzDException - Default Api Exception handler.
    • createForkRepository

      public GitRepository createForkRepository(String repositoryName, String projectId, String parentProjectId, String parentRepositoryId) throws AzDException
      Create a fork of a parent repository
      Specified by:
      createForkRepository in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      projectId - The project id of the target repository
      parentProjectId - Project id of the parent repository from which the fork operation has to initiate.
      parentRepositoryId - Id of the parent repository
      Returns:
      GitRepository Object GitRepository
      Throws:
      AzDException - Default Api Exception handler.
    • createForkRepository

      public GitRepository createForkRepository(String repositoryName, String projectId, String parentProjectId, String parentRepositoryId, String sourceBranch) throws AzDException
      Create a fork of a parent repository syncing only the provided refs
      Specified by:
      createForkRepository in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      projectId - The project id of the target repository
      parentProjectId - Project id of the parent repository from which the fork operation has to initiate.
      parentRepositoryId - Id of the parent repository
      sourceBranch - Provide the name of branch to create a fork request.
      Returns:
      GitRepository Object GitRepository
      Throws:
      AzDException - Default Api Exception handler.
    • createForkRepositoryWithComplete

      public GitRepository createForkRepositoryWithComplete(String repositoryName, String projectId, String parentProjectId, String parentRepositoryId, String sourceBranch, int checkTimes) throws AzDException
      Create a fork of a parent repository syncing only the provided refs with wait for operation completion
      Specified by:
      createForkRepositoryWithComplete in interface GitDetails
      Parameters:
      repositoryName - The name or ID of the repository.
      projectId - The project id of the target repository
      parentProjectId - Project id of the parent repository from which the fork operation has to initiate.
      parentRepositoryId - Id of the parent repository
      sourceBranch - Provide the name of branch to create a fork request.
      checkTimes - Polling interval to wait for operation to complete.
      Returns:
      GitRepository Object GitRepository
      Throws:
      AzDException - Default Api Exception handler.