diff --git a/Dockerfile b/Dockerfile index 4f35e67772..656dc23ddd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,11 +11,15 @@ RUN GOOS=linux make FROM alpine:3.9 RUN apk add --no-cache ca-certificates -RUN echo pwd +RUN apk update +RUN apk add git COPY --from=build-env /go/src/github.com/devtron-labs/devtron/devtron . COPY --from=build-env /go/src/github.com/devtron-labs/devtron/auth_model.conf . COPY --from=build-env /go/src/github.com/devtron-labs/devtron/vendor/github.com/argoproj/argo-cd/assets/ /go/src/github.com/devtron-labs/devtron/vendor/github.com/argoproj/argo-cd/assets COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.JSON scripts/argo-assets/APPLICATION_TEMPLATE.JSON +COPY ./git-ask-pass.sh /git-ask-pass.sh +RUN chmod +x /git-ask-pass.sh + CMD ["./devtron"] diff --git a/Gopkg.lock b/Gopkg.lock index cfe3d5ab4a..ad390ae3ca 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -880,6 +880,24 @@ revision = "c12348ce28de40eed0136aa2b644d0ee0650e56c" version = "v1.0.1" +[[projects]] + branch = "dev" + digest = "1:dbbf8497a7448220ab79bcee0f263b29c1f9e6b56149f252e945d30d7227b649" + name = "github.com/microsoft/azure-devops-go-api" + packages = [ + "azuredevops", + "azuredevops/core", + "azuredevops/delegatedauthorization", + "azuredevops/git", + "azuredevops/identity", + "azuredevops/operations", + "azuredevops/policy", + "azuredevops/system", + "azuredevops/webapi", + ] + pruneopts = "UT" + revision = "09c8cad426a653fc76cdbfb915d3d11114b4d8e8" + [[projects]] digest = "1:5d231480e1c64a726869bc4142d270184c419749d34f167646baa21008eb0a79" name = "github.com/mitchellh/go-homedir" @@ -1966,6 +1984,9 @@ "github.com/grpc-ecosystem/grpc-gateway/runtime", "github.com/juju/errors", "github.com/lib/pq", + "github.com/microsoft/azure-devops-go-api/azuredevops", + "github.com/microsoft/azure-devops-go-api/azuredevops/core", + "github.com/microsoft/azure-devops-go-api/azuredevops/git", "github.com/nats-io/nats.go", "github.com/nats-io/stan", "github.com/otiai10/copy", @@ -2003,6 +2024,7 @@ "k8s.io/apimachinery/pkg/runtime/schema", "k8s.io/apimachinery/pkg/runtime/serializer", "k8s.io/apimachinery/pkg/types", + "k8s.io/client-go/discovery", "k8s.io/client-go/kubernetes", "k8s.io/client-go/kubernetes/scheme", "k8s.io/client-go/kubernetes/typed/core/v1", diff --git a/Gopkg.toml b/Gopkg.toml index dd0e399a03..663b6e23cf 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -187,3 +187,7 @@ required = [ [[constraint]] name = "github.com/igm/sockjs-go" version = "3.0.0" + +[[constraint]] + branch = "dev" + name = "github.com/microsoft/azure-devops-go-api" diff --git a/Wire.go b/Wire.go index fc262ea73a..c8de0e7970 100644 --- a/Wire.go +++ b/Wire.go @@ -646,6 +646,7 @@ func InitializeApp() (*App, error) { wire.Bind(new(router.CommonRouter), new(*router.CommonRouterImpl)), restHandler.NewCommonRestHanlderImpl, wire.Bind(new(restHandler.CommonRestHanlder), new(*restHandler.CommonRestHanlderImpl)), + util.NewGitCliUtil, ) return &App{}, nil } diff --git a/git-ask-pass.sh b/git-ask-pass.sh new file mode 100755 index 0000000000..4e34efe216 --- /dev/null +++ b/git-ask-pass.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# This script is used as the command supplied to GIT_ASKPASS as a way to supply username/password +# credentials to git, without having to use git credentials helpers, or having on-disk config. +case "$1" in +Username*) echo "${GIT_USERNAME}" ;; +Password*) echo "${GIT_PASSWORD}" ;; +esac diff --git a/internal/sql/repository/GitOpsConfigRepository.go b/internal/sql/repository/GitOpsConfigRepository.go index 02424ce597..8a51f2e720 100644 --- a/internal/sql/repository/GitOpsConfigRepository.go +++ b/internal/sql/repository/GitOpsConfigRepository.go @@ -46,6 +46,7 @@ type GitOpsConfig struct { Token string `sql:"token"` GitLabGroupId string `sql:"gitlab_group_id"` GitHubOrgId string `sql:"github_org_id"` + AzureProject string `sql:"azure_project"` Host string `sql:"host"` Active bool `sql:"active,notnull"` models.AuditLog diff --git a/internal/util/GitCliUtil.go b/internal/util/GitCliUtil.go new file mode 100644 index 0000000000..df33509de0 --- /dev/null +++ b/internal/util/GitCliUtil.go @@ -0,0 +1,105 @@ +package util + +import ( + "fmt" + "go.uber.org/zap" + "gopkg.in/src-d/go-git.v4" + "gopkg.in/src-d/go-git.v4/config" + "os" + "os/exec" + "strings" +) + +type GitCliUtil struct { + logger *zap.SugaredLogger +} + +func NewGitCliUtil(logger *zap.SugaredLogger) *GitCliUtil { + return &GitCliUtil{ + logger: logger, + } +} + +const GIT_ASK_PASS = "/git-ask-pass.sh" + +func (impl *GitCliUtil) Fetch(rootDir string, username string, password string) (response, errMsg string, err error) { + impl.logger.Debugw("git fetch ", "location", rootDir) + cmd := exec.Command("git", "-C", rootDir, "fetch", "origin", "--tags", "--force") + output, errMsg, err := impl.runCommandWithCred(cmd, username, password) + impl.logger.Debugw("fetch output", "root", rootDir, "opt", output, "errMsg", errMsg, "error", err) + return output, errMsg, err +} + +func (impl *GitCliUtil) Pull(rootDir string, username string, password string, branch string) (response, errMsg string, err error) { + impl.logger.Debugw("git pull ", "location", rootDir) + cmd := exec.Command("git", "-C", rootDir, "pull", "origin", branch, "--force") + output, errMsg, err := impl.runCommandWithCred(cmd, username, password) + impl.logger.Debugw("pull output", "root", rootDir, "opt", output, "errMsg", errMsg, "error", err) + return output, errMsg, err +} +func (impl *GitCliUtil) Checkout(rootDir string, branch string) (response, errMsg string, err error) { + impl.logger.Debugw("git checkout ", "location", rootDir) + cmd := exec.Command("git", "-C", rootDir, "checkout", branch, "--force") + output, errMsg, err := impl.runCommand(cmd) + impl.logger.Debugw("checkout output", "root", rootDir, "opt", output, "errMsg", errMsg, "error", err) + return output, errMsg, err +} + +func (impl *GitCliUtil) runCommandWithCred(cmd *exec.Cmd, userName, password string) (response, errMsg string, err error) { + cmd.Env = append(os.Environ(), + fmt.Sprintf("GIT_ASKPASS=%s", GIT_ASK_PASS), + fmt.Sprintf("GIT_USERNAME=%s", userName), + fmt.Sprintf("GIT_PASSWORD=%s", password), + ) + return impl.runCommand(cmd) +} + +func (impl *GitCliUtil) runCommand(cmd *exec.Cmd) (response, errMsg string, err error) { + cmd.Env = append(cmd.Env, "HOME=/dev/null") + outBytes, err := cmd.CombinedOutput() + if err != nil { + exErr, ok := err.(*exec.ExitError) + if !ok { + return "", "", err + } + errOutput := string(exErr.Stderr) + return "", errOutput, err + } + output := string(outBytes) + output = strings.TrimSpace(output) + return output, "", nil +} + +func (impl *GitCliUtil) Init(rootDir string, remoteUrl string, isBare bool) error { + //----------------- + err := os.RemoveAll(rootDir) + if err != nil { + impl.logger.Errorw("error in cleaning rootDir", "err", err) + return err + } + err = os.MkdirAll(rootDir, 0755) + if err != nil { + return err + } + repo, err := git.PlainInit(rootDir, isBare) + if err != nil { + return err + } + _, err = repo.CreateRemote(&config.RemoteConfig{ + Name: git.DefaultRemoteName, + URLs: []string{remoteUrl}, + }) + return err +} + +func (impl *GitCliUtil) Clone(rootDir string, remoteUrl string, username string, password string) (response, errMsg string, err error) { + err = impl.Init(rootDir, remoteUrl, false) + if err != nil { + return "", "", err + } + response, errMsg, err = impl.Fetch(rootDir, username, password) + if err == nil && errMsg == "" { + response, errMsg, err = impl.Pull(rootDir, username, password, "master") + } + return response, errMsg, err +} diff --git a/internal/util/GitService.go b/internal/util/GitService.go index 8c2271b41a..797bd36015 100644 --- a/internal/util/GitService.go +++ b/internal/util/GitService.go @@ -28,7 +28,6 @@ import ( "golang.org/x/oauth2" "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/plumbing/object" - "gopkg.in/src-d/go-git.v4/plumbing/transport" "gopkg.in/src-d/go-git.v4/plumbing/transport/http" "io/ioutil" "net/url" @@ -49,6 +48,7 @@ type GitFactory struct { GitWorkingDir string logger *zap.SugaredLogger gitOpsRepository repository.GitOpsConfigRepository + gitCliUtil *GitCliUtil } func (factory *GitFactory) Reload() error { @@ -57,7 +57,7 @@ func (factory *GitFactory) Reload() error { if err != nil { return err } - gitService := NewGitServiceImpl(cfg, logger) + gitService := NewGitServiceImpl(cfg, logger, factory.gitCliUtil) factory.gitService = gitService client, err := NewGitLabClient(cfg, logger, gitService) if err != nil { @@ -68,12 +68,12 @@ func (factory *GitFactory) Reload() error { return nil } -func NewGitFactory(logger *zap.SugaredLogger, gitOpsRepository repository.GitOpsConfigRepository) (*GitFactory, error) { +func NewGitFactory(logger *zap.SugaredLogger, gitOpsRepository repository.GitOpsConfigRepository, gitCliUtil *GitCliUtil) (*GitFactory, error) { cfg, err := GetGitConfig(gitOpsRepository) if err != nil { return nil, err } - gitService := NewGitServiceImpl(cfg, logger) + gitService := NewGitServiceImpl(cfg, logger, gitCliUtil) client, err := NewGitLabClient(cfg, logger, gitService) if err != nil { return nil, err @@ -84,18 +84,21 @@ func NewGitFactory(logger *zap.SugaredLogger, gitOpsRepository repository.GitOps gitService: gitService, gitOpsRepository: gitOpsRepository, GitWorkingDir: cfg.GitWorkingDir, + gitCliUtil: gitCliUtil, }, nil } type GitConfig struct { - GitlabGroupId string //local - GitlabGroupPath string //local - GitToken string `env:"GIT_TOKEN" ` //not null // public - GitUserName string `env:"GIT_USERNAME" ` //not null // public - GitWorkingDir string `env:"GIT_WORKING_DIRECTORY" envDefault:"/tmp/gitops/"` //working directory for git. might use pvc + GitlabGroupId string //local + GitlabGroupPath string //local + GitToken string //not null // public + GitUserName string //not null // public + GitWorkingDir string //working directory for git. might use pvc GithubOrganization string - GitProvider string `env:"GIT_PROVIDER" envDefault:"GITHUB"` // SUPPORTED VALUES GITHUB, GITLAB - GitHost string `env:"GIT_HOST" envDefault:""` + GitProvider string // SUPPORTED VALUES GITHUB, GITLAB + GitHost string + AzureToken string + AzureProject string } func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfig, error) { @@ -121,6 +124,8 @@ func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfi GithubOrganization: gitOpsConfig.GitHubOrgId, GitProvider: gitOpsConfig.Provider, GitHost: gitOpsConfig.Host, + AzureToken: gitOpsConfig.Token, + AzureProject: gitOpsConfig.AzureProject, } return cfg, err } @@ -190,9 +195,15 @@ func NewGitLabClient(config *GitConfig, logger *zap.SugaredLogger, gitService Gi logger: logger, gitService: gitService, }, nil - } else { + } else if config.GitProvider == "GITHUB" { gitHubClient := NewGithubClient(config.GitToken, config.GithubOrganization, logger, gitService) return gitHubClient, nil + } else if config.GitProvider == "AZURE_DEVOPS" { + gitAzureClient := NewGitAzureClient(config.AzureToken, config.GitHost, config.AzureProject, logger, gitService) + return gitAzureClient, nil + } else { + logger.Errorw("no gitops config provided, gitops will not work ") + return nil, nil } } @@ -373,17 +384,19 @@ type GitService interface { Pull(repoRoot string) (err error) } type GitServiceImpl struct { - Auth transport.AuthMethod - config *GitConfig - logger *zap.SugaredLogger + Auth *http.BasicAuth + config *GitConfig + logger *zap.SugaredLogger + gitCliUtil *GitCliUtil } -func NewGitServiceImpl(config *GitConfig, logger *zap.SugaredLogger) *GitServiceImpl { +func NewGitServiceImpl(config *GitConfig, logger *zap.SugaredLogger, GitCliUtil *GitCliUtil) *GitServiceImpl { auth := &http.BasicAuth{Password: config.GitToken, Username: config.GitUserName} return &GitServiceImpl{ - Auth: auth, - logger: logger, - config: config, + Auth: auth, + logger: logger, + config: config, + gitCliUtil: GitCliUtil, } } @@ -395,14 +408,14 @@ func (impl GitServiceImpl) GetCloneDirectory(targetDir string) (clonedDir string func (impl GitServiceImpl) Clone(url, targetDir string) (clonedDir string, err error) { impl.logger.Debugw("git checkout ", "url", url, "dir", targetDir) clonedDir = filepath.Join(impl.config.GitWorkingDir, targetDir) - _, err = git.PlainClone(clonedDir, false, &git.CloneOptions{ - URL: url, - Auth: impl.Auth, - }) + _, errorMsg, err := impl.gitCliUtil.Clone(clonedDir, url, impl.Auth.Username, impl.Auth.Password) if err != nil { - impl.logger.Errorw("error in git checkout ", "url", url, "targetDir", targetDir, "err", err) + impl.logger.Errorw("error in git checkout", "url", url, "targetDir", targetDir, "err", err) return "", err } + if errorMsg != "" { + return "", fmt.Errorf(errorMsg) + } return clonedDir, nil } diff --git a/internal/util/GitServiceAzure.go b/internal/util/GitServiceAzure.go new file mode 100644 index 0000000000..85c2cae935 --- /dev/null +++ b/internal/util/GitServiceAzure.go @@ -0,0 +1,239 @@ +package util + +import ( + "context" + "fmt" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/git" + "go.uber.org/zap" + "path/filepath" + "time" +) + +type GitAzureClient struct { + client git.Client + logger *zap.SugaredLogger + project string + gitService GitService +} + +func (impl GitAzureClient) GetRepoUrl(repoName string) (repoUrl string, err error) { + url, exists, err := impl.repoExists(repoName, impl.project) + if err != nil { + return "", err + } else if !exists { + return "", fmt.Errorf("%s :repo not found", repoName) + } else { + return url, nil + } +} + +func NewGitAzureClient(token string, host string, project string, logger *zap.SugaredLogger, gitService GitService) GitAzureClient { + ctx := context.Background() + // Create a connection to your organization + connection := azuredevops.NewPatConnection(host, token) + // Create a client to interact with the Core area + coreClient, err := git.NewClient(ctx, connection) + if err != nil { + logger.Errorw("error in creating azure gitops client, gitops related operation might fail", "err", err) + } + return GitAzureClient{client: coreClient, project: project, logger: logger, gitService: gitService} +} + +func (impl GitAzureClient) CreateRepository(name, description string) (url string, isNew bool, err error) { + ctx := context.Background() + url, repoExists, err := impl.repoExists(name, impl.project) + if err != nil { + impl.logger.Errorw("error in communication with azure", "err", err) + return "", false, err + } + if repoExists { + return url, false, nil + } + gitRepositoryCreateOptions := git.GitRepositoryCreateOptions{ + Name: &name, + } + operationReference, err := impl.client.CreateRepository(ctx, git.CreateRepositoryArgs{ + GitRepositoryToCreate: &gitRepositoryCreateOptions, + Project: &impl.project, + }) + if err != nil { + impl.logger.Errorw("error in creating repo, ", "repo", name, "err", err) + return "", true, err + } + logger.Infow("repo created ", "r", operationReference.Url) + + validated, err := impl.ensureProjectAvailabilityOnHttp(name) + if err != nil { + impl.logger.Errorw("error in ensuring project availability ", "project", name, "err", err) + return *operationReference.Url, true, err + } + if !validated { + return "", true, fmt.Errorf("unable to validate project:%s in given time", name) + } + _, err = impl.createReadme(name) + if err != nil { + impl.logger.Errorw("error in creating readme", "err", err) + return *operationReference.Url, true, err + } + validated, err = impl.ensureProjectAvailabilityOnSsh(impl.project, name, *operationReference.Url) + if err != nil { + impl.logger.Errorw("error in ensuring project availability ", "project", name, "err", err) + return *operationReference.Url, true, err + } + if !validated { + return "", true, fmt.Errorf("unable to validate project:%s in given time", name) + } + return *operationReference.WebUrl, true, err +} + +func (impl GitAzureClient) createReadme(repoName string) (string, error) { + cfg := &ChartConfig{ + ChartName: repoName, + ChartLocation: "", + FileName: "README.md", + FileContent: "@devtron", + ReleaseMessage: "readme", + } + hash, err := impl.CommitValues(cfg) + if err != nil { + impl.logger.Errorw("error in creating readme", "repo", repoName, "err", err) + } + return hash, err +} + +func (impl GitAzureClient) CommitValues(config *ChartConfig) (commitHash string, err error) { + branch := "master" + branchfull := "refs/heads/master" + path := filepath.Join(config.ChartLocation, config.FileName) + ctx := context.Background() + newFile := true + oldObjId := "0000000000000000000000000000000000000000" //default commit hash + // check if file exists and current hash + // if file does not exists get hash from branch + // if branch doesn't exists use default hash + fc, err := impl.client.GetItem(ctx, git.GetItemArgs{ + RepositoryId: &config.ChartName, + Path: &path, + Project: &impl.project, + }) + if err != nil { + notFoundStatus := 404 + if e, ok := err.(azuredevops.WrappedError); ok && *e.StatusCode == notFoundStatus { + branchStat, err := impl.client.GetBranch(ctx, git.GetBranchArgs{Project: &impl.project, Name: &branch, RepositoryId: &config.ChartName}) + if err != nil { + if e, ok := err.(azuredevops.WrappedError); !ok || *e.StatusCode >= 500 { + impl.logger.Errorw("error in fetching branch from azure devops", "err", err) + return "", err + } + } else if branchStat != nil { + oldObjId = *branchStat.Commit.CommitId + } + } else { + impl.logger.Errorw("error in fetching file from azure devops", "err", err) + return "", err + } + } else { + oldObjId = *fc.CommitId + newFile = false + } + + var refUpdates []git.GitRefUpdate + refUpdates = append(refUpdates, git.GitRefUpdate{ + Name: &branchfull, + OldObjectId: &oldObjId, + }) + var changeType git.VersionControlChangeType + if newFile { + changeType = git.VersionControlChangeTypeValues.Add + } else { + changeType = git.VersionControlChangeTypeValues.Edit + } + gitChange := git.GitChange{ChangeType: &changeType, + Item: &git.GitItemDescriptor{Path: &path}, + NewContent: &git.ItemContent{ + Content: &config.FileContent, + ContentType: &git.ItemContentTypeValues.RawText, + }} + var contents []interface{} + contents = append(contents, gitChange) + + var commits []git.GitCommitRef + commits = append(commits, git.GitCommitRef{ + Changes: &contents, + Comment: &config.ReleaseMessage, + }) + + push, err := impl.client.CreatePush(ctx, git.CreatePushArgs{ + Push: &git.GitPush{ + Commits: &commits, + RefUpdates: &refUpdates, + }, + RepositoryId: &config.ChartName, + Project: &impl.project, + }) + + if err != nil { + impl.logger.Errorw("error in commit", "err", err) + return "", err + } + //gitPush.Commits + commitId := "" + if len(*push.Commits) > 0 { + commitId = *(*push.Commits)[0].CommitId + } + // push.Commits[0].CommitId + return commitId, nil +} + +func (impl GitAzureClient) repoExists(repoName, projectName string) (repoUrl string, exists bool, err error) { + ctx := context.Background() + // Get first page of the list of team projects for your organization + gitRepository, err := impl.client.GetRepository(ctx, git.GetRepositoryArgs{ + RepositoryId: &repoName, + Project: &projectName, + }) + notFoundStatus := 404 + if err != nil { + if e, ok := err.(azuredevops.WrappedError); ok && *e.StatusCode == notFoundStatus { + return "", false, nil + } else { + return "", false, err + } + + } + for gitRepository == nil { + return "", false, nil + } + return *gitRepository.WebUrl, true, nil +} + +func (impl GitAzureClient) ensureProjectAvailabilityOnHttp(repoName string) (bool, error) { + for count := 0; count < 5; count++ { + _, exists, err := impl.repoExists(repoName, impl.project) + if err == nil && exists { + impl.logger.Infow("repo validated successfully on https") + return true, nil + } else if err != nil { + impl.logger.Errorw("error in validating repo", "err", err) + return false, err + } else { + impl.logger.Errorw("repo not available on http", "repo") + } + time.Sleep(10 * time.Second) + } + return false, nil +} + +func (impl GitAzureClient) ensureProjectAvailabilityOnSsh(projectName string, repoName string, repoUrl string) (bool, error) { + for count := 0; count < 8; count++ { + _, err := impl.gitService.Clone(repoUrl, fmt.Sprintf("/ensure-clone/%s", projectName)) + if err == nil { + impl.logger.Infow("ensureProjectAvailability clone passed", "try count", count, "repoUrl", repoUrl) + return true, nil + } + impl.logger.Errorw("ensureProjectAvailability clone failed ssh ", "try count", count, "err", err) + time.Sleep(10 * time.Second) + } + return false, nil +} diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index 5bea97e5c7..5d7757af56 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -46,15 +46,16 @@ type GitOpsConfigService interface { } type GitOpsConfigDto struct { - Id int `json:"id,omitempty"` - Provider string `json:"provider"` - Username string `json:"username"` - Token string `json:"token"` - GitLabGroupId string `json:"gitLabGroupId"` - GitHubOrgId string `json:"gitHubOrgId"` - Host string `json:"host"` - Active bool `json:"active"` - UserId int32 `json:"-"` + Id int `json:"id,omitempty"` + Provider string `json:"provider"` + Username string `json:"username"` + Token string `json:"token"` + GitLabGroupId string `json:"gitLabGroupId"` + GitHubOrgId string `json:"gitHubOrgId"` + Host string `json:"host"` + Active bool `json:"active"` + AzureProjectName string `json:"azureProjectName"` + UserId int32 `json:"-"` } const GitOpsSecretName = "devtron-gitops-secret" @@ -118,6 +119,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(request *GitOpsConfigDto GitLabGroupId: request.GitLabGroupId, Host: request.Host, Active: true, + AzureProject: request.AzureProjectName, AuditLog: models.AuditLog{CreatedBy: request.UserId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: request.UserId}, } model, err = impl.gitOpsRepository.CreateGitOpsConfig(model, tx) @@ -270,6 +272,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *GitOpsConfigDto model.GitHubOrgId = request.GitHubOrgId model.Host = request.Host model.Active = request.Active + model.AzureProject = request.AzureProjectName err = impl.gitOpsRepository.UpdateGitOpsConfig(model, tx) if err != nil { impl.logger.Errorw("error in updating team", "data", model, "err", err) @@ -379,15 +382,16 @@ func (impl *GitOpsConfigServiceImpl) GetGitOpsConfigById(id int) (*GitOpsConfigD return nil, err } config := &GitOpsConfigDto{ - Id: model.Id, - Provider: model.Provider, - GitHubOrgId: model.GitHubOrgId, - GitLabGroupId: model.GitLabGroupId, - Username: model.Username, - Token: model.Token, - Host: model.Host, - Active: model.Active, - UserId: model.CreatedBy, + Id: model.Id, + Provider: model.Provider, + GitHubOrgId: model.GitHubOrgId, + GitLabGroupId: model.GitLabGroupId, + Username: model.Username, + Token: model.Token, + Host: model.Host, + Active: model.Active, + UserId: model.CreatedBy, + AzureProjectName: model.AzureProject, } return config, err @@ -402,15 +406,16 @@ func (impl *GitOpsConfigServiceImpl) GetAllGitOpsConfig() ([]*GitOpsConfigDto, e configs := make([]*GitOpsConfigDto, 0) for _, model := range models { config := &GitOpsConfigDto{ - Id: model.Id, - Provider: model.Provider, - GitHubOrgId: model.GitHubOrgId, - GitLabGroupId: model.GitLabGroupId, - Username: model.Username, - Token: model.Token, - Host: model.Host, - Active: model.Active, - UserId: model.CreatedBy, + Id: model.Id, + Provider: model.Provider, + GitHubOrgId: model.GitHubOrgId, + GitLabGroupId: model.GitLabGroupId, + Username: model.Username, + Token: model.Token, + Host: model.Host, + Active: model.Active, + UserId: model.CreatedBy, + AzureProjectName: model.AzureProject, } configs = append(configs, config) } @@ -424,15 +429,16 @@ func (impl *GitOpsConfigServiceImpl) GetGitOpsConfigByProvider(provider string) return nil, err } config := &GitOpsConfigDto{ - Id: model.Id, - Provider: model.Provider, - GitHubOrgId: model.GitHubOrgId, - GitLabGroupId: model.GitLabGroupId, - Username: model.Username, - Token: model.Token, - Host: model.Host, - Active: model.Active, - UserId: model.CreatedBy, + Id: model.Id, + Provider: model.Provider, + GitHubOrgId: model.GitHubOrgId, + GitLabGroupId: model.GitLabGroupId, + Username: model.Username, + Token: model.Token, + Host: model.Host, + Active: model.Active, + UserId: model.CreatedBy, + AzureProjectName: model.AzureProject, } return config, err @@ -504,12 +510,13 @@ func (impl *GitOpsConfigServiceImpl) GetGitOpsConfigActive() (*GitOpsConfigDto, return nil, err } config := &GitOpsConfigDto{ - Id: model.Id, - Provider: model.Provider, - GitHubOrgId: model.GitHubOrgId, - GitLabGroupId: model.GitLabGroupId, - Active: model.Active, - UserId: model.CreatedBy, + Id: model.Id, + Provider: model.Provider, + GitHubOrgId: model.GitHubOrgId, + GitLabGroupId: model.GitLabGroupId, + Active: model.Active, + UserId: model.CreatedBy, + AzureProjectName: model.AzureProject, } return config, err } diff --git a/scripts/sql/14_alter_gitops_conf.down.sql b/scripts/sql/14_alter_gitops_conf.down.sql new file mode 100644 index 0000000000..f44e245063 --- /dev/null +++ b/scripts/sql/14_alter_gitops_conf.down.sql @@ -0,0 +1 @@ +ALTER TABLE gitops_config DROP COLUMN column_name; \ No newline at end of file diff --git a/scripts/sql/14_alter_gitops_conf.up.sql b/scripts/sql/14_alter_gitops_conf.up.sql new file mode 100644 index 0000000000..c44bca85f0 --- /dev/null +++ b/scripts/sql/14_alter_gitops_conf.up.sql @@ -0,0 +1 @@ +ALTER TABLE gitops_config ADD COLUMN azure_project character varying(250); \ No newline at end of file diff --git a/vendor/github.com/microsoft/azure-devops-go-api/LICENSE b/vendor/github.com/microsoft/azure-devops-go-api/LICENSE new file mode 100644 index 0000000000..4b1ad51b2f --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/client.go new file mode 100644 index 0000000000..923807af9e --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/client.go @@ -0,0 +1,441 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azuredevops + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "io" + "io/ioutil" + "net/http" + "net/url" + "reflect" + "regexp" + "runtime" + "strings" + "sync" + + "github.com/google/uuid" +) + +const ( + // header keys + headerKeyAccept = "Accept" + headerKeyAuthorization = "Authorization" + headerKeyContentType = "Content-Type" + HeaderKeyContinuationToken = "X-MS-ContinuationToken" + headerKeyFedAuthRedirect = "X-TFS-FedAuthRedirect" + headerKeyForceMsaPassThrough = "X-VSS-ForceMsaPassThrough" + headerKeySession = "X-TFS-Session" + headerUserAgent = "User-Agent" + + // media types + MediaTypeTextPlain = "text/plain" + MediaTypeApplicationJson = "application/json" +) + +// Unique session id to be used by all requests of this session. +var SessionId = uuid.New().String() + +// ApiResourceLocation Cache by Url +var apiResourceLocationCache = make(map[string]*map[uuid.UUID]ApiResourceLocation) +var apiResourceLocationCacheLock = sync.RWMutex{} + +var version = "1.1.0-b3" // todo: remove hardcoded version +var versionSuffix = " (dev)" + +// Base user agent string. The UserAgent set on the connection will be appended to this. +var baseUserAgent = "go/" + runtime.Version() + " (" + runtime.GOOS + " " + runtime.GOARCH + ") azure-devops-go-api/" + version + versionSuffix + +func NewClient(connection *Connection, baseUrl string) *Client { + var client *http.Client + + if connection.TlsConfig != nil { + client = &http.Client{Transport: &http.Transport{TLSClientConfig: connection.TlsConfig}} + } else { + client = &http.Client{} + } + + if connection.Timeout != nil { + client.Timeout = *connection.Timeout + } + return &Client{ + baseUrl: baseUrl, + client: client, + authorization: connection.AuthorizationString, + suppressFedAuthRedirect: connection.SuppressFedAuthRedirect, + forceMsaPassThrough: connection.ForceMsaPassThrough, + userAgent: connection.UserAgent, + } +} + +type Client struct { + baseUrl string + client *http.Client + authorization string + suppressFedAuthRedirect bool + forceMsaPassThrough bool + userAgent string +} + +func (client *Client) SendRequest(request *http.Request) (response *http.Response, err error) { + resp, err := client.client.Do(request) // todo: add retry logic + if resp != nil && (resp.StatusCode < 200 || resp.StatusCode >= 300) { + err = client.UnwrapError(resp) + } + return resp, err +} + +func (client *Client) Send(ctx context.Context, + httpMethod string, + locationId uuid.UUID, + apiVersion string, + routeValues map[string]string, + queryParameters url.Values, + body io.Reader, + mediaType string, + acceptMediaType string, + additionalHeaders map[string]string) (response *http.Response, err error) { + location, err := client.getResourceLocation(ctx, locationId) + if err != nil { + return nil, err + } + generatedUrl := client.GenerateUrl(location, routeValues, queryParameters) + fullUrl := combineUrl(client.baseUrl, generatedUrl) + negotiatedVersion, err := negotiateRequestVersion(location, apiVersion) + if err != nil { + return nil, err + } + + req, err := client.CreateRequestMessage(ctx, httpMethod, fullUrl, negotiatedVersion, body, mediaType, acceptMediaType, additionalHeaders) + if err != nil { + return nil, err + } + + resp, err := client.SendRequest(req) + if err != nil { + return nil, err + } + + // Set session if one was supplied in the response. + session, ok := resp.Header[headerKeySession] + if ok && len(session) > 0 { + SessionId = session[0] + } + + return resp, err +} + +func (client *Client) GenerateUrl(apiResourceLocation *ApiResourceLocation, routeValues map[string]string, queryParameters url.Values) (request string) { + builtUrl := *apiResourceLocation.RouteTemplate + if routeValues == nil { + routeValues = make(map[string]string) + } + routeValues["area"] = *apiResourceLocation.Area + routeValues["resource"] = *apiResourceLocation.ResourceName + builtUrl = transformRouteTemplate(builtUrl, routeValues) + if queryParameters != nil && len(queryParameters) > 0 { + builtUrl += "?" + queryParameters.Encode() + } + return builtUrl +} + +func (client *Client) CreateRequestMessage(ctx context.Context, + httpMethod string, + url string, + apiVersion string, + body io.Reader, + mediaType string, + acceptMediaType string, + additionalHeaders map[string]string) (request *http.Request, err error) { + req, err := http.NewRequest(httpMethod, url, body) + if err != nil { + return nil, err + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + if client.authorization != "" { + req.Header.Add(headerKeyAuthorization, client.authorization) + } + accept := acceptMediaType + if apiVersion != "" { + accept += ";api-version=" + apiVersion + } + req.Header.Add(headerKeyAccept, accept) + if mediaType != "" { + req.Header.Add(headerKeyContentType, mediaType+";charset=utf-8") + } + if client.suppressFedAuthRedirect { + req.Header.Add(headerKeyFedAuthRedirect, "Suppress") + } + if client.forceMsaPassThrough { + req.Header.Add(headerKeyForceMsaPassThrough, "true") + } + + // set session if it has not already been set + _, ok := req.Header[headerKeySession] + if !ok { + req.Header.Add(headerKeySession, SessionId) + } + + userAgent := baseUserAgent + if client.userAgent != "" { + userAgent += " " + client.userAgent + } + req.Header.Add(headerUserAgent, userAgent) + + for key, value := range additionalHeaders { + req.Header.Add(key, value) + } + + return req, err +} + +func (client *Client) getResourceLocation(ctx context.Context, locationId uuid.UUID) (*ApiResourceLocation, error) { + locationsMap, ok := getApiResourceLocationCache(client.baseUrl) + if !ok { + locations, err := client.getResourceLocationsFromServer(ctx) + if err != nil { + return nil, err + } + newMap := make(map[uuid.UUID]ApiResourceLocation) + locationsMap = &newMap + for _, locationEntry := range locations { + (*locationsMap)[*locationEntry.Id] = locationEntry + } + + setApiResourceLocationCache(client.baseUrl, locationsMap) + } + + location, ok := (*locationsMap)[locationId] + if ok { + return &location, nil + } + + return nil, &LocationIdNotRegisteredError{locationId, client.baseUrl} +} + +func getApiResourceLocationCache(url string) (*map[uuid.UUID]ApiResourceLocation, bool) { + apiResourceLocationCacheLock.RLock() + defer apiResourceLocationCacheLock.RUnlock() + locationsMap, ok := apiResourceLocationCache[url] + return locationsMap, ok +} + +func setApiResourceLocationCache(url string, locationsMap *map[uuid.UUID]ApiResourceLocation) { + apiResourceLocationCacheLock.Lock() + defer apiResourceLocationCacheLock.Unlock() + apiResourceLocationCache[url] = locationsMap +} + +func (client *Client) getResourceLocationsFromServer(ctx context.Context) ([]ApiResourceLocation, error) { + optionsUri := combineUrl(client.baseUrl, "_apis") + request, err := client.CreateRequestMessage(ctx, http.MethodOptions, optionsUri, "", nil, "", MediaTypeApplicationJson, nil) + if err != nil { + return nil, err + } + + resp, err := client.SendRequest(request) + if err != nil { + return nil, err + } + + // Set session if one was supplied in the response. + session, ok := resp.Header[headerKeySession] + if ok && len(session) > 0 { + SessionId = session[0] + } + + if resp != nil && (resp.StatusCode < 200 || resp.StatusCode >= 300) { + return nil, client.UnwrapError(resp) + } + + var locations []ApiResourceLocation + err = client.UnmarshalCollectionBody(resp, &locations) + + return locations, err +} + +// Examples of api-version: 5.1, 5.1-preview, 5.1-preview.1 +var apiVersionRegEx = regexp.MustCompile(`(\d+(\.\d)?)(-preview(.(\d+))?)?`) + +func combineUrl(part1 string, part2 string) string { + return strings.TrimRight(part1, "/") + "/" + strings.TrimLeft(part2, "/") +} + +func transformRouteTemplate(routeTemplate string, routeValues map[string]string) string { + newTemplate := "" + routeTemplate = strings.Replace(routeTemplate, "{*", "{", -1) + segments := strings.Split(routeTemplate, "/") + for _, segment := range segments { + length := len(segment) + if length <= 2 || segment[0] != '{' || segment[length-1] != '}' { + newTemplate += "/" + segment + } else { + value, ok := routeValues[segment[1:length-1]] + if ok { + newTemplate += "/" + url.PathEscape(value) + } + // else this is an optional parameter that has not been supplied, so don't add it back + } + } + // following covers oddball templates with segments that include the token and additional constants + for key, value := range routeValues { + newTemplate = strings.Replace(newTemplate, "{"+key+"}", value, -1) + } + return newTemplate +} + +func (client *Client) UnmarshalBody(response *http.Response, v interface{}) (err error) { + if response != nil && response.Body != nil { + var err error + defer func() { + if closeError := response.Body.Close(); closeError != nil { + err = closeError + } + }() + body, err := ioutil.ReadAll(response.Body) + if err != nil { + return err + } + body = trimByteOrderMark(body) + return json.Unmarshal(body, &v) + } + return nil +} + +func (client *Client) UnmarshalCollectionBody(response *http.Response, v interface{}) (err error) { + if response != nil && response.Body != nil { + var err error + defer func() { + if closeError := response.Body.Close(); closeError != nil { + err = closeError + } + }() + body, err := ioutil.ReadAll(response.Body) + if err != nil { + return err + } + + body = trimByteOrderMark(body) + err = client.UnmarshalCollectionJson(body, v) + if err != nil { + return err + } + } + return nil +} + +func (client *Client) UnmarshalCollectionJson(jsonValue []byte, v interface{}) (err error) { + t := reflect.TypeOf(v) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } else { + return errors.New("value type must be a pointer") + } + sType := reflect.StructOf([]reflect.StructField{ + {Name: "Count", Type: reflect.TypeOf(0)}, + {Name: "Value", Type: t}, + }) + sv := reflect.New(sType) + err = json.Unmarshal(jsonValue, sv.Interface()) + if err != nil { + return err + } + + rv := reflect.ValueOf(v) + rv.Elem().Set(sv.Elem().FieldByName("Value")) + return nil +} + +// Returns slice of body without utf-8 byte order mark. +// If BOM does not exist body is returned unchanged. +func trimByteOrderMark(body []byte) []byte { + return bytes.TrimPrefix(body, []byte("\xef\xbb\xbf")) +} + +func (client *Client) UnwrapError(response *http.Response) (err error) { + if response.ContentLength == 0 { + message := "Request returned status: " + response.Status + return &WrappedError{ + Message: &message, + StatusCode: &response.StatusCode, + } + } + + defer func() { + if closeError := response.Body.Close(); closeError != nil { + err = closeError + } + }() + + body, err := ioutil.ReadAll(response.Body) + if err != nil { + return err + } + + body = trimByteOrderMark(body) + + contentType, ok := response.Header[headerKeyContentType] + if ok && len(contentType) > 0 && strings.Index(contentType[0], MediaTypeTextPlain) >= 0 { + message := string(body) + statusCode := response.StatusCode + return WrappedError{Message: &message, StatusCode: &statusCode} + } + + var wrappedError WrappedError + err = json.Unmarshal(body, &wrappedError) + wrappedError.StatusCode = &response.StatusCode + if err != nil { + return err + } + + if wrappedError.Message == nil { + var wrappedImproperError WrappedImproperError + err = json.Unmarshal(body, &wrappedImproperError) + if err == nil && wrappedImproperError.Value != nil && wrappedImproperError.Value.Message != nil { + return &WrappedError{ + Message: wrappedImproperError.Value.Message, + StatusCode: &response.StatusCode, + } + } + } + + return wrappedError +} + +func (client *Client) GetResourceAreas(ctx context.Context) (*[]ResourceAreaInfo, error) { + queryParams := url.Values{} + locationId, _ := uuid.Parse("e81700f7-3be2-46de-8624-2eb35882fcaa") + resp, err := client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ResourceAreaInfo + err = client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +type LocationIdNotRegisteredError struct { + LocationId uuid.UUID + Url string +} + +func (e LocationIdNotRegisteredError) Error() string { + return "API resource location " + e.LocationId.String() + " is not registered on " + e.Url + "." +} + +type InvalidApiVersion struct { + ApiVersion string +} + +func (e InvalidApiVersion) Error() string { + return "The requested api-version is not in a valid format: " + e.ApiVersion +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/connection.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/connection.go new file mode 100644 index 0000000000..eb76f53c71 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/connection.go @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azuredevops + +import ( + "context" + "crypto/tls" + "encoding/base64" + "strings" + "sync" + "time" + + "github.com/google/uuid" +) + +// Creates a new Azure DevOps connection instance using a personal access token. +func NewPatConnection(organizationUrl string, personalAccessToken string) *Connection { + authorizationString := CreateBasicAuthHeaderValue("", personalAccessToken) + organizationUrl = normalizeUrl(organizationUrl) + return &Connection{ + AuthorizationString: authorizationString, + BaseUrl: organizationUrl, + SuppressFedAuthRedirect: true, + } +} + +func NewAnonymousConnection(organizationUrl string) *Connection { + organizationUrl = normalizeUrl(organizationUrl) + return &Connection{ + BaseUrl: organizationUrl, + SuppressFedAuthRedirect: true, + } +} + +type Connection struct { + AuthorizationString string + BaseUrl string + UserAgent string + SuppressFedAuthRedirect bool + ForceMsaPassThrough bool + Timeout *time.Duration + TlsConfig *tls.Config + clientCache map[string]Client + clientCacheLock sync.RWMutex + resourceAreaCache map[uuid.UUID]ResourceAreaInfo + resourceAreaCacheLock sync.RWMutex +} + +func CreateBasicAuthHeaderValue(username, password string) string { + auth := username + ":" + password + return "Basic " + base64.StdEncoding.EncodeToString([]byte(auth)) +} + +func normalizeUrl(url string) string { + return strings.ToLower(strings.TrimRight(url, "/")) +} + +func (connection *Connection) GetClientByResourceAreaId(ctx context.Context, resourceAreaID uuid.UUID) (*Client, error) { + resourceAreaInfo, err := connection.getResourceAreaInfo(ctx, resourceAreaID) + if err != nil { + return nil, err + } + var client *Client + if resourceAreaInfo != nil { + client = connection.GetClientByUrl(*resourceAreaInfo.LocationUrl) + } else { + // resourceAreaInfo will be nil for on prem servers + client = connection.GetClientByUrl(connection.BaseUrl) + } + return client, nil +} + +func (connection *Connection) GetClientByUrl(baseUrl string) *Client { + normalizedUrl := normalizeUrl(baseUrl) + azureDevOpsClient, ok := connection.getClientCacheEntry(normalizedUrl) + if !ok { + azureDevOpsClient = NewClient(connection, normalizedUrl) + connection.setClientCacheEntry(normalizedUrl, azureDevOpsClient) + } + return azureDevOpsClient +} + +func (connection *Connection) getResourceAreaInfo(ctx context.Context, resourceAreaId uuid.UUID) (*ResourceAreaInfo, error) { + resourceAreaInfo, ok := connection.getResourceAreaCacheEntry(resourceAreaId) + if !ok { + client := connection.GetClientByUrl(connection.BaseUrl) + resourceAreaInfos, err := client.GetResourceAreas(ctx) + if err != nil { + return nil, err + } + + if len(*resourceAreaInfos) > 0 { + for _, resourceEntry := range *resourceAreaInfos { + connection.setResourceAreaCacheEntry(*resourceEntry.Id, &resourceEntry) + } + resourceAreaInfo, ok = connection.getResourceAreaCacheEntry(resourceAreaId) + } else { + // on prem servers return an empty list + return nil, nil + } + } + + if ok { + return resourceAreaInfo, nil + } + + return nil, &ResourceAreaIdNotRegisteredError{resourceAreaId, connection.BaseUrl} +} + +// Client Cache by Url +func (connection *Connection) getClientCacheEntry(url string) (*Client, bool) { + if connection.clientCache == nil { + return nil, false + } + connection.clientCacheLock.RLock() + defer connection.clientCacheLock.RUnlock() + client, ok := connection.clientCache[url] + return &client, ok +} + +func (connection *Connection) setClientCacheEntry(url string, client *Client) { + connection.clientCacheLock.Lock() + defer connection.clientCacheLock.Unlock() + if connection.clientCache == nil { + connection.clientCache = make(map[string]Client) + } + connection.clientCache[url] = *client +} + +func (connection *Connection) getResourceAreaCacheEntry(resourceAreaId uuid.UUID) (*ResourceAreaInfo, bool) { + if connection.resourceAreaCache == nil { + return nil, false + } + connection.resourceAreaCacheLock.RLock() + defer connection.resourceAreaCacheLock.RUnlock() + resourceAreaInfo, ok := connection.resourceAreaCache[resourceAreaId] + return &resourceAreaInfo, ok +} + +func (connection *Connection) setResourceAreaCacheEntry(resourceAreaId uuid.UUID, resourceAreaInfo *ResourceAreaInfo) { + connection.resourceAreaCacheLock.Lock() + defer connection.resourceAreaCacheLock.Unlock() + if connection.resourceAreaCache == nil { + connection.resourceAreaCache = make(map[uuid.UUID]ResourceAreaInfo) + } + connection.resourceAreaCache[resourceAreaId] = *resourceAreaInfo +} + +type ResourceAreaIdNotRegisteredError struct { + ResourceAreaId uuid.UUID + Url string +} + +func (e ResourceAreaIdNotRegisteredError) Error() string { + return "API resource area Id " + e.ResourceAreaId.String() + " is not registered on " + e.Url + "." +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/core/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/core/client.go new file mode 100644 index 0000000000..edddd3a7e1 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/core/client.go @@ -0,0 +1,918 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package core + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/operations" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("79134c72-4a58-4b42-976c-04e7115f32bf") + +type Client interface { + // [Preview API] + CreateConnectedService(context.Context, CreateConnectedServiceArgs) (*WebApiConnectedService, error) + // [Preview API] + CreateOrUpdateProxy(context.Context, CreateOrUpdateProxyArgs) (*Proxy, error) + // Create a team in a team project. + CreateTeam(context.Context, CreateTeamArgs) (*WebApiTeam, error) + // [Preview API] + DeleteProxy(context.Context, DeleteProxyArgs) error + // Delete a team. + DeleteTeam(context.Context, DeleteTeamArgs) error + // [Preview API] Get a list of all teams. + GetAllTeams(context.Context, GetAllTeamsArgs) (*[]WebApiTeam, error) + // [Preview API] + GetConnectedServiceDetails(context.Context, GetConnectedServiceDetailsArgs) (*WebApiConnectedServiceDetails, error) + // [Preview API] + GetConnectedServices(context.Context, GetConnectedServicesArgs) (*[]WebApiConnectedService, error) + // Get a process by ID. + GetProcessById(context.Context, GetProcessByIdArgs) (*Process, error) + // Get a list of processes. + GetProcesses(context.Context, GetProcessesArgs) (*[]Process, error) + // Get project with the specified id or name, optionally including capabilities. + GetProject(context.Context, GetProjectArgs) (*TeamProject, error) + // Get project collection with the specified id or name. + GetProjectCollection(context.Context, GetProjectCollectionArgs) (*TeamProjectCollection, error) + // Get project collection references for this application. + GetProjectCollections(context.Context, GetProjectCollectionsArgs) (*[]TeamProjectCollectionReference, error) + // [Preview API] Get a collection of team project properties. + GetProjectProperties(context.Context, GetProjectPropertiesArgs) (*[]ProjectProperty, error) + // Get all projects in the organization that the authenticated user has access to. + GetProjects(context.Context, GetProjectsArgs) (*GetProjectsResponseValue, error) + // [Preview API] + GetProxies(context.Context, GetProxiesArgs) (*[]Proxy, error) + // Get a specific team. + GetTeam(context.Context, GetTeamArgs) (*WebApiTeam, error) + // Get a list of members for a specific team. + GetTeamMembersWithExtendedProperties(context.Context, GetTeamMembersWithExtendedPropertiesArgs) (*[]webapi.TeamMember, error) + // Get a list of teams. + GetTeams(context.Context, GetTeamsArgs) (*[]WebApiTeam, error) + // Queues a project to be created. Use the [GetOperation](../../operations/operations/get) to periodically check for create project status. + QueueCreateProject(context.Context, QueueCreateProjectArgs) (*operations.OperationReference, error) + // Queues a project to be deleted. Use the [GetOperation](../../operations/operations/get) to periodically check for delete project status. + QueueDeleteProject(context.Context, QueueDeleteProjectArgs) (*operations.OperationReference, error) + // [Preview API] Removes the avatar for the project. + RemoveProjectAvatar(context.Context, RemoveProjectAvatarArgs) error + // [Preview API] Sets the avatar for the project. + SetProjectAvatar(context.Context, SetProjectAvatarArgs) error + // [Preview API] Create, update, and delete team project properties. + SetProjectProperties(context.Context, SetProjectPropertiesArgs) error + // Update an existing project's name, abbreviation, description, or restore a project. + UpdateProject(context.Context, UpdateProjectArgs) (*operations.OperationReference, error) + // Update a team's name and/or description. + UpdateTeam(context.Context, UpdateTeamArgs) (*WebApiTeam, error) +} + +type ClientImpl struct { + Client azuredevops.Client +} + +func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { + client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) + if err != nil { + return nil, err + } + return &ClientImpl{ + Client: *client, + }, nil +} + +// [Preview API] +func (client *ClientImpl) CreateConnectedService(ctx context.Context, args CreateConnectedServiceArgs) (*WebApiConnectedService, error) { + if args.ConnectedServiceCreationData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ConnectedServiceCreationData"} + } + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + + body, marshalErr := json.Marshal(*args.ConnectedServiceCreationData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b4f70219-e18b-42c5-abe3-98b07d35525e") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WebApiConnectedService + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateConnectedService function +type CreateConnectedServiceArgs struct { + // (required) + ConnectedServiceCreationData *WebApiConnectedServiceDetails + // (required) + ProjectId *string +} + +// [Preview API] +func (client *ClientImpl) CreateOrUpdateProxy(ctx context.Context, args CreateOrUpdateProxyArgs) (*Proxy, error) { + if args.Proxy == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Proxy"} + } + body, marshalErr := json.Marshal(*args.Proxy) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ec1f4311-f2b4-4c15-b2b8-8990b80d2908") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Proxy + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateOrUpdateProxy function +type CreateOrUpdateProxyArgs struct { + // (required) + Proxy *Proxy +} + +// Create a team in a team project. +func (client *ClientImpl) CreateTeam(ctx context.Context, args CreateTeamArgs) (*WebApiTeam, error) { + if args.Team == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Team"} + } + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + + body, marshalErr := json.Marshal(*args.Team) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d30a3dd1-f8ba-442a-b86a-bd0c0c383e59") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WebApiTeam + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTeam function +type CreateTeamArgs struct { + // (required) The team data used to create the team. + Team *WebApiTeam + // (required) The name or ID (GUID) of the team project in which to create the team. + ProjectId *string +} + +// [Preview API] +func (client *ClientImpl) DeleteProxy(ctx context.Context, args DeleteProxyArgs) error { + queryParams := url.Values{} + if args.ProxyUrl == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "proxyUrl"} + } + queryParams.Add("proxyUrl", *args.ProxyUrl) + if args.Site != nil { + queryParams.Add("site", *args.Site) + } + locationId, _ := uuid.Parse("ec1f4311-f2b4-4c15-b2b8-8990b80d2908") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteProxy function +type DeleteProxyArgs struct { + // (required) + ProxyUrl *string + // (optional) + Site *string +} + +// Delete a team. +func (client *ClientImpl) DeleteTeam(ctx context.Context, args DeleteTeamArgs) error { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + if args.TeamId == nil || *args.TeamId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TeamId"} + } + routeValues["teamId"] = *args.TeamId + + locationId, _ := uuid.Parse("d30a3dd1-f8ba-442a-b86a-bd0c0c383e59") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteTeam function +type DeleteTeamArgs struct { + // (required) The name or ID (GUID) of the team project containing the team to delete. + ProjectId *string + // (required) The name or ID of the team to delete. + TeamId *string +} + +// [Preview API] Get a list of all teams. +func (client *ClientImpl) GetAllTeams(ctx context.Context, args GetAllTeamsArgs) (*[]WebApiTeam, error) { + queryParams := url.Values{} + if args.Mine != nil { + queryParams.Add("$mine", strconv.FormatBool(*args.Mine)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.ExpandIdentity != nil { + queryParams.Add("$expandIdentity", strconv.FormatBool(*args.ExpandIdentity)) + } + locationId, _ := uuid.Parse("7a4d9ee9-3433-4347-b47a-7a80f1cf307e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.3", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []WebApiTeam + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAllTeams function +type GetAllTeamsArgs struct { + // (optional) If true, then return all teams requesting user is member. Otherwise return all teams user has read access. + Mine *bool + // (optional) Maximum number of teams to return. + Top *int + // (optional) Number of teams to skip. + Skip *int + // (optional) A value indicating whether or not to expand Identity information in the result WebApiTeam object. + ExpandIdentity *bool +} + +// [Preview API] +func (client *ClientImpl) GetConnectedServiceDetails(ctx context.Context, args GetConnectedServiceDetailsArgs) (*WebApiConnectedServiceDetails, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("b4f70219-e18b-42c5-abe3-98b07d35525e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WebApiConnectedServiceDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetConnectedServiceDetails function +type GetConnectedServiceDetailsArgs struct { + // (required) + ProjectId *string + // (required) + Name *string +} + +// [Preview API] +func (client *ClientImpl) GetConnectedServices(ctx context.Context, args GetConnectedServicesArgs) (*[]WebApiConnectedService, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + + queryParams := url.Values{} + if args.Kind != nil { + queryParams.Add("kind", string(*args.Kind)) + } + locationId, _ := uuid.Parse("b4f70219-e18b-42c5-abe3-98b07d35525e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []WebApiConnectedService + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetConnectedServices function +type GetConnectedServicesArgs struct { + // (required) + ProjectId *string + // (optional) + Kind *ConnectedServiceKind +} + +// Get a process by ID. +func (client *ClientImpl) GetProcessById(ctx context.Context, args GetProcessByIdArgs) (*Process, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + + locationId, _ := uuid.Parse("93878975-88c5-4e6a-8abb-7ddd77a8a7d8") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Process + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessById function +type GetProcessByIdArgs struct { + // (required) ID for a process. + ProcessId *uuid.UUID +} + +// Get a list of processes. +func (client *ClientImpl) GetProcesses(ctx context.Context, args GetProcessesArgs) (*[]Process, error) { + locationId, _ := uuid.Parse("93878975-88c5-4e6a-8abb-7ddd77a8a7d8") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Process + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcesses function +type GetProcessesArgs struct { +} + +// Get project with the specified id or name, optionally including capabilities. +func (client *ClientImpl) GetProject(ctx context.Context, args GetProjectArgs) (*TeamProject, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + + queryParams := url.Values{} + if args.IncludeCapabilities != nil { + queryParams.Add("includeCapabilities", strconv.FormatBool(*args.IncludeCapabilities)) + } + if args.IncludeHistory != nil { + queryParams.Add("includeHistory", strconv.FormatBool(*args.IncludeHistory)) + } + locationId, _ := uuid.Parse("603fe2ac-9723-48b9-88ad-09305aa6c6e1") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TeamProject + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProject function +type GetProjectArgs struct { + // (required) + ProjectId *string + // (optional) Include capabilities (such as source control) in the team project result (default: false). + IncludeCapabilities *bool + // (optional) Search within renamed projects (that had such name in the past). + IncludeHistory *bool +} + +// Get project collection with the specified id or name. +func (client *ClientImpl) GetProjectCollection(ctx context.Context, args GetProjectCollectionArgs) (*TeamProjectCollection, error) { + routeValues := make(map[string]string) + if args.CollectionId == nil || *args.CollectionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CollectionId"} + } + routeValues["collectionId"] = *args.CollectionId + + locationId, _ := uuid.Parse("8031090f-ef1d-4af6-85fc-698cd75d42bf") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TeamProjectCollection + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProjectCollection function +type GetProjectCollectionArgs struct { + // (required) + CollectionId *string +} + +// Get project collection references for this application. +func (client *ClientImpl) GetProjectCollections(ctx context.Context, args GetProjectCollectionsArgs) (*[]TeamProjectCollectionReference, error) { + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + locationId, _ := uuid.Parse("8031090f-ef1d-4af6-85fc-698cd75d42bf") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []TeamProjectCollectionReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProjectCollections function +type GetProjectCollectionsArgs struct { + // (optional) + Top *int + // (optional) + Skip *int +} + +// [Preview API] Get a collection of team project properties. +func (client *ClientImpl) GetProjectProperties(ctx context.Context, args GetProjectPropertiesArgs) (*[]ProjectProperty, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = (*args.ProjectId).String() + + queryParams := url.Values{} + if args.Keys != nil { + listAsString := strings.Join((*args.Keys)[:], ",") + queryParams.Add("keys", listAsString) + } + locationId, _ := uuid.Parse("4976a71a-4487-49aa-8aab-a1eda469037a") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ProjectProperty + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProjectProperties function +type GetProjectPropertiesArgs struct { + // (required) The team project ID. + ProjectId *uuid.UUID + // (optional) A comma-delimited string of team project property names. Wildcard characters ("?" and "*") are supported. If no key is specified, all properties will be returned. + Keys *[]string +} + +// Get all projects in the organization that the authenticated user has access to. +func (client *ClientImpl) GetProjects(ctx context.Context, args GetProjectsArgs) (*GetProjectsResponseValue, error) { + queryParams := url.Values{} + if args.StateFilter != nil { + queryParams.Add("stateFilter", string(*args.StateFilter)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.GetDefaultTeamImageUrl != nil { + queryParams.Add("getDefaultTeamImageUrl", strconv.FormatBool(*args.GetDefaultTeamImageUrl)) + } + locationId, _ := uuid.Parse("603fe2ac-9723-48b9-88ad-09305aa6c6e1") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetProjectsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetProjects function +type GetProjectsArgs struct { + // (optional) Filter on team projects in a specific team project state (default: WellFormed). + StateFilter *ProjectState + // (optional) + Top *int + // (optional) + Skip *int + // (optional) + ContinuationToken *string + // (optional) + GetDefaultTeamImageUrl *bool +} + +// Return type for the GetProjects function +type GetProjectsResponseValue struct { + Value []TeamProjectReference + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] +func (client *ClientImpl) GetProxies(ctx context.Context, args GetProxiesArgs) (*[]Proxy, error) { + queryParams := url.Values{} + if args.ProxyUrl != nil { + queryParams.Add("proxyUrl", *args.ProxyUrl) + } + locationId, _ := uuid.Parse("ec1f4311-f2b4-4c15-b2b8-8990b80d2908") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Proxy + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProxies function +type GetProxiesArgs struct { + // (optional) + ProxyUrl *string +} + +// Get a specific team. +func (client *ClientImpl) GetTeam(ctx context.Context, args GetTeamArgs) (*WebApiTeam, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + if args.TeamId == nil || *args.TeamId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TeamId"} + } + routeValues["teamId"] = *args.TeamId + + queryParams := url.Values{} + if args.ExpandIdentity != nil { + queryParams.Add("$expandIdentity", strconv.FormatBool(*args.ExpandIdentity)) + } + locationId, _ := uuid.Parse("d30a3dd1-f8ba-442a-b86a-bd0c0c383e59") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WebApiTeam + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeam function +type GetTeamArgs struct { + // (required) The name or ID (GUID) of the team project containing the team. + ProjectId *string + // (required) The name or ID (GUID) of the team. + TeamId *string + // (optional) A value indicating whether or not to expand Identity information in the result WebApiTeam object. + ExpandIdentity *bool +} + +// Get a list of members for a specific team. +func (client *ClientImpl) GetTeamMembersWithExtendedProperties(ctx context.Context, args GetTeamMembersWithExtendedPropertiesArgs) (*[]webapi.TeamMember, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + if args.TeamId == nil || *args.TeamId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TeamId"} + } + routeValues["teamId"] = *args.TeamId + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + locationId, _ := uuid.Parse("294c494c-2600-4d7e-b76c-3dd50c3c95be") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []webapi.TeamMember + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeamMembersWithExtendedProperties function +type GetTeamMembersWithExtendedPropertiesArgs struct { + // (required) The name or ID (GUID) of the team project the team belongs to. + ProjectId *string + // (required) The name or ID (GUID) of the team . + TeamId *string + // (optional) + Top *int + // (optional) + Skip *int +} + +// Get a list of teams. +func (client *ClientImpl) GetTeams(ctx context.Context, args GetTeamsArgs) (*[]WebApiTeam, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + + queryParams := url.Values{} + if args.Mine != nil { + queryParams.Add("$mine", strconv.FormatBool(*args.Mine)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.ExpandIdentity != nil { + queryParams.Add("$expandIdentity", strconv.FormatBool(*args.ExpandIdentity)) + } + locationId, _ := uuid.Parse("d30a3dd1-f8ba-442a-b86a-bd0c0c383e59") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []WebApiTeam + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeams function +type GetTeamsArgs struct { + // (required) + ProjectId *string + // (optional) If true return all the teams requesting user is member, otherwise return all the teams user has read access. + Mine *bool + // (optional) Maximum number of teams to return. + Top *int + // (optional) Number of teams to skip. + Skip *int + // (optional) A value indicating whether or not to expand Identity information in the result WebApiTeam object. + ExpandIdentity *bool +} + +// Queues a project to be created. Use the [GetOperation](../../operations/operations/get) to periodically check for create project status. +func (client *ClientImpl) QueueCreateProject(ctx context.Context, args QueueCreateProjectArgs) (*operations.OperationReference, error) { + if args.ProjectToCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProjectToCreate"} + } + body, marshalErr := json.Marshal(*args.ProjectToCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("603fe2ac-9723-48b9-88ad-09305aa6c6e1") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue operations.OperationReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueueCreateProject function +type QueueCreateProjectArgs struct { + // (required) The project to create. + ProjectToCreate *TeamProject +} + +// Queues a project to be deleted. Use the [GetOperation](../../operations/operations/get) to periodically check for delete project status. +func (client *ClientImpl) QueueDeleteProject(ctx context.Context, args QueueDeleteProjectArgs) (*operations.OperationReference, error) { + routeValues := make(map[string]string) + if args.ProjectId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = (*args.ProjectId).String() + + locationId, _ := uuid.Parse("603fe2ac-9723-48b9-88ad-09305aa6c6e1") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue operations.OperationReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueueDeleteProject function +type QueueDeleteProjectArgs struct { + // (required) The project id of the project to delete. + ProjectId *uuid.UUID +} + +// [Preview API] Removes the avatar for the project. +func (client *ClientImpl) RemoveProjectAvatar(ctx context.Context, args RemoveProjectAvatarArgs) error { + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + + locationId, _ := uuid.Parse("54b2a2a0-859b-4d05-827c-ec4c862f641a") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the RemoveProjectAvatar function +type RemoveProjectAvatarArgs struct { + // (required) The ID or name of the project. + ProjectId *string +} + +// [Preview API] Sets the avatar for the project. +func (client *ClientImpl) SetProjectAvatar(ctx context.Context, args SetProjectAvatarArgs) error { + if args.AvatarBlob == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.AvatarBlob"} + } + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + + body, marshalErr := json.Marshal(*args.AvatarBlob) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("54b2a2a0-859b-4d05-827c-ec4c862f641a") + _, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the SetProjectAvatar function +type SetProjectAvatarArgs struct { + // (required) The avatar blob data object to upload. + AvatarBlob *ProjectAvatar + // (required) The ID or name of the project. + ProjectId *string +} + +// [Preview API] Create, update, and delete team project properties. +func (client *ClientImpl) SetProjectProperties(ctx context.Context, args SetProjectPropertiesArgs) error { + if args.PatchDocument == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PatchDocument"} + } + routeValues := make(map[string]string) + if args.ProjectId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = (*args.ProjectId).String() + + body, marshalErr := json.Marshal(*args.PatchDocument) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("4976a71a-4487-49aa-8aab-a1eda469037a") + _, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the SetProjectProperties function +type SetProjectPropertiesArgs struct { + // (required) The team project ID. + ProjectId *uuid.UUID + // (required) A JSON Patch document that represents an array of property operations. See RFC 6902 for more details on JSON Patch. The accepted operation verbs are Add and Remove, where Add is used for both creating and updating properties. The path consists of a forward slash and a property name. + PatchDocument *[]webapi.JsonPatchOperation +} + +// Update an existing project's name, abbreviation, description, or restore a project. +func (client *ClientImpl) UpdateProject(ctx context.Context, args UpdateProjectArgs) (*operations.OperationReference, error) { + if args.ProjectUpdate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProjectUpdate"} + } + routeValues := make(map[string]string) + if args.ProjectId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = (*args.ProjectId).String() + + body, marshalErr := json.Marshal(*args.ProjectUpdate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("603fe2ac-9723-48b9-88ad-09305aa6c6e1") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue operations.OperationReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateProject function +type UpdateProjectArgs struct { + // (required) The updates for the project. The state must be set to wellFormed to restore the project. + ProjectUpdate *TeamProject + // (required) The project id of the project to update. + ProjectId *uuid.UUID +} + +// Update a team's name and/or description. +func (client *ClientImpl) UpdateTeam(ctx context.Context, args UpdateTeamArgs) (*WebApiTeam, error) { + if args.TeamData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TeamData"} + } + routeValues := make(map[string]string) + if args.ProjectId == nil || *args.ProjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProjectId"} + } + routeValues["projectId"] = *args.ProjectId + if args.TeamId == nil || *args.TeamId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TeamId"} + } + routeValues["teamId"] = *args.TeamId + + body, marshalErr := json.Marshal(*args.TeamData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d30a3dd1-f8ba-442a-b86a-bd0c0c383e59") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WebApiTeam + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTeam function +type UpdateTeamArgs struct { + // (required) + TeamData *WebApiTeam + // (required) The name or ID (GUID) of the team project containing the team to update. + ProjectId *string + // (required) The name of ID of the team to update. + TeamId *string +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/core/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/core/models.go new file mode 100644 index 0000000000..e75641040e --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/core/models.go @@ -0,0 +1,483 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package core + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/identity" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type ConnectedServiceKind string + +type connectedServiceKindValuesType struct { + Custom ConnectedServiceKind + AzureSubscription ConnectedServiceKind + Chef ConnectedServiceKind + Generic ConnectedServiceKind +} + +var ConnectedServiceKindValues = connectedServiceKindValuesType{ + // Custom or unknown service + Custom: "custom", + // Azure Subscription + AzureSubscription: "azureSubscription", + // Chef Connection + Chef: "chef", + // Generic Connection + Generic: "generic", +} + +type IdentityData struct { + IdentityIds *[]uuid.UUID `json:"identityIds,omitempty"` +} + +type Process struct { + Name *string `json:"name,omitempty"` + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + Description *string `json:"description,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Type *ProcessType `json:"type,omitempty"` +} + +// Type of process customization on a collection. +type ProcessCustomizationType string + +type processCustomizationTypeValuesType struct { + Xml ProcessCustomizationType + Inherited ProcessCustomizationType +} + +var ProcessCustomizationTypeValues = processCustomizationTypeValuesType{ + // Customization based on project-scoped xml customization + Xml: "xml", + // Customization based on process inheritance + Inherited: "inherited", +} + +type ProcessReference struct { + Name *string `json:"name,omitempty"` + Url *string `json:"url,omitempty"` +} + +type ProcessType string + +type processTypeValuesType struct { + System ProcessType + Custom ProcessType + Inherited ProcessType +} + +var ProcessTypeValues = processTypeValuesType{ + System: "system", + Custom: "custom", + Inherited: "inherited", +} + +// Contains the image data for project avatar. +type ProjectAvatar struct { + // The avatar image represented as a byte array. + Image *[]byte `json:"image,omitempty"` +} + +type ProjectChangeType string + +type projectChangeTypeValuesType struct { + Modified ProjectChangeType + Deleted ProjectChangeType + Added ProjectChangeType +} + +var ProjectChangeTypeValues = projectChangeTypeValuesType{ + Modified: "modified", + Deleted: "deleted", + Added: "added", +} + +// Contains information describing a project. +type ProjectInfo struct { + // The abbreviated name of the project. + Abbreviation *string `json:"abbreviation,omitempty"` + // The description of the project. + Description *string `json:"description,omitempty"` + // The id of the project. + Id *uuid.UUID `json:"id,omitempty"` + // The time that this project was last updated. + LastUpdateTime *azuredevops.Time `json:"lastUpdateTime,omitempty"` + // The name of the project. + Name *string `json:"name,omitempty"` + // A set of name-value pairs storing additional property data related to the project. + Properties *[]ProjectProperty `json:"properties,omitempty"` + // The current revision of the project. + Revision *uint64 `json:"revision,omitempty"` + // The current state of the project. + State *ProjectState `json:"state,omitempty"` + // A Uri that can be used to refer to this project. + Uri *string `json:"uri,omitempty"` + // The version number of the project. + Version *uint64 `json:"version,omitempty"` + // Indicates whom the project is visible to. + Visibility *ProjectVisibility `json:"visibility,omitempty"` +} + +type ProjectMessage struct { + Project *ProjectInfo `json:"project,omitempty"` + ProjectChangeType *ProjectChangeType `json:"projectChangeType,omitempty"` + ShouldInvalidateSystemStore *bool `json:"shouldInvalidateSystemStore,omitempty"` +} + +type ProjectProperties struct { + // The team project Id + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // The collection of team project properties + Properties *[]ProjectProperty `json:"properties,omitempty"` +} + +// A named value associated with a project. +type ProjectProperty struct { + // The name of the property. + Name *string `json:"name,omitempty"` + // The value of the property. + Value interface{} `json:"value,omitempty"` +} + +type ProjectState string + +type projectStateValuesType struct { + Deleting ProjectState + New ProjectState + WellFormed ProjectState + CreatePending ProjectState + All ProjectState + Unchanged ProjectState + Deleted ProjectState +} + +var ProjectStateValues = projectStateValuesType{ + // Project is in the process of being deleted. + Deleting: "deleting", + // Project is in the process of being created. + New: "new", + // Project is completely created and ready to use. + WellFormed: "wellFormed", + // Project has been queued for creation, but the process has not yet started. + CreatePending: "createPending", + // All projects regardless of state. + All: "all", + // Project has not been changed. + Unchanged: "unchanged", + // Project has been deleted. + Deleted: "deleted", +} + +type ProjectVisibility string + +type projectVisibilityValuesType struct { + Private ProjectVisibility + Public ProjectVisibility +} + +var ProjectVisibilityValues = projectVisibilityValuesType{ + // The project is only visible to users with explicit access. + Private: "private", + // The project is visible to all. + Public: "public", +} + +type Proxy struct { + Authorization *ProxyAuthorization `json:"authorization,omitempty"` + // This is a description string + Description *string `json:"description,omitempty"` + // The friendly name of the server + FriendlyName *string `json:"friendlyName,omitempty"` + GlobalDefault *bool `json:"globalDefault,omitempty"` + // This is a string representation of the site that the proxy server is located in (e.g. "NA-WA-RED") + Site *string `json:"site,omitempty"` + SiteDefault *bool `json:"siteDefault,omitempty"` + // The URL of the proxy server + Url *string `json:"url,omitempty"` +} + +type ProxyAuthorization struct { + // Gets or sets the endpoint used to obtain access tokens from the configured token service. + AuthorizationUrl *string `json:"authorizationUrl,omitempty"` + // Gets or sets the client identifier for this proxy. + ClientId *uuid.UUID `json:"clientId,omitempty"` + // Gets or sets the user identity to authorize for on-prem. + Identity *string `json:"identity,omitempty"` + // Gets or sets the public key used to verify the identity of this proxy. Only specify on hosted. + PublicKey *webapi.PublicKey `json:"publicKey,omitempty"` +} + +type SourceControlTypes string + +type sourceControlTypesValuesType struct { + Tfvc SourceControlTypes + Git SourceControlTypes +} + +var SourceControlTypesValues = sourceControlTypesValuesType{ + Tfvc: "tfvc", + Git: "git", +} + +// The Team Context for an operation. +type TeamContext struct { + // The team project Id or name. Ignored if ProjectId is set. + Project *string `json:"project,omitempty"` + // The Team Project ID. Required if Project is not set. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // The Team Id or name. Ignored if TeamId is set. + Team *string `json:"team,omitempty"` + // The Team Id + TeamId *uuid.UUID `json:"teamId,omitempty"` +} + +// Represents a Team Project object. +type TeamProject struct { + // Project abbreviation. + Abbreviation *string `json:"abbreviation,omitempty"` + // Url to default team identity image. + DefaultTeamImageUrl *string `json:"defaultTeamImageUrl,omitempty"` + // The project's description (if any). + Description *string `json:"description,omitempty"` + // Project identifier. + Id *uuid.UUID `json:"id,omitempty"` + // Project last update time. + LastUpdateTime *azuredevops.Time `json:"lastUpdateTime,omitempty"` + // Project name. + Name *string `json:"name,omitempty"` + // Project revision. + Revision *uint64 `json:"revision,omitempty"` + // Project state. + State *ProjectState `json:"state,omitempty"` + // Url to the full version of the object. + Url *string `json:"url,omitempty"` + // Project visibility. + Visibility *ProjectVisibility `json:"visibility,omitempty"` + // The links to other objects related to this object. + Links interface{} `json:"_links,omitempty"` + // Set of capabilities this project has (such as process template & version control). + Capabilities *map[string]map[string]string `json:"capabilities,omitempty"` + // The shallow ref to the default team. + DefaultTeam *WebApiTeamRef `json:"defaultTeam,omitempty"` +} + +// Data contract for a TeamProjectCollection. +type TeamProjectCollection struct { + // Collection Id. + Id *uuid.UUID `json:"id,omitempty"` + // Collection Name. + Name *string `json:"name,omitempty"` + // Collection REST Url. + Url *string `json:"url,omitempty"` + // The links to other objects related to this object. + Links interface{} `json:"_links,omitempty"` + // Project collection description. + Description *string `json:"description,omitempty"` + // Process customization type on this collection. It can be Xml or Inherited. + ProcessCustomizationType *ProcessCustomizationType `json:"processCustomizationType,omitempty"` + // Project collection state. + State *string `json:"state,omitempty"` +} + +// Reference object for a TeamProjectCollection. +type TeamProjectCollectionReference struct { + // Collection Id. + Id *uuid.UUID `json:"id,omitempty"` + // Collection Name. + Name *string `json:"name,omitempty"` + // Collection REST Url. + Url *string `json:"url,omitempty"` +} + +// Represents a shallow reference to a TeamProject. +type TeamProjectReference struct { + // Project abbreviation. + Abbreviation *string `json:"abbreviation,omitempty"` + // Url to default team identity image. + DefaultTeamImageUrl *string `json:"defaultTeamImageUrl,omitempty"` + // The project's description (if any). + Description *string `json:"description,omitempty"` + // Project identifier. + Id *uuid.UUID `json:"id,omitempty"` + // Project last update time. + LastUpdateTime *azuredevops.Time `json:"lastUpdateTime,omitempty"` + // Project name. + Name *string `json:"name,omitempty"` + // Project revision. + Revision *uint64 `json:"revision,omitempty"` + // Project state. + State *ProjectState `json:"state,omitempty"` + // Url to the full version of the object. + Url *string `json:"url,omitempty"` + // Project visibility. + Visibility *ProjectVisibility `json:"visibility,omitempty"` +} + +// A data transfer object that stores the metadata associated with the creation of temporary data. +type TemporaryDataCreatedDTO struct { + ExpirationSeconds *int `json:"expirationSeconds,omitempty"` + Origin *string `json:"origin,omitempty"` + Value interface{} `json:"value,omitempty"` + ExpirationDate *azuredevops.Time `json:"expirationDate,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Url *string `json:"url,omitempty"` +} + +// A data transfer object that stores the metadata associated with the temporary data. +type TemporaryDataDTO struct { + ExpirationSeconds *int `json:"expirationSeconds,omitempty"` + Origin *string `json:"origin,omitempty"` + Value interface{} `json:"value,omitempty"` +} + +// Updateable properties for a WebApiTeam. +type UpdateTeam struct { + // New description for the team. + Description *string `json:"description,omitempty"` + // New name for the team. + Name *string `json:"name,omitempty"` +} + +type WebApiConnectedService struct { + Url *string `json:"url,omitempty"` + // The user who did the OAuth authentication to created this service + AuthenticatedBy *webapi.IdentityRef `json:"authenticatedBy,omitempty"` + // Extra description on the service. + Description *string `json:"description,omitempty"` + // Friendly Name of service connection + FriendlyName *string `json:"friendlyName,omitempty"` + // Id/Name of the connection service. For Ex: Subscription Id for Azure Connection + Id *string `json:"id,omitempty"` + // The kind of service. + Kind *string `json:"kind,omitempty"` + // The project associated with this service + Project *TeamProjectReference `json:"project,omitempty"` + // Optional uri to connect directly to the service such as https://windows.azure.com + ServiceUri *string `json:"serviceUri,omitempty"` +} + +type WebApiConnectedServiceDetails struct { + Id *string `json:"id,omitempty"` + Url *string `json:"url,omitempty"` + // Meta data for service connection + ConnectedServiceMetaData *WebApiConnectedService `json:"connectedServiceMetaData,omitempty"` + // Credential info + CredentialsXml *string `json:"credentialsXml,omitempty"` + // Optional uri to connect directly to the service such as https://windows.azure.com + EndPoint *string `json:"endPoint,omitempty"` +} + +type WebApiConnectedServiceRef struct { + Id *string `json:"id,omitempty"` + Url *string `json:"url,omitempty"` +} + +// The representation of data needed to create a tag definition which is sent across the wire. +type WebApiCreateTagRequestData struct { + // Name of the tag definition that will be created. + Name *string `json:"name,omitempty"` +} + +type WebApiProject struct { + // Project abbreviation. + Abbreviation *string `json:"abbreviation,omitempty"` + // Url to default team identity image. + DefaultTeamImageUrl *string `json:"defaultTeamImageUrl,omitempty"` + // The project's description (if any). + Description *string `json:"description,omitempty"` + // Project identifier. + Id *uuid.UUID `json:"id,omitempty"` + // Project last update time. + LastUpdateTime *azuredevops.Time `json:"lastUpdateTime,omitempty"` + // Project name. + Name *string `json:"name,omitempty"` + // Project revision. + Revision *uint64 `json:"revision,omitempty"` + // Project state. + State *ProjectState `json:"state,omitempty"` + // Url to the full version of the object. + Url *string `json:"url,omitempty"` + // Project visibility. + Visibility *ProjectVisibility `json:"visibility,omitempty"` + // Set of capabilities this project has + Capabilities *map[string]map[string]string `json:"capabilities,omitempty"` + // Reference to collection which contains this project + Collection *WebApiProjectCollectionRef `json:"collection,omitempty"` + // Default team for this project + DefaultTeam *WebApiTeamRef `json:"defaultTeam,omitempty"` +} + +type WebApiProjectCollection struct { + // Collection Tfs Url (Host Url) + CollectionUrl *string `json:"collectionUrl,omitempty"` + // Collection Guid + Id *uuid.UUID `json:"id,omitempty"` + // Collection Name + Name *string `json:"name,omitempty"` + // Collection REST Url + Url *string `json:"url,omitempty"` + // Project collection description + Description *string `json:"description,omitempty"` + // Project collection state + State *string `json:"state,omitempty"` +} + +type WebApiProjectCollectionRef struct { + // Collection Tfs Url (Host Url) + CollectionUrl *string `json:"collectionUrl,omitempty"` + // Collection Guid + Id *uuid.UUID `json:"id,omitempty"` + // Collection Name + Name *string `json:"name,omitempty"` + // Collection REST Url + Url *string `json:"url,omitempty"` +} + +// The representation of a tag definition which is sent across the wire. +type WebApiTagDefinition struct { + // Whether or not the tag definition is active. + Active *bool `json:"active,omitempty"` + // ID of the tag definition. + Id *uuid.UUID `json:"id,omitempty"` + // The name of the tag definition. + Name *string `json:"name,omitempty"` + // Resource URL for the Tag Definition. + Url *string `json:"url,omitempty"` +} + +type WebApiTeam struct { + // Team (Identity) Guid. A Team Foundation ID. + Id *uuid.UUID `json:"id,omitempty"` + // Team name + Name *string `json:"name,omitempty"` + // Team REST API Url + Url *string `json:"url,omitempty"` + // Team description + Description *string `json:"description,omitempty"` + // Team identity. + Identity *identity.Identity `json:"identity,omitempty"` + // Identity REST API Url to this team + IdentityUrl *string `json:"identityUrl,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ProjectName *string `json:"projectName,omitempty"` +} + +type WebApiTeamRef struct { + // Team (Identity) Guid. A Team Foundation ID. + Id *uuid.UUID `json:"id,omitempty"` + // Team name + Name *string `json:"name,omitempty"` + // Team REST API Url + Url *string `json:"url,omitempty"` +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/delegatedauthorization/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/delegatedauthorization/models.go new file mode 100644 index 0000000000..e26fb557c6 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/delegatedauthorization/models.go @@ -0,0 +1,350 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package delegatedauthorization + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AccessTokenResult struct { + AccessToken *webapi.JsonWebToken `json:"accessToken,omitempty"` + AccessTokenError *TokenError `json:"accessTokenError,omitempty"` + AuthorizationId *uuid.UUID `json:"authorizationId,omitempty"` + ErrorDescription *string `json:"errorDescription,omitempty"` + HasError *bool `json:"hasError,omitempty"` + RefreshToken *RefreshTokenGrant `json:"refreshToken,omitempty"` + TokenType *string `json:"tokenType,omitempty"` + ValidTo *azuredevops.Time `json:"validTo,omitempty"` +} + +type Authorization struct { + AccessIssued *azuredevops.Time `json:"accessIssued,omitempty"` + Audience *string `json:"audience,omitempty"` + AuthorizationId *uuid.UUID `json:"authorizationId,omitempty"` + IdentityId *uuid.UUID `json:"identityId,omitempty"` + IsAccessUsed *bool `json:"isAccessUsed,omitempty"` + IsValid *bool `json:"isValid,omitempty"` + RedirectUri *string `json:"redirectUri,omitempty"` + RegistrationId *uuid.UUID `json:"registrationId,omitempty"` + Scopes *string `json:"scopes,omitempty"` + Source *string `json:"source,omitempty"` + ValidFrom *azuredevops.Time `json:"validFrom,omitempty"` + ValidTo *azuredevops.Time `json:"validTo,omitempty"` +} + +type AuthorizationDecision struct { + Authorization *Authorization `json:"authorization,omitempty"` + AuthorizationError *AuthorizationError `json:"authorizationError,omitempty"` + AuthorizationGrant *AuthorizationGrant `json:"authorizationGrant,omitempty"` + HasError *bool `json:"hasError,omitempty"` + IsAuthorized *bool `json:"isAuthorized,omitempty"` +} + +type AuthorizationDescription struct { + ClientRegistration *Registration `json:"clientRegistration,omitempty"` + HasError *bool `json:"hasError,omitempty"` + InitiationError *InitiationError `json:"initiationError,omitempty"` + ScopeDescriptions *[]AuthorizationScopeDescription `json:"scopeDescriptions,omitempty"` +} + +type AuthorizationDetails struct { + Authorization *Authorization `json:"authorization,omitempty"` + ClientRegistration *Registration `json:"clientRegistration,omitempty"` + ScopeDescriptions *[]AuthorizationScopeDescription `json:"scopeDescriptions,omitempty"` +} + +type AuthorizationError string + +type authorizationErrorValuesType struct { + None AuthorizationError + ClientIdRequired AuthorizationError + InvalidClientId AuthorizationError + ResponseTypeRequired AuthorizationError + ResponseTypeNotSupported AuthorizationError + ScopeRequired AuthorizationError + InvalidScope AuthorizationError + RedirectUriRequired AuthorizationError + InsecureRedirectUri AuthorizationError + InvalidRedirectUri AuthorizationError + InvalidUserId AuthorizationError + InvalidUserType AuthorizationError + AccessDenied AuthorizationError +} + +var AuthorizationErrorValues = authorizationErrorValuesType{ + None: "none", + ClientIdRequired: "clientIdRequired", + InvalidClientId: "invalidClientId", + ResponseTypeRequired: "responseTypeRequired", + ResponseTypeNotSupported: "responseTypeNotSupported", + ScopeRequired: "scopeRequired", + InvalidScope: "invalidScope", + RedirectUriRequired: "redirectUriRequired", + InsecureRedirectUri: "insecureRedirectUri", + InvalidRedirectUri: "invalidRedirectUri", + InvalidUserId: "invalidUserId", + InvalidUserType: "invalidUserType", + AccessDenied: "accessDenied", +} + +type AuthorizationGrant struct { + GrantType *GrantType `json:"grantType,omitempty"` +} + +type AuthorizationScopeDescription struct { + Description *string `json:"description,omitempty"` + Market *string `json:"market,omitempty"` + Title *string `json:"title,omitempty"` +} + +type ClientType string + +type clientTypeValuesType struct { + Confidential ClientType + Public ClientType + MediumTrust ClientType + HighTrust ClientType + FullTrust ClientType +} + +var ClientTypeValues = clientTypeValuesType{ + Confidential: "confidential", + Public: "public", + MediumTrust: "mediumTrust", + HighTrust: "highTrust", + FullTrust: "fullTrust", +} + +type GrantType string + +type grantTypeValuesType struct { + None GrantType + JwtBearer GrantType + RefreshToken GrantType + Implicit GrantType + ClientCredentials GrantType +} + +var GrantTypeValues = grantTypeValuesType{ + None: "none", + JwtBearer: "jwtBearer", + RefreshToken: "refreshToken", + Implicit: "implicit", + ClientCredentials: "clientCredentials", +} + +type HostAuthorization struct { + HostId *uuid.UUID `json:"hostId,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsValid *bool `json:"isValid,omitempty"` + RegistrationId *uuid.UUID `json:"registrationId,omitempty"` +} + +type HostAuthorizationDecision struct { + HasError *bool `json:"hasError,omitempty"` + HostAuthorizationError *HostAuthorizationError `json:"hostAuthorizationError,omitempty"` + HostAuthorizationId *uuid.UUID `json:"hostAuthorizationId,omitempty"` +} + +type HostAuthorizationError string + +type hostAuthorizationErrorValuesType struct { + None HostAuthorizationError + ClientIdRequired HostAuthorizationError + AccessDenied HostAuthorizationError + FailedToAuthorizeHost HostAuthorizationError + ClientIdNotFound HostAuthorizationError + InvalidClientId HostAuthorizationError +} + +var HostAuthorizationErrorValues = hostAuthorizationErrorValuesType{ + None: "none", + ClientIdRequired: "clientIdRequired", + AccessDenied: "accessDenied", + FailedToAuthorizeHost: "failedToAuthorizeHost", + ClientIdNotFound: "clientIdNotFound", + InvalidClientId: "invalidClientId", +} + +type InitiationError string + +type initiationErrorValuesType struct { + None InitiationError + ClientIdRequired InitiationError + InvalidClientId InitiationError + ResponseTypeRequired InitiationError + ResponseTypeNotSupported InitiationError + ScopeRequired InitiationError + InvalidScope InitiationError + RedirectUriRequired InitiationError + InsecureRedirectUri InitiationError + InvalidRedirectUri InitiationError +} + +var InitiationErrorValues = initiationErrorValuesType{ + None: "none", + ClientIdRequired: "clientIdRequired", + InvalidClientId: "invalidClientId", + ResponseTypeRequired: "responseTypeRequired", + ResponseTypeNotSupported: "responseTypeNotSupported", + ScopeRequired: "scopeRequired", + InvalidScope: "invalidScope", + RedirectUriRequired: "redirectUriRequired", + InsecureRedirectUri: "insecureRedirectUri", + InvalidRedirectUri: "invalidRedirectUri", +} + +type RefreshTokenGrant struct { + GrantType *GrantType `json:"grantType,omitempty"` + Jwt *webapi.JsonWebToken `json:"jwt,omitempty"` +} + +type Registration struct { + ClientType *ClientType `json:"clientType,omitempty"` + IdentityId *uuid.UUID `json:"identityId,omitempty"` + Issuer *string `json:"issuer,omitempty"` + IsValid *bool `json:"isValid,omitempty"` + IsWellKnown *bool `json:"isWellKnown,omitempty"` + OrganizationLocation *string `json:"organizationLocation,omitempty"` + OrganizationName *string `json:"organizationName,omitempty"` + // Raw cert data string from public key. This will be used for authenticating medium trust clients. + PublicKey *string `json:"publicKey,omitempty"` + RedirectUris *[]string `json:"redirectUris,omitempty"` + RegistrationDescription *string `json:"registrationDescription,omitempty"` + RegistrationId *uuid.UUID `json:"registrationId,omitempty"` + RegistrationLocation *string `json:"registrationLocation,omitempty"` + RegistrationLogoSecureLocation *string `json:"registrationLogoSecureLocation,omitempty"` + RegistrationName *string `json:"registrationName,omitempty"` + RegistrationPrivacyStatementLocation *string `json:"registrationPrivacyStatementLocation,omitempty"` + RegistrationTermsOfServiceLocation *string `json:"registrationTermsOfServiceLocation,omitempty"` + ResponseTypes *string `json:"responseTypes,omitempty"` + Scopes *string `json:"scopes,omitempty"` + Secret *string `json:"secret,omitempty"` + SecretValidTo *azuredevops.Time `json:"secretValidTo,omitempty"` + SecretVersionId *uuid.UUID `json:"secretVersionId,omitempty"` + ValidFrom *azuredevops.Time `json:"validFrom,omitempty"` +} + +type ResponseType string + +type responseTypeValuesType struct { + None ResponseType + Assertion ResponseType + IdToken ResponseType + TenantPicker ResponseType + SignoutToken ResponseType + AppToken ResponseType + Code ResponseType +} + +var ResponseTypeValues = responseTypeValuesType{ + None: "none", + Assertion: "assertion", + IdToken: "idToken", + TenantPicker: "tenantPicker", + SignoutToken: "signoutToken", + AppToken: "appToken", + Code: "code", +} + +type SessionToken struct { + AccessId *uuid.UUID `json:"accessId,omitempty"` + // This is populated when user requests a compact token. The alternate token value is self describing token. + AlternateToken *string `json:"alternateToken,omitempty"` + AuthorizationId *uuid.UUID `json:"authorizationId,omitempty"` + Claims *map[string]string `json:"claims,omitempty"` + ClientId *uuid.UUID `json:"clientId,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + HostAuthorizationId *uuid.UUID `json:"hostAuthorizationId,omitempty"` + IsPublic *bool `json:"isPublic,omitempty"` + IsValid *bool `json:"isValid,omitempty"` + PublicData *string `json:"publicData,omitempty"` + Scope *string `json:"scope,omitempty"` + Source *string `json:"source,omitempty"` + TargetAccounts *[]uuid.UUID `json:"targetAccounts,omitempty"` + // This is computed and not returned in Get queries + Token *string `json:"token,omitempty"` + UserId *uuid.UUID `json:"userId,omitempty"` + ValidFrom *azuredevops.Time `json:"validFrom,omitempty"` + ValidTo *azuredevops.Time `json:"validTo,omitempty"` +} + +type TokenError string + +type tokenErrorValuesType struct { + None TokenError + GrantTypeRequired TokenError + AuthorizationGrantRequired TokenError + ClientSecretRequired TokenError + RedirectUriRequired TokenError + InvalidAuthorizationGrant TokenError + InvalidAuthorizationScopes TokenError + InvalidRefreshToken TokenError + AuthorizationNotFound TokenError + AuthorizationGrantExpired TokenError + AccessAlreadyIssued TokenError + InvalidRedirectUri TokenError + AccessTokenNotFound TokenError + InvalidAccessToken TokenError + AccessTokenAlreadyRefreshed TokenError + InvalidClientSecret TokenError + ClientSecretExpired TokenError + ServerError TokenError + AccessDenied TokenError + AccessTokenKeyRequired TokenError + InvalidAccessTokenKey TokenError + FailedToGetAccessToken TokenError + InvalidClientId TokenError + InvalidClient TokenError + InvalidValidTo TokenError + InvalidUserId TokenError + FailedToIssueAccessToken TokenError + AuthorizationGrantScopeMissing TokenError + InvalidPublicAccessTokenKey TokenError + InvalidPublicAccessToken TokenError + PublicFeatureFlagNotEnabled TokenError + SshPolicyDisabled TokenError +} + +var TokenErrorValues = tokenErrorValuesType{ + None: "none", + GrantTypeRequired: "grantTypeRequired", + AuthorizationGrantRequired: "authorizationGrantRequired", + ClientSecretRequired: "clientSecretRequired", + RedirectUriRequired: "redirectUriRequired", + InvalidAuthorizationGrant: "invalidAuthorizationGrant", + InvalidAuthorizationScopes: "invalidAuthorizationScopes", + InvalidRefreshToken: "invalidRefreshToken", + AuthorizationNotFound: "authorizationNotFound", + AuthorizationGrantExpired: "authorizationGrantExpired", + AccessAlreadyIssued: "accessAlreadyIssued", + InvalidRedirectUri: "invalidRedirectUri", + AccessTokenNotFound: "accessTokenNotFound", + InvalidAccessToken: "invalidAccessToken", + AccessTokenAlreadyRefreshed: "accessTokenAlreadyRefreshed", + InvalidClientSecret: "invalidClientSecret", + ClientSecretExpired: "clientSecretExpired", + ServerError: "serverError", + AccessDenied: "accessDenied", + AccessTokenKeyRequired: "accessTokenKeyRequired", + InvalidAccessTokenKey: "invalidAccessTokenKey", + FailedToGetAccessToken: "failedToGetAccessToken", + InvalidClientId: "invalidClientId", + InvalidClient: "invalidClient", + InvalidValidTo: "invalidValidTo", + InvalidUserId: "invalidUserId", + FailedToIssueAccessToken: "failedToIssueAccessToken", + AuthorizationGrantScopeMissing: "authorizationGrantScopeMissing", + InvalidPublicAccessTokenKey: "invalidPublicAccessTokenKey", + InvalidPublicAccessToken: "invalidPublicAccessToken", + PublicFeatureFlagNotEnabled: "publicFeatureFlagNotEnabled", + SshPolicyDisabled: "sshPolicyDisabled", +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/errors.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/errors.go new file mode 100644 index 0000000000..e7cf6a377a --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/errors.go @@ -0,0 +1,17 @@ +package azuredevops + +type ArgumentNilError struct { + ArgumentName string +} + +func (e ArgumentNilError) Error() string { + return "Argument " + e.ArgumentName + " can not be nil" +} + +type ArgumentNilOrEmptyError struct { + ArgumentName string +} + +func (e ArgumentNilOrEmptyError) Error() string { + return "Argument " + e.ArgumentName + " can not be nil or empty" +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/git/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/git/client.go new file mode 100644 index 0000000000..7321f90302 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/git/client.go @@ -0,0 +1,5702 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package git + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/core" + "github.com/microsoft/azure-devops-go-api/azuredevops/policy" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "io" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("4e080c62-fa21-4fbc-8fef-2a10a2b38049") + +type Client interface { + // [Preview API] Create an annotated tag. + CreateAnnotatedTag(context.Context, CreateAnnotatedTagArgs) (*GitAnnotatedTag, error) + // [Preview API] Attach a new file to a pull request. + CreateAttachment(context.Context, CreateAttachmentArgs) (*Attachment, error) + // [Preview API] Cherry pick a specific commit or commits that are associated to a pull request into a new branch. + CreateCherryPick(context.Context, CreateCherryPickArgs) (*GitCherryPick, error) + // Create a comment on a specific thread in a pull request (up to 500 comments can be created per thread). + CreateComment(context.Context, CreateCommentArgs) (*Comment, error) + // Create Git commit status. + CreateCommitStatus(context.Context, CreateCommitStatusArgs) (*GitStatus, error) + // [Preview API] Creates a ref favorite + CreateFavorite(context.Context, CreateFavoriteArgs) (*GitRefFavorite, error) + // [Preview API] Request that another repository's refs be fetched into this one. It syncs two existing forks. To create a fork, please see the repositories endpoint + CreateForkSyncRequest(context.Context, CreateForkSyncRequestArgs) (*GitForkSyncRequest, error) + // [Preview API] Create an import request. + CreateImportRequest(context.Context, CreateImportRequestArgs) (*GitImportRequest, error) + // [Preview API] Add a like on a comment. + CreateLike(context.Context, CreateLikeArgs) error + // [Preview API] Request a git merge operation. Currently we support merging only 2 commits. + CreateMergeRequest(context.Context, CreateMergeRequestArgs) (*GitMerge, error) + // Create a pull request. + CreatePullRequest(context.Context, CreatePullRequestArgs) (*GitPullRequest, error) + // [Preview API] Create a pull request status on the iteration. This operation will have the same result as Create status on pull request with specified iteration ID in the request body. + CreatePullRequestIterationStatus(context.Context, CreatePullRequestIterationStatusArgs) (*GitPullRequestStatus, error) + // [Preview API] Create a label for a specified pull request. The only required field is the name of the new label. + CreatePullRequestLabel(context.Context, CreatePullRequestLabelArgs) (*core.WebApiTagDefinition, error) + // Add a reviewer to a pull request or cast a vote. + CreatePullRequestReviewer(context.Context, CreatePullRequestReviewerArgs) (*IdentityRefWithVote, error) + // Add reviewers to a pull request. + CreatePullRequestReviewers(context.Context, CreatePullRequestReviewersArgs) (*[]IdentityRefWithVote, error) + // [Preview API] Create a pull request status. + CreatePullRequestStatus(context.Context, CreatePullRequestStatusArgs) (*GitPullRequestStatus, error) + // Push changes to the repository. + CreatePush(context.Context, CreatePushArgs) (*GitPush, error) + // Create a git repository in a team project. + CreateRepository(context.Context, CreateRepositoryArgs) (*GitRepository, error) + // [Preview API] Starts the operation to create a new branch which reverts changes introduced by either a specific commit or commits that are associated to a pull request. + CreateRevert(context.Context, CreateRevertArgs) (*GitRevert, error) + // Create a thread in a pull request. + CreateThread(context.Context, CreateThreadArgs) (*GitPullRequestCommentThread, error) + // [Preview API] Delete a pull request attachment. + DeleteAttachment(context.Context, DeleteAttachmentArgs) error + // Delete a comment associated with a specific thread in a pull request. + DeleteComment(context.Context, DeleteCommentArgs) error + // [Preview API] Delete a like on a comment. + DeleteLike(context.Context, DeleteLikeArgs) error + // [Preview API] Delete pull request iteration status. + DeletePullRequestIterationStatus(context.Context, DeletePullRequestIterationStatusArgs) error + // [Preview API] Removes a label from the set of those assigned to the pull request. + DeletePullRequestLabels(context.Context, DeletePullRequestLabelsArgs) error + // Remove a reviewer from a pull request. + DeletePullRequestReviewer(context.Context, DeletePullRequestReviewerArgs) error + // [Preview API] Delete pull request status. + DeletePullRequestStatus(context.Context, DeletePullRequestStatusArgs) error + // [Preview API] Deletes the refs favorite specified + DeleteRefFavorite(context.Context, DeleteRefFavoriteArgs) error + // Delete a git repository + DeleteRepository(context.Context, DeleteRepositoryArgs) error + // [Preview API] Destroy (hard delete) a soft-deleted Git repository. + DeleteRepositoryFromRecycleBin(context.Context, DeleteRepositoryFromRecycleBinArgs) error + // [Preview API] Get an annotated tag. + GetAnnotatedTag(context.Context, GetAnnotatedTagArgs) (*GitAnnotatedTag, error) + // [Preview API] Get the file content of a pull request attachment. + GetAttachmentContent(context.Context, GetAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] Get a list of files attached to a given pull request. + GetAttachments(context.Context, GetAttachmentsArgs) (*[]Attachment, error) + // [Preview API] Get the file content of a pull request attachment. + GetAttachmentZip(context.Context, GetAttachmentZipArgs) (io.ReadCloser, error) + // Get a single blob. + GetBlob(context.Context, GetBlobArgs) (*GitBlobRef, error) + // Get a single blob. + GetBlobContent(context.Context, GetBlobContentArgs) (io.ReadCloser, error) + // Gets one or more blobs in a zip file download. + GetBlobsZip(context.Context, GetBlobsZipArgs) (io.ReadCloser, error) + // Get a single blob. + GetBlobZip(context.Context, GetBlobZipArgs) (io.ReadCloser, error) + // Retrieve statistics about a single branch. + GetBranch(context.Context, GetBranchArgs) (*GitBranchStats, error) + // Retrieve statistics about all branches within a repository. + GetBranches(context.Context, GetBranchesArgs) (*[]GitBranchStats, error) + // Retrieve changes for a particular commit. + GetChanges(context.Context, GetChangesArgs) (*GitCommitChanges, error) + // [Preview API] Retrieve information about a cherry pick by cherry pick Id. + GetCherryPick(context.Context, GetCherryPickArgs) (*GitCherryPick, error) + // [Preview API] Retrieve information about a cherry pick for a specific branch. + GetCherryPickForRefName(context.Context, GetCherryPickForRefNameArgs) (*GitCherryPick, error) + // Retrieve a comment associated with a specific thread in a pull request. + GetComment(context.Context, GetCommentArgs) (*Comment, error) + // Retrieve all comments associated with a specific thread in a pull request. + GetComments(context.Context, GetCommentsArgs) (*[]Comment, error) + // Retrieve a particular commit. + GetCommit(context.Context, GetCommitArgs) (*GitCommit, error) + // Find the closest common commit (the merge base) between base and target commits, and get the diff between either the base and target commits or common and target commits. + GetCommitDiffs(context.Context, GetCommitDiffsArgs) (*GitCommitDiffs, error) + // Retrieve git commits for a project + GetCommits(context.Context, GetCommitsArgs) (*[]GitCommitRef, error) + // Retrieve git commits for a project matching the search criteria + GetCommitsBatch(context.Context, GetCommitsBatchArgs) (*[]GitCommitRef, error) + // [Preview API] Retrieve deleted git repositories. + GetDeletedRepositories(context.Context, GetDeletedRepositoriesArgs) (*[]GitDeletedRepository, error) + // [Preview API] Retrieve all forks of a repository in the collection. + GetForks(context.Context, GetForksArgs) (*[]GitRepositoryRef, error) + // [Preview API] Get a specific fork sync operation's details. + GetForkSyncRequest(context.Context, GetForkSyncRequestArgs) (*GitForkSyncRequest, error) + // [Preview API] Retrieve all requested fork sync operations on this repository. + GetForkSyncRequests(context.Context, GetForkSyncRequestsArgs) (*[]GitForkSyncRequest, error) + // [Preview API] Retrieve a particular import request. + GetImportRequest(context.Context, GetImportRequestArgs) (*GitImportRequest, error) + // Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. + GetItem(context.Context, GetItemArgs) (*GitItem, error) + // Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. + GetItemContent(context.Context, GetItemContentArgs) (io.ReadCloser, error) + // Get Item Metadata and/or Content for a collection of items. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download. + GetItems(context.Context, GetItemsArgs) (*[]GitItem, error) + // Post for retrieving a creating a batch out of a set of items in a repo / project given a list of paths or a long path + GetItemsBatch(context.Context, GetItemsBatchArgs) (*[][]GitItem, error) + // Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. + GetItemText(context.Context, GetItemTextArgs) (io.ReadCloser, error) + // Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. + GetItemZip(context.Context, GetItemZipArgs) (io.ReadCloser, error) + // [Preview API] Get likes for a comment. + GetLikes(context.Context, GetLikesArgs) (*[]webapi.IdentityRef, error) + // [Preview API] Find the merge bases of two commits, optionally across forks. If otherRepositoryId is not specified, the merge bases will only be calculated within the context of the local repositoryNameOrId. + GetMergeBases(context.Context, GetMergeBasesArgs) (*[]GitCommitRef, error) + // [Preview API] Get a specific merge operation's details. + GetMergeRequest(context.Context, GetMergeRequestArgs) (*GitMerge, error) + // [Preview API] Retrieve a list of policy configurations by a given set of scope/filtering criteria. + GetPolicyConfigurations(context.Context, GetPolicyConfigurationsArgs) (*GitPolicyConfigurationResponse, error) + // Retrieve a pull request. + GetPullRequest(context.Context, GetPullRequestArgs) (*GitPullRequest, error) + // Retrieve a pull request. + GetPullRequestById(context.Context, GetPullRequestByIdArgs) (*GitPullRequest, error) + // Get the commits for the specified pull request. + GetPullRequestCommits(context.Context, GetPullRequestCommitsArgs) (*GetPullRequestCommitsResponseValue, error) + // Get the specified iteration for a pull request. + GetPullRequestIteration(context.Context, GetPullRequestIterationArgs) (*GitPullRequestIteration, error) + // Retrieve the changes made in a pull request between two iterations. + GetPullRequestIterationChanges(context.Context, GetPullRequestIterationChangesArgs) (*GitPullRequestIterationChanges, error) + // Get the commits for the specified iteration of a pull request. + GetPullRequestIterationCommits(context.Context, GetPullRequestIterationCommitsArgs) (*[]GitCommitRef, error) + // Get the list of iterations for the specified pull request. + GetPullRequestIterations(context.Context, GetPullRequestIterationsArgs) (*[]GitPullRequestIteration, error) + // [Preview API] Get the specific pull request iteration status by ID. The status ID is unique within the pull request across all iterations. + GetPullRequestIterationStatus(context.Context, GetPullRequestIterationStatusArgs) (*GitPullRequestStatus, error) + // [Preview API] Get all the statuses associated with a pull request iteration. + GetPullRequestIterationStatuses(context.Context, GetPullRequestIterationStatusesArgs) (*[]GitPullRequestStatus, error) + // [Preview API] Retrieves a single label that has been assigned to a pull request. + GetPullRequestLabel(context.Context, GetPullRequestLabelArgs) (*core.WebApiTagDefinition, error) + // [Preview API] Get all the labels assigned to a pull request. + GetPullRequestLabels(context.Context, GetPullRequestLabelsArgs) (*[]core.WebApiTagDefinition, error) + // [Preview API] Get external properties of the pull request. + GetPullRequestProperties(context.Context, GetPullRequestPropertiesArgs) (interface{}, error) + // This API is used to find what pull requests are related to a given commit. It can be used to either find the pull request that created a particular merge commit or it can be used to find all pull requests that have ever merged a particular commit. The input is a list of queries which each contain a list of commits. For each commit that you search against, you will get back a dictionary of commit -> pull requests. + GetPullRequestQuery(context.Context, GetPullRequestQueryArgs) (*GitPullRequestQuery, error) + // Retrieve information about a particular reviewer on a pull request + GetPullRequestReviewer(context.Context, GetPullRequestReviewerArgs) (*IdentityRefWithVote, error) + // Retrieve the reviewers for a pull request + GetPullRequestReviewers(context.Context, GetPullRequestReviewersArgs) (*[]IdentityRefWithVote, error) + // Retrieve all pull requests matching a specified criteria. + GetPullRequests(context.Context, GetPullRequestsArgs) (*[]GitPullRequest, error) + // Retrieve all pull requests matching a specified criteria. + GetPullRequestsByProject(context.Context, GetPullRequestsByProjectArgs) (*[]GitPullRequest, error) + // [Preview API] Get the specific pull request status by ID. The status ID is unique within the pull request across all iterations. + GetPullRequestStatus(context.Context, GetPullRequestStatusArgs) (*GitPullRequestStatus, error) + // [Preview API] Get all the statuses associated with a pull request. + GetPullRequestStatuses(context.Context, GetPullRequestStatusesArgs) (*[]GitPullRequestStatus, error) + // Retrieve a thread in a pull request. + GetPullRequestThread(context.Context, GetPullRequestThreadArgs) (*GitPullRequestCommentThread, error) + // Retrieve a list of work items associated with a pull request. + GetPullRequestWorkItemRefs(context.Context, GetPullRequestWorkItemRefsArgs) (*[]webapi.ResourceRef, error) + // Retrieves a particular push. + GetPush(context.Context, GetPushArgs) (*GitPush, error) + // Retrieve a list of commits associated with a particular push. + GetPushCommits(context.Context, GetPushCommitsArgs) (*[]GitCommitRef, error) + // Retrieves pushes associated with the specified repository. + GetPushes(context.Context, GetPushesArgs) (*[]GitPush, error) + // [Preview API] Retrieve soft-deleted git repositories from the recycle bin. + GetRecycleBinRepositories(context.Context, GetRecycleBinRepositoriesArgs) (*[]GitDeletedRepository, error) + // [Preview API] Gets the refs favorite for a favorite Id. + GetRefFavorite(context.Context, GetRefFavoriteArgs) (*GitRefFavorite, error) + // [Preview API] Gets the refs favorites for a repo and an identity. + GetRefFavorites(context.Context, GetRefFavoritesArgs) (*[]GitRefFavorite, error) + // Queries the provided repository for its refs and returns them. + GetRefs(context.Context, GetRefsArgs) (*GetRefsResponseValue, error) + // Retrieve git repositories. + GetRepositories(context.Context, GetRepositoriesArgs) (*[]GitRepository, error) + // Retrieve a git repository. + GetRepository(context.Context, GetRepositoryArgs) (*GitRepository, error) + // Retrieve a git repository. + GetRepositoryWithParent(context.Context, GetRepositoryWithParentArgs) (*GitRepository, error) + // [Preview API] Retrieve information about a revert operation by revert Id. + GetRevert(context.Context, GetRevertArgs) (*GitRevert, error) + // [Preview API] Retrieve information about a revert operation for a specific branch. + GetRevertForRefName(context.Context, GetRevertForRefNameArgs) (*GitRevert, error) + // Get statuses associated with the Git commit. + GetStatuses(context.Context, GetStatusesArgs) (*[]GitStatus, error) + // [Preview API] Retrieve a pull request suggestion for a particular repository or team project. + GetSuggestions(context.Context, GetSuggestionsArgs) (*[]GitSuggestion, error) + // Retrieve all threads in a pull request. + GetThreads(context.Context, GetThreadsArgs) (*[]GitPullRequestCommentThread, error) + // The Tree endpoint returns the collection of objects underneath the specified tree. Trees are folders in a Git repository. + GetTree(context.Context, GetTreeArgs) (*GitTreeRef, error) + // The Tree endpoint returns the collection of objects underneath the specified tree. Trees are folders in a Git repository. + GetTreeZip(context.Context, GetTreeZipArgs) (io.ReadCloser, error) + // [Preview API] Retrieve import requests for a repository. + QueryImportRequests(context.Context, QueryImportRequestsArgs) (*[]GitImportRequest, error) + // [Preview API] 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. + RestoreRepositoryFromRecycleBin(context.Context, RestoreRepositoryFromRecycleBinArgs) (*GitRepository, error) + // [Preview API] Sends an e-mail notification about a specific pull request to a set of recipients + SharePullRequest(context.Context, SharePullRequestArgs) error + // Update a comment associated with a specific thread in a pull request. + UpdateComment(context.Context, UpdateCommentArgs) (*Comment, error) + // [Preview API] Retry or abandon a failed import request. + UpdateImportRequest(context.Context, UpdateImportRequestArgs) (*GitImportRequest, error) + // Update a pull request + UpdatePullRequest(context.Context, UpdatePullRequestArgs) (*GitPullRequest, error) + // [Preview API] Update pull request iteration statuses collection. The only supported operation type is `remove`. + UpdatePullRequestIterationStatuses(context.Context, UpdatePullRequestIterationStatusesArgs) error + // [Preview API] Create or update pull request external properties. The patch operation can be `add`, `replace` or `remove`. For `add` operation, the path can be empty. If the path is empty, the value must be a list of key value pairs. For `replace` operation, the path cannot be empty. If the path does not exist, the property will be added to the collection. For `remove` operation, the path cannot be empty. If the path does not exist, no action will be performed. + UpdatePullRequestProperties(context.Context, UpdatePullRequestPropertiesArgs) (interface{}, error) + // Reset the votes of multiple reviewers on a pull request. NOTE: This endpoint only supports updating votes, but does not support updating required reviewers (use policy) or display names. + UpdatePullRequestReviewers(context.Context, UpdatePullRequestReviewersArgs) error + // [Preview API] Update pull request statuses collection. The only supported operation type is `remove`. + UpdatePullRequestStatuses(context.Context, UpdatePullRequestStatusesArgs) error + // Lock or Unlock a branch. + UpdateRef(context.Context, UpdateRefArgs) (*GitRef, error) + // Creating, updating, or deleting refs(branches). + UpdateRefs(context.Context, UpdateRefsArgs) (*[]GitRefUpdateResult, error) + // Updates the Git repository with either a new repo name or a new default branch. + UpdateRepository(context.Context, UpdateRepositoryArgs) (*GitRepository, error) + // Update a thread in a pull request. + UpdateThread(context.Context, UpdateThreadArgs) (*GitPullRequestCommentThread, error) +} + +type ClientImpl struct { + Client azuredevops.Client +} + +func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { + client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) + if err != nil { + return nil, err + } + return &ClientImpl{ + Client: *client, + }, nil +} + +// [Preview API] Create an annotated tag. +func (client *ClientImpl) CreateAnnotatedTag(ctx context.Context, args CreateAnnotatedTagArgs) (*GitAnnotatedTag, error) { + if args.TagObject == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TagObject"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.TagObject) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("5e8a8081-3851-4626-b677-9891cc04102e") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitAnnotatedTag + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateAnnotatedTag function +type CreateAnnotatedTagArgs struct { + // (required) Object containing details of tag to be created. + TagObject *GitAnnotatedTag + // (required) Project ID or project name + Project *string + // (required) ID or name of the repository. + RepositoryId *string +} + +// [Preview API] Attach a new file to a pull request. +func (client *ClientImpl) CreateAttachment(ctx context.Context, args CreateAttachmentArgs) (*Attachment, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FileName == nil || *args.FileName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FileName"} + } + routeValues["fileName"] = *args.FileName + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("965d9361-878b-413b-a494-45d5b5fd8ab7") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Attachment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateAttachment function +type CreateAttachmentArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) The name of the file. + FileName *string + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Cherry pick a specific commit or commits that are associated to a pull request into a new branch. +func (client *ClientImpl) CreateCherryPick(ctx context.Context, args CreateCherryPickArgs) (*GitCherryPick, error) { + if args.CherryPickToCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CherryPickToCreate"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.CherryPickToCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("033bad68-9a14-43d1-90e0-59cb8856fef6") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitCherryPick + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateCherryPick function +type CreateCherryPickArgs struct { + // (required) + CherryPickToCreate *GitAsyncRefOperationParameters + // (required) Project ID or project name + Project *string + // (required) ID of the repository. + RepositoryId *string +} + +// Create a comment on a specific thread in a pull request (up to 500 comments can be created per thread). +func (client *ClientImpl) CreateComment(ctx context.Context, args CreateCommentArgs) (*Comment, error) { + if args.Comment == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Comment"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + + body, marshalErr := json.Marshal(*args.Comment) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("965a3ec7-5ed8-455a-bdcb-835a5ea7fe7b") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Comment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateComment function +type CreateCommentArgs struct { + // (required) The comment to create. Comments can be up to 150,000 characters. + Comment *Comment + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the thread that the desired comment is in. + ThreadId *int + // (optional) Project ID or project name + Project *string +} + +// Create Git commit status. +func (client *ClientImpl) CreateCommitStatus(ctx context.Context, args CreateCommitStatusArgs) (*GitStatus, error) { + if args.GitCommitStatusToCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GitCommitStatusToCreate"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.CommitId == nil || *args.CommitId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CommitId"} + } + routeValues["commitId"] = *args.CommitId + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.GitCommitStatusToCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("428dd4fb-fda5-4722-af02-9313b80305da") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitStatus + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateCommitStatus function +type CreateCommitStatusArgs struct { + // (required) Git commit status object to create. + GitCommitStatusToCreate *GitStatus + // (required) ID of the Git commit. + CommitId *string + // (required) ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Creates a ref favorite +func (client *ClientImpl) CreateFavorite(ctx context.Context, args CreateFavoriteArgs) (*GitRefFavorite, error) { + if args.Favorite == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Favorite"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + body, marshalErr := json.Marshal(*args.Favorite) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("876f70af-5792-485a-a1c7-d0a7b2f42bbb") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRefFavorite + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateFavorite function +type CreateFavoriteArgs struct { + // (required) The ref favorite to create. + Favorite *GitRefFavorite + // (required) Project ID or project name + Project *string +} + +// [Preview API] Request that another repository's refs be fetched into this one. It syncs two existing forks. To create a fork, please see the repositories endpoint +func (client *ClientImpl) CreateForkSyncRequest(ctx context.Context, args CreateForkSyncRequestArgs) (*GitForkSyncRequest, error) { + if args.SyncParams == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SyncParams"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryNameOrId == nil || *args.RepositoryNameOrId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryNameOrId"} + } + routeValues["repositoryNameOrId"] = *args.RepositoryNameOrId + + queryParams := url.Values{} + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + body, marshalErr := json.Marshal(*args.SyncParams) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1703f858-b9d1-46af-ab62-483e9e1055b5") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitForkSyncRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateForkSyncRequest function +type CreateForkSyncRequestArgs struct { + // (required) Source repository and ref mapping. + SyncParams *GitForkSyncRequestParameters + // (required) The name or ID of the repository. + RepositoryNameOrId *string + // (optional) Project ID or project name + Project *string + // (optional) True to include links + IncludeLinks *bool +} + +// [Preview API] Create an import request. +func (client *ClientImpl) CreateImportRequest(ctx context.Context, args CreateImportRequestArgs) (*GitImportRequest, error) { + if args.ImportRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ImportRequest"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.ImportRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("01828ddc-3600-4a41-8633-99b3a73a0eb3") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitImportRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateImportRequest function +type CreateImportRequestArgs struct { + // (required) The import request to create. + ImportRequest *GitImportRequest + // (required) Project ID or project name + Project *string + // (required) The name or ID of the repository. + RepositoryId *string +} + +// [Preview API] Add a like on a comment. +func (client *ClientImpl) CreateLike(ctx context.Context, args CreateLikeArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + if args.CommentId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("5f2e2851-1389-425b-a00b-fb2adb3ef31b") + _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the CreateLike function +type CreateLikeArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) The ID of the thread that contains the comment. + ThreadId *int + // (required) The ID of the comment. + CommentId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Request a git merge operation. Currently we support merging only 2 commits. +func (client *ClientImpl) CreateMergeRequest(ctx context.Context, args CreateMergeRequestArgs) (*GitMerge, error) { + if args.MergeParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.MergeParameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryNameOrId == nil || *args.RepositoryNameOrId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryNameOrId"} + } + routeValues["repositoryNameOrId"] = *args.RepositoryNameOrId + + queryParams := url.Values{} + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + body, marshalErr := json.Marshal(*args.MergeParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("985f7ae9-844f-4906-9897-7ef41516c0e2") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitMerge + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateMergeRequest function +type CreateMergeRequestArgs struct { + // (required) Parents commitIds and merge commit messsage. + MergeParameters *GitMergeParameters + // (required) Project ID or project name + Project *string + // (required) The name or ID of the repository. + RepositoryNameOrId *string + // (optional) True to include links + IncludeLinks *bool +} + +// Create a pull request. +func (client *ClientImpl) CreatePullRequest(ctx context.Context, args CreatePullRequestArgs) (*GitPullRequest, error) { + if args.GitPullRequestToCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GitPullRequestToCreate"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.SupportsIterations != nil { + queryParams.Add("supportsIterations", strconv.FormatBool(*args.SupportsIterations)) + } + body, marshalErr := json.Marshal(*args.GitPullRequestToCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("9946fd70-0d40-406e-b686-b4744cbbcc37") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePullRequest function +type CreatePullRequestArgs struct { + // (required) The pull request to create. + GitPullRequestToCreate *GitPullRequest + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) If true, subsequent pushes to the pull request will be individually reviewable. Set this to false for large pull requests for performance reasons if this functionality is not needed. + SupportsIterations *bool +} + +// [Preview API] Create a pull request status on the iteration. This operation will have the same result as Create status on pull request with specified iteration ID in the request body. +func (client *ClientImpl) CreatePullRequestIterationStatus(ctx context.Context, args CreatePullRequestIterationStatusArgs) (*GitPullRequestStatus, error) { + if args.Status == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Status"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + body, marshalErr := json.Marshal(*args.Status) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("75cf11c5-979f-4038-a76e-058a06adf2bf") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestStatus + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePullRequestIterationStatus function +type CreatePullRequestIterationStatusArgs struct { + // (required) Pull request status to create. + Status *GitPullRequestStatus + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request iteration. + IterationId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Create a label for a specified pull request. The only required field is the name of the new label. +func (client *ClientImpl) CreatePullRequestLabel(ctx context.Context, args CreatePullRequestLabelArgs) (*core.WebApiTagDefinition, error) { + if args.Label == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Label"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + queryParams := url.Values{} + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + body, marshalErr := json.Marshal(*args.Label) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f22387e3-984e-4c52-9c6d-fbb8f14c812d") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue core.WebApiTagDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePullRequestLabel function +type CreatePullRequestLabelArgs struct { + // (required) Label to assign to the pull request. + Label *core.WebApiCreateTagRequestData + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string + // (optional) Project ID or project name. + ProjectId *string +} + +// Add a reviewer to a pull request or cast a vote. +func (client *ClientImpl) CreatePullRequestReviewer(ctx context.Context, args CreatePullRequestReviewerArgs) (*IdentityRefWithVote, error) { + if args.Reviewer == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Reviewer"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ReviewerId == nil || *args.ReviewerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ReviewerId"} + } + routeValues["reviewerId"] = *args.ReviewerId + + body, marshalErr := json.Marshal(*args.Reviewer) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4b6702c7-aa35-4b89-9c96-b9abf6d3e540") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue IdentityRefWithVote + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePullRequestReviewer function +type CreatePullRequestReviewerArgs struct { + // (required) Reviewer's vote.
If the reviewer's ID is included here, it must match the reviewerID parameter.
Reviewers can set their own vote with this method. When adding other reviewers, vote must be set to zero. + Reviewer *IdentityRefWithVote + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the reviewer. + ReviewerId *string + // (optional) Project ID or project name + Project *string +} + +// Add reviewers to a pull request. +func (client *ClientImpl) CreatePullRequestReviewers(ctx context.Context, args CreatePullRequestReviewersArgs) (*[]IdentityRefWithVote, error) { + if args.Reviewers == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Reviewers"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.Reviewers) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4b6702c7-aa35-4b89-9c96-b9abf6d3e540") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []IdentityRefWithVote + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePullRequestReviewers function +type CreatePullRequestReviewersArgs struct { + // (required) Reviewers to add to the pull request. + Reviewers *[]webapi.IdentityRef + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Create a pull request status. +func (client *ClientImpl) CreatePullRequestStatus(ctx context.Context, args CreatePullRequestStatusArgs) (*GitPullRequestStatus, error) { + if args.Status == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Status"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.Status) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b5f6bb4f-8d1e-4d79-8d11-4c9172c99c35") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestStatus + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePullRequestStatus function +type CreatePullRequestStatusArgs struct { + // (required) Pull request status to create. + Status *GitPullRequestStatus + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Push changes to the repository. +func (client *ClientImpl) CreatePush(ctx context.Context, args CreatePushArgs) (*GitPush, error) { + if args.Push == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Push"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.Push) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ea98d07b-3c87-4971-8ede-a613694ffb55") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPush + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePush function +type CreatePushArgs struct { + // (required) + Push *GitPush + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string +} + +// Create a git repository in a team project. +func (client *ClientImpl) CreateRepository(ctx context.Context, args CreateRepositoryArgs) (*GitRepository, error) { + if args.GitRepositoryToCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GitRepositoryToCreate"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.SourceRef != nil { + queryParams.Add("sourceRef", *args.SourceRef) + } + body, marshalErr := json.Marshal(*args.GitRepositoryToCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("225f7195-f9c7-4d14-ab28-a83f7ff77e1f") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRepository + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateRepository function +type CreateRepositoryArgs struct { + // (required) Specify the repo name, team project and/or parent repository. Team project information can be omitted from gitRepositoryToCreate if the request is project-scoped (i.e., includes project Id). + GitRepositoryToCreate *GitRepositoryCreateOptions + // (optional) Project ID or project name + Project *string + // (optional) [optional] Specify the source refs to use while creating a fork repo + SourceRef *string +} + +// [Preview API] Starts the operation to create a new branch which reverts changes introduced by either a specific commit or commits that are associated to a pull request. +func (client *ClientImpl) CreateRevert(ctx context.Context, args CreateRevertArgs) (*GitRevert, error) { + if args.RevertToCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RevertToCreate"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.RevertToCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bc866058-5449-4715-9cf1-a510b6ff193c") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRevert + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateRevert function +type CreateRevertArgs struct { + // (required) + RevertToCreate *GitAsyncRefOperationParameters + // (required) Project ID or project name + Project *string + // (required) ID of the repository. + RepositoryId *string +} + +// Create a thread in a pull request. +func (client *ClientImpl) CreateThread(ctx context.Context, args CreateThreadArgs) (*GitPullRequestCommentThread, error) { + if args.CommentThread == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentThread"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.CommentThread) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ab6e2e5d-a0b7-4153-b64a-a4efe0d49449") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestCommentThread + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateThread function +type CreateThreadArgs struct { + // (required) The thread to create. Thread must contain at least one comment. + CommentThread *GitPullRequestCommentThread + // (required) Repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete a pull request attachment. +func (client *ClientImpl) DeleteAttachment(ctx context.Context, args DeleteAttachmentArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FileName == nil || *args.FileName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FileName"} + } + routeValues["fileName"] = *args.FileName + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("965d9361-878b-413b-a494-45d5b5fd8ab7") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteAttachment function +type DeleteAttachmentArgs struct { + // (required) The name of the attachment to delete. + FileName *string + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Delete a comment associated with a specific thread in a pull request. +func (client *ClientImpl) DeleteComment(ctx context.Context, args DeleteCommentArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + if args.CommentId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("965a3ec7-5ed8-455a-bdcb-835a5ea7fe7b") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteComment function +type DeleteCommentArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the thread that the desired comment is in. + ThreadId *int + // (required) ID of the comment. + CommentId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete a like on a comment. +func (client *ClientImpl) DeleteLike(ctx context.Context, args DeleteLikeArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + if args.CommentId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("5f2e2851-1389-425b-a00b-fb2adb3ef31b") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteLike function +type DeleteLikeArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) The ID of the thread that contains the comment. + ThreadId *int + // (required) The ID of the comment. + CommentId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete pull request iteration status. +func (client *ClientImpl) DeletePullRequestIterationStatus(ctx context.Context, args DeletePullRequestIterationStatusArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + if args.StatusId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.StatusId"} + } + routeValues["statusId"] = strconv.Itoa(*args.StatusId) + + locationId, _ := uuid.Parse("75cf11c5-979f-4038-a76e-058a06adf2bf") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeletePullRequestIterationStatus function +type DeletePullRequestIterationStatusArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request iteration. + IterationId *int + // (required) ID of the pull request status. + StatusId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Removes a label from the set of those assigned to the pull request. +func (client *ClientImpl) DeletePullRequestLabels(ctx context.Context, args DeletePullRequestLabelsArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.LabelIdOrName == nil || *args.LabelIdOrName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.LabelIdOrName"} + } + routeValues["labelIdOrName"] = *args.LabelIdOrName + + queryParams := url.Values{} + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + locationId, _ := uuid.Parse("f22387e3-984e-4c52-9c6d-fbb8f14c812d") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeletePullRequestLabels function +type DeletePullRequestLabelsArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) The name or ID of the label requested. + LabelIdOrName *string + // (optional) Project ID or project name + Project *string + // (optional) Project ID or project name. + ProjectId *string +} + +// Remove a reviewer from a pull request. +func (client *ClientImpl) DeletePullRequestReviewer(ctx context.Context, args DeletePullRequestReviewerArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ReviewerId == nil || *args.ReviewerId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ReviewerId"} + } + routeValues["reviewerId"] = *args.ReviewerId + + locationId, _ := uuid.Parse("4b6702c7-aa35-4b89-9c96-b9abf6d3e540") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeletePullRequestReviewer function +type DeletePullRequestReviewerArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the reviewer to remove. + ReviewerId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete pull request status. +func (client *ClientImpl) DeletePullRequestStatus(ctx context.Context, args DeletePullRequestStatusArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.StatusId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.StatusId"} + } + routeValues["statusId"] = strconv.Itoa(*args.StatusId) + + locationId, _ := uuid.Parse("b5f6bb4f-8d1e-4d79-8d11-4c9172c99c35") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeletePullRequestStatus function +type DeletePullRequestStatusArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request status. + StatusId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Deletes the refs favorite specified +func (client *ClientImpl) DeleteRefFavorite(ctx context.Context, args DeleteRefFavoriteArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.FavoriteId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.FavoriteId"} + } + routeValues["favoriteId"] = strconv.Itoa(*args.FavoriteId) + + locationId, _ := uuid.Parse("876f70af-5792-485a-a1c7-d0a7b2f42bbb") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteRefFavorite function +type DeleteRefFavoriteArgs struct { + // (required) Project ID or project name + Project *string + // (required) The Id of the ref favorite to delete. + FavoriteId *int +} + +// Delete a git repository +func (client *ClientImpl) DeleteRepository(ctx context.Context, args DeleteRepositoryArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = (*args.RepositoryId).String() + + locationId, _ := uuid.Parse("225f7195-f9c7-4d14-ab28-a83f7ff77e1f") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteRepository function +type DeleteRepositoryArgs struct { + // (required) The name or ID of the repository. + RepositoryId *uuid.UUID + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Destroy (hard delete) a soft-deleted Git repository. +func (client *ClientImpl) DeleteRepositoryFromRecycleBin(ctx context.Context, args DeleteRepositoryFromRecycleBinArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = (*args.RepositoryId).String() + + locationId, _ := uuid.Parse("a663da97-81db-4eb3-8b83-287670f63073") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteRepositoryFromRecycleBin function +type DeleteRepositoryFromRecycleBinArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the repository. + RepositoryId *uuid.UUID +} + +// [Preview API] Get an annotated tag. +func (client *ClientImpl) GetAnnotatedTag(ctx context.Context, args GetAnnotatedTagArgs) (*GitAnnotatedTag, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.ObjectId == nil || *args.ObjectId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ObjectId"} + } + routeValues["objectId"] = *args.ObjectId + + locationId, _ := uuid.Parse("5e8a8081-3851-4626-b677-9891cc04102e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitAnnotatedTag + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAnnotatedTag function +type GetAnnotatedTagArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID or name of the repository. + RepositoryId *string + // (required) ObjectId (Sha1Id) of tag to get. + ObjectId *string +} + +// [Preview API] Get the file content of a pull request attachment. +func (client *ClientImpl) GetAttachmentContent(ctx context.Context, args GetAttachmentContentArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FileName == nil || *args.FileName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FileName"} + } + routeValues["fileName"] = *args.FileName + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("965d9361-878b-413b-a494-45d5b5fd8ab7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAttachmentContent function +type GetAttachmentContentArgs struct { + // (required) The name of the attachment. + FileName *string + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get a list of files attached to a given pull request. +func (client *ClientImpl) GetAttachments(ctx context.Context, args GetAttachmentsArgs) (*[]Attachment, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("965d9361-878b-413b-a494-45d5b5fd8ab7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Attachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAttachments function +type GetAttachmentsArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get the file content of a pull request attachment. +func (client *ClientImpl) GetAttachmentZip(ctx context.Context, args GetAttachmentZipArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FileName == nil || *args.FileName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FileName"} + } + routeValues["fileName"] = *args.FileName + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("965d9361-878b-413b-a494-45d5b5fd8ab7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAttachmentZip function +type GetAttachmentZipArgs struct { + // (required) The name of the attachment. + FileName *string + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Get a single blob. +func (client *ClientImpl) GetBlob(ctx context.Context, args GetBlobArgs) (*GitBlobRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.Sha1 == nil || *args.Sha1 == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Sha1"} + } + routeValues["sha1"] = *args.Sha1 + + queryParams := url.Values{} + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.ResolveLfs != nil { + queryParams.Add("resolveLfs", strconv.FormatBool(*args.ResolveLfs)) + } + locationId, _ := uuid.Parse("7b28e929-2c99-405d-9c5c-6167a06e6816") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitBlobRef + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBlob function +type GetBlobArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint. + Sha1 *string + // (optional) Project ID or project name + Project *string + // (optional) If true, prompt for a download rather than rendering in a browser. Note: this value defaults to true if $format is zip + Download *bool + // (optional) Provide a fileName to use for a download. + FileName *string + // (optional) 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 + ResolveLfs *bool +} + +// Get a single blob. +func (client *ClientImpl) GetBlobContent(ctx context.Context, args GetBlobContentArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.Sha1 == nil || *args.Sha1 == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Sha1"} + } + routeValues["sha1"] = *args.Sha1 + + queryParams := url.Values{} + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.ResolveLfs != nil { + queryParams.Add("resolveLfs", strconv.FormatBool(*args.ResolveLfs)) + } + locationId, _ := uuid.Parse("7b28e929-2c99-405d-9c5c-6167a06e6816") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetBlobContent function +type GetBlobContentArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint. + Sha1 *string + // (optional) Project ID or project name + Project *string + // (optional) If true, prompt for a download rather than rendering in a browser. Note: this value defaults to true if $format is zip + Download *bool + // (optional) Provide a fileName to use for a download. + FileName *string + // (optional) 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 + ResolveLfs *bool +} + +// Gets one or more blobs in a zip file download. +func (client *ClientImpl) GetBlobsZip(ctx context.Context, args GetBlobsZipArgs) (io.ReadCloser, error) { + if args.BlobIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BlobIds"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Filename != nil { + queryParams.Add("filename", *args.Filename) + } + body, marshalErr := json.Marshal(*args.BlobIds) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("7b28e929-2c99-405d-9c5c-6167a06e6816") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetBlobsZip function +type GetBlobsZipArgs struct { + // (required) Blob IDs (SHA1 hashes) to be returned in the zip file. + BlobIds *[]string + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) + Filename *string +} + +// Get a single blob. +func (client *ClientImpl) GetBlobZip(ctx context.Context, args GetBlobZipArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.Sha1 == nil || *args.Sha1 == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Sha1"} + } + routeValues["sha1"] = *args.Sha1 + + queryParams := url.Values{} + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.ResolveLfs != nil { + queryParams.Add("resolveLfs", strconv.FormatBool(*args.ResolveLfs)) + } + locationId, _ := uuid.Parse("7b28e929-2c99-405d-9c5c-6167a06e6816") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetBlobZip function +type GetBlobZipArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) SHA1 hash of the file. You can get the SHA1 of a file using the "Git/Items/Get Item" endpoint. + Sha1 *string + // (optional) Project ID or project name + Project *string + // (optional) If true, prompt for a download rather than rendering in a browser. Note: this value defaults to true if $format is zip + Download *bool + // (optional) Provide a fileName to use for a download. + FileName *string + // (optional) 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 + ResolveLfs *bool +} + +// Retrieve statistics about a single branch. +func (client *ClientImpl) GetBranch(ctx context.Context, args GetBranchArgs) (*GitBranchStats, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Name == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "name"} + } + queryParams.Add("name", *args.Name) + if args.BaseVersionDescriptor != nil { + if args.BaseVersionDescriptor.VersionType != nil { + queryParams.Add("baseVersionDescriptor.versionType", string(*args.BaseVersionDescriptor.VersionType)) + } + if args.BaseVersionDescriptor.Version != nil { + queryParams.Add("baseVersionDescriptor.version", *args.BaseVersionDescriptor.Version) + } + if args.BaseVersionDescriptor.VersionOptions != nil { + queryParams.Add("baseVersionDescriptor.versionOptions", string(*args.BaseVersionDescriptor.VersionOptions)) + } + } + locationId, _ := uuid.Parse("d5b216de-d8d5-4d32-ae76-51df755b16d3") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitBranchStats + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBranch function +type GetBranchArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) Name of the branch. + Name *string + // (optional) Project ID or project name + Project *string + // (optional) Identifies the commit or branch to use as the base. + BaseVersionDescriptor *GitVersionDescriptor +} + +// Retrieve statistics about all branches within a repository. +func (client *ClientImpl) GetBranches(ctx context.Context, args GetBranchesArgs) (*[]GitBranchStats, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.BaseVersionDescriptor != nil { + if args.BaseVersionDescriptor.VersionType != nil { + queryParams.Add("baseVersionDescriptor.versionType", string(*args.BaseVersionDescriptor.VersionType)) + } + if args.BaseVersionDescriptor.Version != nil { + queryParams.Add("baseVersionDescriptor.version", *args.BaseVersionDescriptor.Version) + } + if args.BaseVersionDescriptor.VersionOptions != nil { + queryParams.Add("baseVersionDescriptor.versionOptions", string(*args.BaseVersionDescriptor.VersionOptions)) + } + } + locationId, _ := uuid.Parse("d5b216de-d8d5-4d32-ae76-51df755b16d3") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitBranchStats + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBranches function +type GetBranchesArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) Identifies the commit or branch to use as the base. + BaseVersionDescriptor *GitVersionDescriptor +} + +// Retrieve changes for a particular commit. +func (client *ClientImpl) GetChanges(ctx context.Context, args GetChangesArgs) (*GitCommitChanges, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.CommitId == nil || *args.CommitId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CommitId"} + } + routeValues["commitId"] = *args.CommitId + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("skip", strconv.Itoa(*args.Skip)) + } + locationId, _ := uuid.Parse("5bf884f5-3e07-42e9-afb8-1b872267bf16") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitCommitChanges + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetChanges function +type GetChangesArgs struct { + // (required) The id of the commit. + CommitId *string + // (required) The id or friendly name of the repository. To use the friendly name, projectId must also be specified. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) The maximum number of changes to return. + Top *int + // (optional) The number of changes to skip. + Skip *int +} + +// [Preview API] Retrieve information about a cherry pick by cherry pick Id. +func (client *ClientImpl) GetCherryPick(ctx context.Context, args GetCherryPickArgs) (*GitCherryPick, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.CherryPickId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CherryPickId"} + } + routeValues["cherryPickId"] = strconv.Itoa(*args.CherryPickId) + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + locationId, _ := uuid.Parse("033bad68-9a14-43d1-90e0-59cb8856fef6") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitCherryPick + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCherryPick function +type GetCherryPickArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the cherry pick. + CherryPickId *int + // (required) ID of the repository. + RepositoryId *string +} + +// [Preview API] Retrieve information about a cherry pick for a specific branch. +func (client *ClientImpl) GetCherryPickForRefName(ctx context.Context, args GetCherryPickForRefNameArgs) (*GitCherryPick, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.RefName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "refName"} + } + queryParams.Add("refName", *args.RefName) + locationId, _ := uuid.Parse("033bad68-9a14-43d1-90e0-59cb8856fef6") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitCherryPick + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCherryPickForRefName function +type GetCherryPickForRefNameArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the repository. + RepositoryId *string + // (required) The GitAsyncRefOperationParameters generatedRefName used for the cherry pick operation. + RefName *string +} + +// Retrieve a comment associated with a specific thread in a pull request. +func (client *ClientImpl) GetComment(ctx context.Context, args GetCommentArgs) (*Comment, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("965a3ec7-5ed8-455a-bdcb-835a5ea7fe7b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Comment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetComment function +type GetCommentArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the thread that the desired comment is in. + ThreadId *int + // (required) ID of the comment. + CommentId *int + // (optional) Project ID or project name + Project *string +} + +// Retrieve all comments associated with a specific thread in a pull request. +func (client *ClientImpl) GetComments(ctx context.Context, args GetCommentsArgs) (*[]Comment, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + + locationId, _ := uuid.Parse("965a3ec7-5ed8-455a-bdcb-835a5ea7fe7b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Comment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetComments function +type GetCommentsArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the thread. + ThreadId *int + // (optional) Project ID or project name + Project *string +} + +// Retrieve a particular commit. +func (client *ClientImpl) GetCommit(ctx context.Context, args GetCommitArgs) (*GitCommit, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.CommitId == nil || *args.CommitId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CommitId"} + } + routeValues["commitId"] = *args.CommitId + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.ChangeCount != nil { + queryParams.Add("changeCount", strconv.Itoa(*args.ChangeCount)) + } + locationId, _ := uuid.Parse("c2570c3b-5b3f-41b8-98bf-5407bfde8d58") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitCommit + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommit function +type GetCommitArgs struct { + // (required) The id of the commit. + CommitId *string + // (required) The id or friendly name of the repository. To use the friendly name, projectId must also be specified. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) The number of changes to include in the result. + ChangeCount *int +} + +// Find the closest common commit (the merge base) between base and target commits, and get the diff between either the base and target commits or common and target commits. +func (client *ClientImpl) GetCommitDiffs(ctx context.Context, args GetCommitDiffsArgs) (*GitCommitDiffs, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.DiffCommonCommit != nil { + queryParams.Add("diffCommonCommit", strconv.FormatBool(*args.DiffCommonCommit)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.BaseVersionDescriptor != nil { + if args.BaseVersionDescriptor.BaseVersionType != nil { + queryParams.Add("baseVersionType", string(*args.BaseVersionDescriptor.BaseVersionType)) + } + if args.BaseVersionDescriptor.BaseVersion != nil { + queryParams.Add("baseVersion", *args.BaseVersionDescriptor.BaseVersion) + } + if args.BaseVersionDescriptor.BaseVersionOptions != nil { + queryParams.Add("baseVersionOptions", string(*args.BaseVersionDescriptor.BaseVersionOptions)) + } + } + if args.TargetVersionDescriptor != nil { + if args.TargetVersionDescriptor.TargetVersionType != nil { + queryParams.Add("targetVersionType", string(*args.TargetVersionDescriptor.TargetVersionType)) + } + if args.TargetVersionDescriptor.TargetVersion != nil { + queryParams.Add("targetVersion", *args.TargetVersionDescriptor.TargetVersion) + } + if args.TargetVersionDescriptor.TargetVersionOptions != nil { + queryParams.Add("targetVersionOptions", string(*args.TargetVersionDescriptor.TargetVersionOptions)) + } + } + locationId, _ := uuid.Parse("615588d5-c0c7-4b88-88f8-e625306446e8") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitCommitDiffs + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommitDiffs function +type GetCommitDiffsArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) If true, diff between common and target commits. If false, diff between base and target commits. + DiffCommonCommit *bool + // (optional) Maximum number of changes to return. Defaults to 100. + Top *int + // (optional) Number of changes to skip + Skip *int + // (optional) Descriptor for base commit. + BaseVersionDescriptor *GitBaseVersionDescriptor + // (optional) Descriptor for target commit. + TargetVersionDescriptor *GitTargetVersionDescriptor +} + +// Retrieve git commits for a project +func (client *ClientImpl) GetCommits(ctx context.Context, args GetCommitsArgs) (*[]GitCommitRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.SearchCriteria == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "searchCriteria"} + } + if args.SearchCriteria.Ids != nil { + for index, item := range *args.SearchCriteria.Ids { + queryParams.Add("searchCriteria.ids["+strconv.Itoa(index)+"]", item) + } + } + if args.SearchCriteria.FromDate != nil { + queryParams.Add("searchCriteria.fromDate", *args.SearchCriteria.FromDate) + } + if args.SearchCriteria.ToDate != nil { + queryParams.Add("searchCriteria.toDate", *args.SearchCriteria.ToDate) + } + if args.SearchCriteria.ItemVersion != nil { + if args.SearchCriteria.ItemVersion.VersionType != nil { + queryParams.Add("searchCriteria.itemVersion.versionType", string(*args.SearchCriteria.ItemVersion.VersionType)) + } + if args.SearchCriteria.ItemVersion.Version != nil { + queryParams.Add("searchCriteria.itemVersion.version", *args.SearchCriteria.ItemVersion.Version) + } + if args.SearchCriteria.ItemVersion.VersionOptions != nil { + queryParams.Add("searchCriteria.itemVersion.versionOptions", string(*args.SearchCriteria.ItemVersion.VersionOptions)) + } + } + if args.SearchCriteria.CompareVersion != nil { + if args.SearchCriteria.CompareVersion.VersionType != nil { + queryParams.Add("searchCriteria.compareVersion.versionType", string(*args.SearchCriteria.CompareVersion.VersionType)) + } + if args.SearchCriteria.CompareVersion.Version != nil { + queryParams.Add("searchCriteria.compareVersion.version", *args.SearchCriteria.CompareVersion.Version) + } + if args.SearchCriteria.CompareVersion.VersionOptions != nil { + queryParams.Add("searchCriteria.compareVersion.versionOptions", string(*args.SearchCriteria.CompareVersion.VersionOptions)) + } + } + if args.SearchCriteria.FromCommitId != nil { + queryParams.Add("searchCriteria.fromCommitId", *args.SearchCriteria.FromCommitId) + } + if args.SearchCriteria.ToCommitId != nil { + queryParams.Add("searchCriteria.toCommitId", *args.SearchCriteria.ToCommitId) + } + if args.SearchCriteria.User != nil { + queryParams.Add("searchCriteria.user", *args.SearchCriteria.User) + } + if args.SearchCriteria.Author != nil { + queryParams.Add("searchCriteria.author", *args.SearchCriteria.Author) + } + if args.SearchCriteria.ItemPath != nil { + queryParams.Add("searchCriteria.itemPath", *args.SearchCriteria.ItemPath) + } + if args.SearchCriteria.ExcludeDeletes != nil { + queryParams.Add("searchCriteria.excludeDeletes", strconv.FormatBool(*args.SearchCriteria.ExcludeDeletes)) + } + if args.SearchCriteria.Skip != nil { + queryParams.Add("searchCriteria.$skip", strconv.Itoa(*args.SearchCriteria.Skip)) + } + if args.SearchCriteria.Top != nil { + queryParams.Add("searchCriteria.$top", strconv.Itoa(*args.SearchCriteria.Top)) + } + if args.SearchCriteria.IncludeLinks != nil { + queryParams.Add("searchCriteria.includeLinks", strconv.FormatBool(*args.SearchCriteria.IncludeLinks)) + } + if args.SearchCriteria.IncludeWorkItems != nil { + queryParams.Add("searchCriteria.includeWorkItems", strconv.FormatBool(*args.SearchCriteria.IncludeWorkItems)) + } + if args.SearchCriteria.IncludeUserImageUrl != nil { + queryParams.Add("searchCriteria.includeUserImageUrl", strconv.FormatBool(*args.SearchCriteria.IncludeUserImageUrl)) + } + if args.SearchCriteria.IncludePushData != nil { + queryParams.Add("searchCriteria.includePushData", strconv.FormatBool(*args.SearchCriteria.IncludePushData)) + } + if args.SearchCriteria.HistoryMode != nil { + queryParams.Add("searchCriteria.historyMode", string(*args.SearchCriteria.HistoryMode)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("c2570c3b-5b3f-41b8-98bf-5407bfde8d58") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitCommitRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommits function +type GetCommitsArgs struct { + // (required) The id or friendly name of the repository. To use the friendly name, projectId must also be specified. + RepositoryId *string + // (required) + SearchCriteria *GitQueryCommitsCriteria + // (optional) Project ID or project name + Project *string + // (optional) + Skip *int + // (optional) + Top *int +} + +// Retrieve git commits for a project matching the search criteria +func (client *ClientImpl) GetCommitsBatch(ctx context.Context, args GetCommitsBatchArgs) (*[]GitCommitRef, error) { + if args.SearchCriteria == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SearchCriteria"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.IncludeStatuses != nil { + queryParams.Add("includeStatuses", strconv.FormatBool(*args.IncludeStatuses)) + } + body, marshalErr := json.Marshal(*args.SearchCriteria) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6400dfb2-0bcb-462b-b992-5a57f8f1416c") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitCommitRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommitsBatch function +type GetCommitsBatchArgs struct { + // (required) Search options + SearchCriteria *GitQueryCommitsCriteria + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) Number of commits to skip. + Skip *int + // (optional) Maximum number of commits to return. + Top *int + // (optional) True to include additional commit status information. + IncludeStatuses *bool +} + +// [Preview API] Retrieve deleted git repositories. +func (client *ClientImpl) GetDeletedRepositories(ctx context.Context, args GetDeletedRepositoriesArgs) (*[]GitDeletedRepository, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + locationId, _ := uuid.Parse("2b6869c4-cb25-42b5-b7a3-0d3e6be0a11a") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitDeletedRepository + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDeletedRepositories function +type GetDeletedRepositoriesArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] Retrieve all forks of a repository in the collection. +func (client *ClientImpl) GetForks(ctx context.Context, args GetForksArgs) (*[]GitRepositoryRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryNameOrId == nil || *args.RepositoryNameOrId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryNameOrId"} + } + routeValues["repositoryNameOrId"] = *args.RepositoryNameOrId + if args.CollectionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CollectionId"} + } + routeValues["collectionId"] = (*args.CollectionId).String() + + queryParams := url.Values{} + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + locationId, _ := uuid.Parse("158c0340-bf6f-489c-9625-d572a1480d57") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitRepositoryRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetForks function +type GetForksArgs struct { + // (required) The name or ID of the repository. + RepositoryNameOrId *string + // (required) Team project collection ID. + CollectionId *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) True to include links. + IncludeLinks *bool +} + +// [Preview API] Get a specific fork sync operation's details. +func (client *ClientImpl) GetForkSyncRequest(ctx context.Context, args GetForkSyncRequestArgs) (*GitForkSyncRequest, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryNameOrId == nil || *args.RepositoryNameOrId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryNameOrId"} + } + routeValues["repositoryNameOrId"] = *args.RepositoryNameOrId + if args.ForkSyncOperationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ForkSyncOperationId"} + } + routeValues["forkSyncOperationId"] = strconv.Itoa(*args.ForkSyncOperationId) + + queryParams := url.Values{} + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + locationId, _ := uuid.Parse("1703f858-b9d1-46af-ab62-483e9e1055b5") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitForkSyncRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetForkSyncRequest function +type GetForkSyncRequestArgs struct { + // (required) The name or ID of the repository. + RepositoryNameOrId *string + // (required) OperationId of the sync request. + ForkSyncOperationId *int + // (optional) Project ID or project name + Project *string + // (optional) True to include links. + IncludeLinks *bool +} + +// [Preview API] Retrieve all requested fork sync operations on this repository. +func (client *ClientImpl) GetForkSyncRequests(ctx context.Context, args GetForkSyncRequestsArgs) (*[]GitForkSyncRequest, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryNameOrId == nil || *args.RepositoryNameOrId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryNameOrId"} + } + routeValues["repositoryNameOrId"] = *args.RepositoryNameOrId + + queryParams := url.Values{} + if args.IncludeAbandoned != nil { + queryParams.Add("includeAbandoned", strconv.FormatBool(*args.IncludeAbandoned)) + } + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + locationId, _ := uuid.Parse("1703f858-b9d1-46af-ab62-483e9e1055b5") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitForkSyncRequest + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetForkSyncRequests function +type GetForkSyncRequestsArgs struct { + // (required) The name or ID of the repository. + RepositoryNameOrId *string + // (optional) Project ID or project name + Project *string + // (optional) True to include abandoned requests. + IncludeAbandoned *bool + // (optional) True to include links. + IncludeLinks *bool +} + +// [Preview API] Retrieve a particular import request. +func (client *ClientImpl) GetImportRequest(ctx context.Context, args GetImportRequestArgs) (*GitImportRequest, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.ImportRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ImportRequestId"} + } + routeValues["importRequestId"] = strconv.Itoa(*args.ImportRequestId) + + locationId, _ := uuid.Parse("01828ddc-3600-4a41-8633-99b3a73a0eb3") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitImportRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetImportRequest function +type GetImportRequestArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name or ID of the repository. + RepositoryId *string + // (required) The unique identifier for the import request. + ImportRequestId *int +} + +// Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. +func (client *ClientImpl) GetItem(ctx context.Context, args GetItemArgs) (*GitItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContentMetadata != nil { + queryParams.Add("includeContentMetadata", strconv.FormatBool(*args.IncludeContentMetadata)) + } + if args.LatestProcessedChange != nil { + queryParams.Add("latestProcessedChange", strconv.FormatBool(*args.LatestProcessedChange)) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionType != nil { + queryParams.Add("versionDescriptor.versionType", string(*args.VersionDescriptor.VersionType)) + } + if args.VersionDescriptor.Version != nil { + queryParams.Add("versionDescriptor.version", *args.VersionDescriptor.Version) + } + if args.VersionDescriptor.VersionOptions != nil { + queryParams.Add("versionDescriptor.versionOptions", string(*args.VersionDescriptor.VersionOptions)) + } + } + if args.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + if args.ResolveLfs != nil { + queryParams.Add("resolveLfs", strconv.FormatBool(*args.ResolveLfs)) + } + locationId, _ := uuid.Parse("fb93c0db-47ed-4a31-8c20-47552878fb44") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetItem function +type GetItemArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) The item path. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) The path scope. The default is null. + ScopePath *string + // (optional) The recursion level of this request. The default is 'none', no recursion. + RecursionLevel *VersionControlRecursionType + // (optional) Set to true to include content metadata. Default is false. + IncludeContentMetadata *bool + // (optional) Set to true to include the latest changes. Default is false. + LatestProcessedChange *bool + // (optional) Set to true to download the response as a file. Default is false. + Download *bool + // (optional) Version descriptor. Default is the default branch for the repository. + VersionDescriptor *GitVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *bool + // (optional) Set to true to resolve Git LFS pointer files to return actual content from Git LFS. Default is false. + ResolveLfs *bool +} + +// Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. +func (client *ClientImpl) GetItemContent(ctx context.Context, args GetItemContentArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContentMetadata != nil { + queryParams.Add("includeContentMetadata", strconv.FormatBool(*args.IncludeContentMetadata)) + } + if args.LatestProcessedChange != nil { + queryParams.Add("latestProcessedChange", strconv.FormatBool(*args.LatestProcessedChange)) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionType != nil { + queryParams.Add("versionDescriptor.versionType", string(*args.VersionDescriptor.VersionType)) + } + if args.VersionDescriptor.Version != nil { + queryParams.Add("versionDescriptor.version", *args.VersionDescriptor.Version) + } + if args.VersionDescriptor.VersionOptions != nil { + queryParams.Add("versionDescriptor.versionOptions", string(*args.VersionDescriptor.VersionOptions)) + } + } + if args.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + if args.ResolveLfs != nil { + queryParams.Add("resolveLfs", strconv.FormatBool(*args.ResolveLfs)) + } + locationId, _ := uuid.Parse("fb93c0db-47ed-4a31-8c20-47552878fb44") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetItemContent function +type GetItemContentArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) The item path. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) The path scope. The default is null. + ScopePath *string + // (optional) The recursion level of this request. The default is 'none', no recursion. + RecursionLevel *VersionControlRecursionType + // (optional) Set to true to include content metadata. Default is false. + IncludeContentMetadata *bool + // (optional) Set to true to include the latest changes. Default is false. + LatestProcessedChange *bool + // (optional) Set to true to download the response as a file. Default is false. + Download *bool + // (optional) Version descriptor. Default is the default branch for the repository. + VersionDescriptor *GitVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *bool + // (optional) Set to true to resolve Git LFS pointer files to return actual content from Git LFS. Default is false. + ResolveLfs *bool +} + +// Get Item Metadata and/or Content for a collection of items. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download. +func (client *ClientImpl) GetItems(ctx context.Context, args GetItemsArgs) (*[]GitItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContentMetadata != nil { + queryParams.Add("includeContentMetadata", strconv.FormatBool(*args.IncludeContentMetadata)) + } + if args.LatestProcessedChange != nil { + queryParams.Add("latestProcessedChange", strconv.FormatBool(*args.LatestProcessedChange)) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionType != nil { + queryParams.Add("versionDescriptor.versionType", string(*args.VersionDescriptor.VersionType)) + } + if args.VersionDescriptor.Version != nil { + queryParams.Add("versionDescriptor.version", *args.VersionDescriptor.Version) + } + if args.VersionDescriptor.VersionOptions != nil { + queryParams.Add("versionDescriptor.versionOptions", string(*args.VersionDescriptor.VersionOptions)) + } + } + locationId, _ := uuid.Parse("fb93c0db-47ed-4a31-8c20-47552878fb44") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetItems function +type GetItemsArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) The path scope. The default is null. + ScopePath *string + // (optional) The recursion level of this request. The default is 'none', no recursion. + RecursionLevel *VersionControlRecursionType + // (optional) Set to true to include content metadata. Default is false. + IncludeContentMetadata *bool + // (optional) Set to true to include the latest changes. Default is false. + LatestProcessedChange *bool + // (optional) Set to true to download the response as a file. Default is false. + Download *bool + // (optional) Set to true to include links to items. Default is false. + IncludeLinks *bool + // (optional) Version descriptor. Default is the default branch for the repository. + VersionDescriptor *GitVersionDescriptor +} + +// Post for retrieving a creating a batch out of a set of items in a repo / project given a list of paths or a long path +func (client *ClientImpl) GetItemsBatch(ctx context.Context, args GetItemsBatchArgs) (*[][]GitItem, error) { + if args.RequestData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RequestData"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.RequestData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("630fd2e4-fb88-4f85-ad21-13f3fd1fbca9") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue [][]GitItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetItemsBatch function +type GetItemsBatchArgs struct { + // (required) Request data attributes: ItemDescriptors, IncludeContentMetadata, LatestProcessedChange, IncludeLinks. ItemDescriptors: Collection of items to fetch, including path, version, and recursion level. IncludeContentMetadata: Whether to include metadata for all items LatestProcessedChange: Whether to include shallow ref to commit that last changed each item. IncludeLinks: Whether to include the _links field on the shallow references. + RequestData *GitItemRequestData + // (required) The name or ID of the repository + RepositoryId *string + // (optional) Project ID or project name + Project *string +} + +// Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. +func (client *ClientImpl) GetItemText(ctx context.Context, args GetItemTextArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContentMetadata != nil { + queryParams.Add("includeContentMetadata", strconv.FormatBool(*args.IncludeContentMetadata)) + } + if args.LatestProcessedChange != nil { + queryParams.Add("latestProcessedChange", strconv.FormatBool(*args.LatestProcessedChange)) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionType != nil { + queryParams.Add("versionDescriptor.versionType", string(*args.VersionDescriptor.VersionType)) + } + if args.VersionDescriptor.Version != nil { + queryParams.Add("versionDescriptor.version", *args.VersionDescriptor.Version) + } + if args.VersionDescriptor.VersionOptions != nil { + queryParams.Add("versionDescriptor.versionOptions", string(*args.VersionDescriptor.VersionOptions)) + } + } + if args.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + if args.ResolveLfs != nil { + queryParams.Add("resolveLfs", strconv.FormatBool(*args.ResolveLfs)) + } + locationId, _ := uuid.Parse("fb93c0db-47ed-4a31-8c20-47552878fb44") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetItemText function +type GetItemTextArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) The item path. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) The path scope. The default is null. + ScopePath *string + // (optional) The recursion level of this request. The default is 'none', no recursion. + RecursionLevel *VersionControlRecursionType + // (optional) Set to true to include content metadata. Default is false. + IncludeContentMetadata *bool + // (optional) Set to true to include the latest changes. Default is false. + LatestProcessedChange *bool + // (optional) Set to true to download the response as a file. Default is false. + Download *bool + // (optional) Version descriptor. Default is the default branch for the repository. + VersionDescriptor *GitVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *bool + // (optional) Set to true to resolve Git LFS pointer files to return actual content from Git LFS. Default is false. + ResolveLfs *bool +} + +// Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content, which is always returned as a download. +func (client *ClientImpl) GetItemZip(ctx context.Context, args GetItemZipArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContentMetadata != nil { + queryParams.Add("includeContentMetadata", strconv.FormatBool(*args.IncludeContentMetadata)) + } + if args.LatestProcessedChange != nil { + queryParams.Add("latestProcessedChange", strconv.FormatBool(*args.LatestProcessedChange)) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionType != nil { + queryParams.Add("versionDescriptor.versionType", string(*args.VersionDescriptor.VersionType)) + } + if args.VersionDescriptor.Version != nil { + queryParams.Add("versionDescriptor.version", *args.VersionDescriptor.Version) + } + if args.VersionDescriptor.VersionOptions != nil { + queryParams.Add("versionDescriptor.versionOptions", string(*args.VersionDescriptor.VersionOptions)) + } + } + if args.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + if args.ResolveLfs != nil { + queryParams.Add("resolveLfs", strconv.FormatBool(*args.ResolveLfs)) + } + locationId, _ := uuid.Parse("fb93c0db-47ed-4a31-8c20-47552878fb44") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetItemZip function +type GetItemZipArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) The item path. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) The path scope. The default is null. + ScopePath *string + // (optional) The recursion level of this request. The default is 'none', no recursion. + RecursionLevel *VersionControlRecursionType + // (optional) Set to true to include content metadata. Default is false. + IncludeContentMetadata *bool + // (optional) Set to true to include the latest changes. Default is false. + LatestProcessedChange *bool + // (optional) Set to true to download the response as a file. Default is false. + Download *bool + // (optional) Version descriptor. Default is the default branch for the repository. + VersionDescriptor *GitVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *bool + // (optional) Set to true to resolve Git LFS pointer files to return actual content from Git LFS. Default is false. + ResolveLfs *bool +} + +// [Preview API] Get likes for a comment. +func (client *ClientImpl) GetLikes(ctx context.Context, args GetLikesArgs) (*[]webapi.IdentityRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("5f2e2851-1389-425b-a00b-fb2adb3ef31b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []webapi.IdentityRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLikes function +type GetLikesArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) The ID of the thread that contains the comment. + ThreadId *int + // (required) The ID of the comment. + CommentId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Find the merge bases of two commits, optionally across forks. If otherRepositoryId is not specified, the merge bases will only be calculated within the context of the local repositoryNameOrId. +func (client *ClientImpl) GetMergeBases(ctx context.Context, args GetMergeBasesArgs) (*[]GitCommitRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryNameOrId == nil || *args.RepositoryNameOrId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryNameOrId"} + } + routeValues["repositoryNameOrId"] = *args.RepositoryNameOrId + if args.CommitId == nil || *args.CommitId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CommitId"} + } + routeValues["commitId"] = *args.CommitId + + queryParams := url.Values{} + if args.OtherCommitId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "otherCommitId"} + } + queryParams.Add("otherCommitId", *args.OtherCommitId) + if args.OtherCollectionId != nil { + queryParams.Add("otherCollectionId", (*args.OtherCollectionId).String()) + } + if args.OtherRepositoryId != nil { + queryParams.Add("otherRepositoryId", (*args.OtherRepositoryId).String()) + } + locationId, _ := uuid.Parse("7cf2abb6-c964-4f7e-9872-f78c66e72e9c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitCommitRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetMergeBases function +type GetMergeBasesArgs struct { + // (required) ID or name of the local repository. + RepositoryNameOrId *string + // (required) First commit, usually the tip of the target branch of the potential merge. + CommitId *string + // (required) Other commit, usually the tip of the source branch of the potential merge. + OtherCommitId *string + // (optional) Project ID or project name + Project *string + // (optional) The collection ID where otherCommitId lives. + OtherCollectionId *uuid.UUID + // (optional) The repository ID where otherCommitId lives. + OtherRepositoryId *uuid.UUID +} + +// [Preview API] Get a specific merge operation's details. +func (client *ClientImpl) GetMergeRequest(ctx context.Context, args GetMergeRequestArgs) (*GitMerge, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryNameOrId == nil || *args.RepositoryNameOrId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryNameOrId"} + } + routeValues["repositoryNameOrId"] = *args.RepositoryNameOrId + if args.MergeOperationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.MergeOperationId"} + } + routeValues["mergeOperationId"] = strconv.Itoa(*args.MergeOperationId) + + queryParams := url.Values{} + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + locationId, _ := uuid.Parse("985f7ae9-844f-4906-9897-7ef41516c0e2") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitMerge + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetMergeRequest function +type GetMergeRequestArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name or ID of the repository. + RepositoryNameOrId *string + // (required) OperationId of the merge request. + MergeOperationId *int + // (optional) True to include links + IncludeLinks *bool +} + +// [Preview API] Retrieve a list of policy configurations by a given set of scope/filtering criteria. +func (client *ClientImpl) GetPolicyConfigurations(ctx context.Context, args GetPolicyConfigurationsArgs) (*GitPolicyConfigurationResponse, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.RepositoryId != nil { + queryParams.Add("repositoryId", (*args.RepositoryId).String()) + } + if args.RefName != nil { + queryParams.Add("refName", *args.RefName) + } + if args.PolicyType != nil { + queryParams.Add("policyType", (*args.PolicyType).String()) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("2c420070-a0a2-49cc-9639-c9f271c5ff07") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseBodyValue []policy.PolicyConfiguration + err = client.Client.UnmarshalCollectionBody(resp, &responseBodyValue) + + var responseValue *GitPolicyConfigurationResponse + xmsContinuationTokenHeader := resp.Header.Get("x-ms-continuationtoken") + if err == nil { + responseValue = &GitPolicyConfigurationResponse{ + PolicyConfigurations: &responseBodyValue, + ContinuationToken: &xmsContinuationTokenHeader, + } + } + + return responseValue, err +} + +// Arguments for the GetPolicyConfigurations function +type GetPolicyConfigurationsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The repository id. + RepositoryId *uuid.UUID + // (optional) The fully-qualified Git ref name (e.g. refs/heads/master). + RefName *string + // (optional) The policy type filter. + PolicyType *uuid.UUID + // (optional) Maximum number of policies to return. + Top *int + // (optional) Pass a policy configuration ID to fetch the next page of results, up to top number of results, for this endpoint. + ContinuationToken *string +} + +// Retrieve a pull request. +func (client *ClientImpl) GetPullRequest(ctx context.Context, args GetPullRequestArgs) (*GitPullRequest, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + queryParams := url.Values{} + if args.MaxCommentLength != nil { + queryParams.Add("maxCommentLength", strconv.Itoa(*args.MaxCommentLength)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.IncludeCommits != nil { + queryParams.Add("includeCommits", strconv.FormatBool(*args.IncludeCommits)) + } + if args.IncludeWorkItemRefs != nil { + queryParams.Add("includeWorkItemRefs", strconv.FormatBool(*args.IncludeWorkItemRefs)) + } + locationId, _ := uuid.Parse("9946fd70-0d40-406e-b686-b4744cbbcc37") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequest function +type GetPullRequestArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) The ID of the pull request to retrieve. + PullRequestId *int + // (optional) Project ID or project name + Project *string + // (optional) Not used. + MaxCommentLength *int + // (optional) Not used. + Skip *int + // (optional) Not used. + Top *int + // (optional) If true, the pull request will be returned with the associated commits. + IncludeCommits *bool + // (optional) If true, the pull request will be returned with the associated work item references. + IncludeWorkItemRefs *bool +} + +// Retrieve a pull request. +func (client *ClientImpl) GetPullRequestById(ctx context.Context, args GetPullRequestByIdArgs) (*GitPullRequest, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("01a46dea-7d46-4d40-bc84-319e7c260d99") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestById function +type GetPullRequestByIdArgs struct { + // (required) The ID of the pull request to retrieve. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Get the commits for the specified pull request. +func (client *ClientImpl) GetPullRequestCommits(ctx context.Context, args GetPullRequestCommitsArgs) (*GetPullRequestCommitsResponseValue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("52823034-34a8-4576-922c-8d8b77e9e4c4") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetPullRequestCommitsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetPullRequestCommits function +type GetPullRequestCommitsArgs struct { + // (required) ID or name of the repository. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string + // (optional) Maximum number of commits to return. + Top *int + // (optional) The continuation token used for pagination. + ContinuationToken *string +} + +// Return type for the GetPullRequestCommits function +type GetPullRequestCommitsResponseValue struct { + Value []GitCommitRef + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// Get the specified iteration for a pull request. +func (client *ClientImpl) GetPullRequestIteration(ctx context.Context, args GetPullRequestIterationArgs) (*GitPullRequestIteration, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + locationId, _ := uuid.Parse("d43911ee-6958-46b0-a42b-8445b8a0d004") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestIteration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestIteration function +type GetPullRequestIterationArgs struct { + // (required) ID or name of the repository. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request iteration to return. + IterationId *int + // (optional) Project ID or project name + Project *string +} + +// Retrieve the changes made in a pull request between two iterations. +func (client *ClientImpl) GetPullRequestIterationChanges(ctx context.Context, args GetPullRequestIterationChangesArgs) (*GitPullRequestIterationChanges, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.CompareTo != nil { + queryParams.Add("$compareTo", strconv.Itoa(*args.CompareTo)) + } + locationId, _ := uuid.Parse("4216bdcf-b6b1-4d59-8b82-c34cc183fc8b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestIterationChanges + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestIterationChanges function +type GetPullRequestIterationChangesArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request iteration.
Iteration IDs are zero-based with zero indicating the common commit between the source and target branches. Iteration one is the head of the source branch at the time the pull request is created and subsequent iterations are created when there are pushes to the source branch. + IterationId *int + // (optional) Project ID or project name + Project *string + // (optional) Optional. The number of changes to retrieve. The default value is 100 and the maximum value is 2000. + Top *int + // (optional) Optional. The number of changes to ignore. For example, to retrieve changes 101-150, set top 50 and skip to 100. + Skip *int + // (optional) ID of the pull request iteration to compare against. The default value is zero which indicates the comparison is made against the common commit between the source and target branches + CompareTo *int +} + +// Get the commits for the specified iteration of a pull request. +func (client *ClientImpl) GetPullRequestIterationCommits(ctx context.Context, args GetPullRequestIterationCommitsArgs) (*[]GitCommitRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("skip", strconv.Itoa(*args.Skip)) + } + locationId, _ := uuid.Parse("e7ea0883-095f-4926-b5fb-f24691c26fb9") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitCommitRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestIterationCommits function +type GetPullRequestIterationCommitsArgs struct { + // (required) ID or name of the repository. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the iteration from which to get the commits. + IterationId *int + // (optional) Project ID or project name + Project *string + // (optional) Maximum number of commits to return. The maximum number of commits that can be returned per batch is 500. + Top *int + // (optional) Number of commits to skip. + Skip *int +} + +// Get the list of iterations for the specified pull request. +func (client *ClientImpl) GetPullRequestIterations(ctx context.Context, args GetPullRequestIterationsArgs) (*[]GitPullRequestIteration, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + queryParams := url.Values{} + if args.IncludeCommits != nil { + queryParams.Add("includeCommits", strconv.FormatBool(*args.IncludeCommits)) + } + locationId, _ := uuid.Parse("d43911ee-6958-46b0-a42b-8445b8a0d004") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitPullRequestIteration + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestIterations function +type GetPullRequestIterationsArgs struct { + // (required) ID or name of the repository. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string + // (optional) If true, include the commits associated with each iteration in the response. + IncludeCommits *bool +} + +// [Preview API] Get the specific pull request iteration status by ID. The status ID is unique within the pull request across all iterations. +func (client *ClientImpl) GetPullRequestIterationStatus(ctx context.Context, args GetPullRequestIterationStatusArgs) (*GitPullRequestStatus, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + if args.StatusId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StatusId"} + } + routeValues["statusId"] = strconv.Itoa(*args.StatusId) + + locationId, _ := uuid.Parse("75cf11c5-979f-4038-a76e-058a06adf2bf") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestStatus + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestIterationStatus function +type GetPullRequestIterationStatusArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request iteration. + IterationId *int + // (required) ID of the pull request status. + StatusId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get all the statuses associated with a pull request iteration. +func (client *ClientImpl) GetPullRequestIterationStatuses(ctx context.Context, args GetPullRequestIterationStatusesArgs) (*[]GitPullRequestStatus, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + locationId, _ := uuid.Parse("75cf11c5-979f-4038-a76e-058a06adf2bf") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitPullRequestStatus + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestIterationStatuses function +type GetPullRequestIterationStatusesArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request iteration. + IterationId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Retrieves a single label that has been assigned to a pull request. +func (client *ClientImpl) GetPullRequestLabel(ctx context.Context, args GetPullRequestLabelArgs) (*core.WebApiTagDefinition, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.LabelIdOrName == nil || *args.LabelIdOrName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.LabelIdOrName"} + } + routeValues["labelIdOrName"] = *args.LabelIdOrName + + queryParams := url.Values{} + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + locationId, _ := uuid.Parse("f22387e3-984e-4c52-9c6d-fbb8f14c812d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue core.WebApiTagDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestLabel function +type GetPullRequestLabelArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) The name or ID of the label requested. + LabelIdOrName *string + // (optional) Project ID or project name + Project *string + // (optional) Project ID or project name. + ProjectId *string +} + +// [Preview API] Get all the labels assigned to a pull request. +func (client *ClientImpl) GetPullRequestLabels(ctx context.Context, args GetPullRequestLabelsArgs) (*[]core.WebApiTagDefinition, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + queryParams := url.Values{} + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + locationId, _ := uuid.Parse("f22387e3-984e-4c52-9c6d-fbb8f14c812d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []core.WebApiTagDefinition + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestLabels function +type GetPullRequestLabelsArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string + // (optional) Project ID or project name. + ProjectId *string +} + +// [Preview API] Get external properties of the pull request. +func (client *ClientImpl) GetPullRequestProperties(ctx context.Context, args GetPullRequestPropertiesArgs) (interface{}, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("48a52185-5b9e-4736-9dc1-bb1e2feac80b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetPullRequestProperties function +type GetPullRequestPropertiesArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// This API is used to find what pull requests are related to a given commit. It can be used to either find the pull request that created a particular merge commit or it can be used to find all pull requests that have ever merged a particular commit. The input is a list of queries which each contain a list of commits. For each commit that you search against, you will get back a dictionary of commit -> pull requests. +func (client *ClientImpl) GetPullRequestQuery(ctx context.Context, args GetPullRequestQueryArgs) (*GitPullRequestQuery, error) { + if args.Queries == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Queries"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + body, marshalErr := json.Marshal(*args.Queries) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b3a6eebe-9cf0-49ea-b6cb-1a4c5f5007b0") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestQuery function +type GetPullRequestQueryArgs struct { + // (required) The list of queries to perform. + Queries *GitPullRequestQuery + // (required) ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string +} + +// Retrieve information about a particular reviewer on a pull request +func (client *ClientImpl) GetPullRequestReviewer(ctx context.Context, args GetPullRequestReviewerArgs) (*IdentityRefWithVote, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ReviewerId == nil || *args.ReviewerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ReviewerId"} + } + routeValues["reviewerId"] = *args.ReviewerId + + locationId, _ := uuid.Parse("4b6702c7-aa35-4b89-9c96-b9abf6d3e540") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue IdentityRefWithVote + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestReviewer function +type GetPullRequestReviewerArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the reviewer. + ReviewerId *string + // (optional) Project ID or project name + Project *string +} + +// Retrieve the reviewers for a pull request +func (client *ClientImpl) GetPullRequestReviewers(ctx context.Context, args GetPullRequestReviewersArgs) (*[]IdentityRefWithVote, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("4b6702c7-aa35-4b89-9c96-b9abf6d3e540") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []IdentityRefWithVote + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestReviewers function +type GetPullRequestReviewersArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Retrieve all pull requests matching a specified criteria. +func (client *ClientImpl) GetPullRequests(ctx context.Context, args GetPullRequestsArgs) (*[]GitPullRequest, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.SearchCriteria == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "searchCriteria"} + } + if args.SearchCriteria.RepositoryId != nil { + queryParams.Add("searchCriteria.repositoryId", (*args.SearchCriteria.RepositoryId).String()) + } + if args.SearchCriteria.CreatorId != nil { + queryParams.Add("searchCriteria.creatorId", (*args.SearchCriteria.CreatorId).String()) + } + if args.SearchCriteria.ReviewerId != nil { + queryParams.Add("searchCriteria.reviewerId", (*args.SearchCriteria.ReviewerId).String()) + } + if args.SearchCriteria.Status != nil { + queryParams.Add("searchCriteria.status", string(*args.SearchCriteria.Status)) + } + if args.SearchCriteria.TargetRefName != nil { + queryParams.Add("searchCriteria.targetRefName", *args.SearchCriteria.TargetRefName) + } + if args.SearchCriteria.SourceRepositoryId != nil { + queryParams.Add("searchCriteria.sourceRepositoryId", (*args.SearchCriteria.SourceRepositoryId).String()) + } + if args.SearchCriteria.SourceRefName != nil { + queryParams.Add("searchCriteria.sourceRefName", *args.SearchCriteria.SourceRefName) + } + if args.SearchCriteria.IncludeLinks != nil { + queryParams.Add("searchCriteria.includeLinks", strconv.FormatBool(*args.SearchCriteria.IncludeLinks)) + } + if args.MaxCommentLength != nil { + queryParams.Add("maxCommentLength", strconv.Itoa(*args.MaxCommentLength)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("9946fd70-0d40-406e-b686-b4744cbbcc37") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitPullRequest + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequests function +type GetPullRequestsArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) Pull requests will be returned that match this search criteria. + SearchCriteria *GitPullRequestSearchCriteria + // (optional) Project ID or project name + Project *string + // (optional) Not used. + MaxCommentLength *int + // (optional) The number of pull requests to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100. + Skip *int + // (optional) The number of pull requests to retrieve. + Top *int +} + +// Retrieve all pull requests matching a specified criteria. +func (client *ClientImpl) GetPullRequestsByProject(ctx context.Context, args GetPullRequestsByProjectArgs) (*[]GitPullRequest, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.SearchCriteria == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "searchCriteria"} + } + if args.SearchCriteria.RepositoryId != nil { + queryParams.Add("searchCriteria.repositoryId", (*args.SearchCriteria.RepositoryId).String()) + } + if args.SearchCriteria.CreatorId != nil { + queryParams.Add("searchCriteria.creatorId", (*args.SearchCriteria.CreatorId).String()) + } + if args.SearchCriteria.ReviewerId != nil { + queryParams.Add("searchCriteria.reviewerId", (*args.SearchCriteria.ReviewerId).String()) + } + if args.SearchCriteria.Status != nil { + queryParams.Add("searchCriteria.status", string(*args.SearchCriteria.Status)) + } + if args.SearchCriteria.TargetRefName != nil { + queryParams.Add("searchCriteria.targetRefName", *args.SearchCriteria.TargetRefName) + } + if args.SearchCriteria.SourceRepositoryId != nil { + queryParams.Add("searchCriteria.sourceRepositoryId", (*args.SearchCriteria.SourceRepositoryId).String()) + } + if args.SearchCriteria.SourceRefName != nil { + queryParams.Add("searchCriteria.sourceRefName", *args.SearchCriteria.SourceRefName) + } + if args.SearchCriteria.IncludeLinks != nil { + queryParams.Add("searchCriteria.includeLinks", strconv.FormatBool(*args.SearchCriteria.IncludeLinks)) + } + if args.MaxCommentLength != nil { + queryParams.Add("maxCommentLength", strconv.Itoa(*args.MaxCommentLength)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("a5d28130-9cd2-40fa-9f08-902e7daa9efb") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitPullRequest + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestsByProject function +type GetPullRequestsByProjectArgs struct { + // (required) Project ID or project name + Project *string + // (required) Pull requests will be returned that match this search criteria. + SearchCriteria *GitPullRequestSearchCriteria + // (optional) Not used. + MaxCommentLength *int + // (optional) The number of pull requests to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100. + Skip *int + // (optional) The number of pull requests to retrieve. + Top *int +} + +// [Preview API] Get the specific pull request status by ID. The status ID is unique within the pull request across all iterations. +func (client *ClientImpl) GetPullRequestStatus(ctx context.Context, args GetPullRequestStatusArgs) (*GitPullRequestStatus, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.StatusId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StatusId"} + } + routeValues["statusId"] = strconv.Itoa(*args.StatusId) + + locationId, _ := uuid.Parse("b5f6bb4f-8d1e-4d79-8d11-4c9172c99c35") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestStatus + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestStatus function +type GetPullRequestStatusArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request status. + StatusId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get all the statuses associated with a pull request. +func (client *ClientImpl) GetPullRequestStatuses(ctx context.Context, args GetPullRequestStatusesArgs) (*[]GitPullRequestStatus, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("b5f6bb4f-8d1e-4d79-8d11-4c9172c99c35") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitPullRequestStatus + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestStatuses function +type GetPullRequestStatusesArgs struct { + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Retrieve a thread in a pull request. +func (client *ClientImpl) GetPullRequestThread(ctx context.Context, args GetPullRequestThreadArgs) (*GitPullRequestCommentThread, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + + queryParams := url.Values{} + if args.Iteration != nil { + queryParams.Add("$iteration", strconv.Itoa(*args.Iteration)) + } + if args.BaseIteration != nil { + queryParams.Add("$baseIteration", strconv.Itoa(*args.BaseIteration)) + } + locationId, _ := uuid.Parse("ab6e2e5d-a0b7-4153-b64a-a4efe0d49449") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestCommentThread + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestThread function +type GetPullRequestThreadArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the thread. + ThreadId *int + // (optional) Project ID or project name + Project *string + // (optional) If specified, thread position will be tracked using this iteration as the right side of the diff. + Iteration *int + // (optional) If specified, thread position will be tracked using this iteration as the left side of the diff. + BaseIteration *int +} + +// Retrieve a list of work items associated with a pull request. +func (client *ClientImpl) GetPullRequestWorkItemRefs(ctx context.Context, args GetPullRequestWorkItemRefsArgs) (*[]webapi.ResourceRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + locationId, _ := uuid.Parse("0a637fcc-5370-4ce8-b0e8-98091f5f9482") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []webapi.ResourceRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequestWorkItemRefs function +type GetPullRequestWorkItemRefsArgs struct { + // (required) ID or name of the repository. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Retrieves a particular push. +func (client *ClientImpl) GetPush(ctx context.Context, args GetPushArgs) (*GitPush, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PushId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PushId"} + } + routeValues["pushId"] = strconv.Itoa(*args.PushId) + + queryParams := url.Values{} + if args.IncludeCommits != nil { + queryParams.Add("includeCommits", strconv.Itoa(*args.IncludeCommits)) + } + if args.IncludeRefUpdates != nil { + queryParams.Add("includeRefUpdates", strconv.FormatBool(*args.IncludeRefUpdates)) + } + locationId, _ := uuid.Parse("ea98d07b-3c87-4971-8ede-a613694ffb55") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPush + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPush function +type GetPushArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) ID of the push. + PushId *int + // (optional) Project ID or project name + Project *string + // (optional) The number of commits to include in the result. + IncludeCommits *int + // (optional) If true, include the list of refs that were updated by the push. + IncludeRefUpdates *bool +} + +// Retrieve a list of commits associated with a particular push. +func (client *ClientImpl) GetPushCommits(ctx context.Context, args GetPushCommitsArgs) (*[]GitCommitRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.PushId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "pushId"} + } + queryParams.Add("pushId", strconv.Itoa(*args.PushId)) + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("skip", strconv.Itoa(*args.Skip)) + } + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + locationId, _ := uuid.Parse("c2570c3b-5b3f-41b8-98bf-5407bfde8d58") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitCommitRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPushCommits function +type GetPushCommitsArgs struct { + // (required) The id or friendly name of the repository. To use the friendly name, projectId must also be specified. + RepositoryId *string + // (required) The id of the push. + PushId *int + // (optional) Project ID or project name + Project *string + // (optional) The maximum number of commits to return ("get the top x commits"). + Top *int + // (optional) The number of commits to skip. + Skip *int + // (optional) Set to false to avoid including REST Url links for resources. Defaults to true. + IncludeLinks *bool +} + +// Retrieves pushes associated with the specified repository. +func (client *ClientImpl) GetPushes(ctx context.Context, args GetPushesArgs) (*[]GitPush, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.SearchCriteria != nil { + if args.SearchCriteria.FromDate != nil { + queryParams.Add("searchCriteria.fromDate", (*args.SearchCriteria.FromDate).AsQueryParameter()) + } + if args.SearchCriteria.ToDate != nil { + queryParams.Add("searchCriteria.toDate", (*args.SearchCriteria.ToDate).AsQueryParameter()) + } + if args.SearchCriteria.PusherId != nil { + queryParams.Add("searchCriteria.pusherId", (*args.SearchCriteria.PusherId).String()) + } + if args.SearchCriteria.RefName != nil { + queryParams.Add("searchCriteria.refName", *args.SearchCriteria.RefName) + } + if args.SearchCriteria.IncludeRefUpdates != nil { + queryParams.Add("searchCriteria.includeRefUpdates", strconv.FormatBool(*args.SearchCriteria.IncludeRefUpdates)) + } + if args.SearchCriteria.IncludeLinks != nil { + queryParams.Add("searchCriteria.includeLinks", strconv.FormatBool(*args.SearchCriteria.IncludeLinks)) + } + } + locationId, _ := uuid.Parse("ea98d07b-3c87-4971-8ede-a613694ffb55") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitPush + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPushes function +type GetPushesArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) Number of pushes to skip. + Skip *int + // (optional) Number of pushes to return. + Top *int + // (optional) Search criteria attributes: fromDate, toDate, pusherId, refName, includeRefUpdates or includeLinks. fromDate: Start date to search from. toDate: End date to search to. pusherId: Identity of the person who submitted the push. refName: Branch name to consider. includeRefUpdates: If true, include the list of refs that were updated by the push. includeLinks: Whether to include the _links field on the shallow references. + SearchCriteria *GitPushSearchCriteria +} + +// [Preview API] Retrieve soft-deleted git repositories from the recycle bin. +func (client *ClientImpl) GetRecycleBinRepositories(ctx context.Context, args GetRecycleBinRepositoriesArgs) (*[]GitDeletedRepository, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + locationId, _ := uuid.Parse("a663da97-81db-4eb3-8b83-287670f63073") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitDeletedRepository + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRecycleBinRepositories function +type GetRecycleBinRepositoriesArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] Gets the refs favorite for a favorite Id. +func (client *ClientImpl) GetRefFavorite(ctx context.Context, args GetRefFavoriteArgs) (*GitRefFavorite, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.FavoriteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.FavoriteId"} + } + routeValues["favoriteId"] = strconv.Itoa(*args.FavoriteId) + + locationId, _ := uuid.Parse("876f70af-5792-485a-a1c7-d0a7b2f42bbb") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRefFavorite + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRefFavorite function +type GetRefFavoriteArgs struct { + // (required) Project ID or project name + Project *string + // (required) The Id of the requested ref favorite. + FavoriteId *int +} + +// [Preview API] Gets the refs favorites for a repo and an identity. +func (client *ClientImpl) GetRefFavorites(ctx context.Context, args GetRefFavoritesArgs) (*[]GitRefFavorite, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.RepositoryId != nil { + queryParams.Add("repositoryId", *args.RepositoryId) + } + if args.IdentityId != nil { + queryParams.Add("identityId", *args.IdentityId) + } + locationId, _ := uuid.Parse("876f70af-5792-485a-a1c7-d0a7b2f42bbb") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitRefFavorite + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRefFavorites function +type GetRefFavoritesArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The id of the repository. + RepositoryId *string + // (optional) The id of the identity whose favorites are to be retrieved. If null, the requesting identity is used. + IdentityId *string +} + +// Queries the provided repository for its refs and returns them. +func (client *ClientImpl) GetRefs(ctx context.Context, args GetRefsArgs) (*GetRefsResponseValue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Filter != nil { + queryParams.Add("filter", *args.Filter) + } + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + if args.IncludeStatuses != nil { + queryParams.Add("includeStatuses", strconv.FormatBool(*args.IncludeStatuses)) + } + if args.IncludeMyBranches != nil { + queryParams.Add("includeMyBranches", strconv.FormatBool(*args.IncludeMyBranches)) + } + if args.LatestStatusesOnly != nil { + queryParams.Add("latestStatusesOnly", strconv.FormatBool(*args.LatestStatusesOnly)) + } + if args.PeelTags != nil { + queryParams.Add("peelTags", strconv.FormatBool(*args.PeelTags)) + } + if args.FilterContains != nil { + queryParams.Add("filterContains", *args.FilterContains) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("2d874a60-a811-4f62-9c9f-963a6ea0a55b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetRefsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetRefs function +type GetRefsArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) [optional] A filter to apply to the refs (starts with). + Filter *string + // (optional) [optional] Specifies if referenceLinks should be included in the result. default is false. + IncludeLinks *bool + // (optional) [optional] Includes up to the first 1000 commit statuses for each ref. The default value is false. + IncludeStatuses *bool + // (optional) [optional] Includes only branches that the user owns, the branches the user favorites, and the default branch. The default value is false. Cannot be combined with the filter parameter. + IncludeMyBranches *bool + // (optional) [optional] True to include only the tip commit status for each ref. This option requires `includeStatuses` to be true. The default value is false. + LatestStatusesOnly *bool + // (optional) [optional] Annotated tags will populate the PeeledObjectId property. default is false. + PeelTags *bool + // (optional) [optional] A filter to apply to the refs (contains). + FilterContains *string + // (optional) [optional] Maximum number of refs to return. It cannot be bigger than 1000. If it is not provided but continuationToken is, top will default to 100. + Top *int + // (optional) The continuation token used for pagination. + ContinuationToken *string +} + +// Return type for the GetRefs function +type GetRefsResponseValue struct { + Value []GitRef + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// Retrieve git repositories. +func (client *ClientImpl) GetRepositories(ctx context.Context, args GetRepositoriesArgs) (*[]GitRepository, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + if args.IncludeAllUrls != nil { + queryParams.Add("includeAllUrls", strconv.FormatBool(*args.IncludeAllUrls)) + } + if args.IncludeHidden != nil { + queryParams.Add("includeHidden", strconv.FormatBool(*args.IncludeHidden)) + } + locationId, _ := uuid.Parse("225f7195-f9c7-4d14-ab28-a83f7ff77e1f") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitRepository + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRepositories function +type GetRepositoriesArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) [optional] True to include reference links. The default value is false. + IncludeLinks *bool + // (optional) [optional] True to include all remote URLs. The default value is false. + IncludeAllUrls *bool + // (optional) [optional] True to include hidden repositories. The default value is false. + IncludeHidden *bool +} + +// Retrieve a git repository. +func (client *ClientImpl) GetRepository(ctx context.Context, args GetRepositoryArgs) (*GitRepository, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + locationId, _ := uuid.Parse("225f7195-f9c7-4d14-ab28-a83f7ff77e1f") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRepository + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRepository function +type GetRepositoryArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string +} + +// Retrieve a git repository. +func (client *ClientImpl) GetRepositoryWithParent(ctx context.Context, args GetRepositoryWithParentArgs) (*GitRepository, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.IncludeParent == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "includeParent"} + } + queryParams.Add("includeParent", strconv.FormatBool(*args.IncludeParent)) + locationId, _ := uuid.Parse("225f7195-f9c7-4d14-ab28-a83f7ff77e1f") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRepository + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRepositoryWithParent function +type GetRepositoryWithParentArgs struct { + // (required) The name or ID of the repository. + RepositoryId *string + // (required) True to include parent repository. Only available in authenticated calls. + IncludeParent *bool + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Retrieve information about a revert operation by revert Id. +func (client *ClientImpl) GetRevert(ctx context.Context, args GetRevertArgs) (*GitRevert, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RevertId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RevertId"} + } + routeValues["revertId"] = strconv.Itoa(*args.RevertId) + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + locationId, _ := uuid.Parse("bc866058-5449-4715-9cf1-a510b6ff193c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRevert + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRevert function +type GetRevertArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the revert operation. + RevertId *int + // (required) ID of the repository. + RepositoryId *string +} + +// [Preview API] Retrieve information about a revert operation for a specific branch. +func (client *ClientImpl) GetRevertForRefName(ctx context.Context, args GetRevertForRefNameArgs) (*GitRevert, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.RefName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "refName"} + } + queryParams.Add("refName", *args.RefName) + locationId, _ := uuid.Parse("bc866058-5449-4715-9cf1-a510b6ff193c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRevert + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRevertForRefName function +type GetRevertForRefNameArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the repository. + RepositoryId *string + // (required) The GitAsyncRefOperationParameters generatedRefName used for the revert operation. + RefName *string +} + +// Get statuses associated with the Git commit. +func (client *ClientImpl) GetStatuses(ctx context.Context, args GetStatusesArgs) (*[]GitStatus, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.CommitId == nil || *args.CommitId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CommitId"} + } + routeValues["commitId"] = *args.CommitId + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("skip", strconv.Itoa(*args.Skip)) + } + if args.LatestOnly != nil { + queryParams.Add("latestOnly", strconv.FormatBool(*args.LatestOnly)) + } + locationId, _ := uuid.Parse("428dd4fb-fda5-4722-af02-9313b80305da") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitStatus + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetStatuses function +type GetStatusesArgs struct { + // (required) ID of the Git commit. + CommitId *string + // (required) ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) Optional. The number of statuses to retrieve. Default is 1000. + Top *int + // (optional) Optional. The number of statuses to ignore. Default is 0. For example, to retrieve results 101-150, set top to 50 and skip to 100. + Skip *int + // (optional) The flag indicates whether to get only latest statuses grouped by `Context.Name` and `Context.Genre`. + LatestOnly *bool +} + +// [Preview API] Retrieve a pull request suggestion for a particular repository or team project. +func (client *ClientImpl) GetSuggestions(ctx context.Context, args GetSuggestionsArgs) (*[]GitSuggestion, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + locationId, _ := uuid.Parse("9393b4fb-4445-4919-972b-9ad16f442d83") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitSuggestion + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSuggestions function +type GetSuggestionsArgs struct { + // (required) ID of the git repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string +} + +// Retrieve all threads in a pull request. +func (client *ClientImpl) GetThreads(ctx context.Context, args GetThreadsArgs) (*[]GitPullRequestCommentThread, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + queryParams := url.Values{} + if args.Iteration != nil { + queryParams.Add("$iteration", strconv.Itoa(*args.Iteration)) + } + if args.BaseIteration != nil { + queryParams.Add("$baseIteration", strconv.Itoa(*args.BaseIteration)) + } + locationId, _ := uuid.Parse("ab6e2e5d-a0b7-4153-b64a-a4efe0d49449") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitPullRequestCommentThread + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetThreads function +type GetThreadsArgs struct { + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string + // (optional) If specified, thread positions will be tracked using this iteration as the right side of the diff. + Iteration *int + // (optional) If specified, thread positions will be tracked using this iteration as the left side of the diff. + BaseIteration *int +} + +// The Tree endpoint returns the collection of objects underneath the specified tree. Trees are folders in a Git repository. +func (client *ClientImpl) GetTree(ctx context.Context, args GetTreeArgs) (*GitTreeRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.Sha1 == nil || *args.Sha1 == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Sha1"} + } + routeValues["sha1"] = *args.Sha1 + + queryParams := url.Values{} + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + if args.Recursive != nil { + queryParams.Add("recursive", strconv.FormatBool(*args.Recursive)) + } + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + locationId, _ := uuid.Parse("729f6437-6f92-44ec-8bee-273a7111063c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitTreeRef + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTree function +type GetTreeArgs struct { + // (required) Repository Id. + RepositoryId *string + // (required) SHA1 hash of the tree object. + Sha1 *string + // (optional) Project ID or project name + Project *string + // (optional) Project Id. + ProjectId *string + // (optional) Search recursively. Include trees underneath this tree. Default is false. + Recursive *bool + // (optional) Name to use if a .zip file is returned. Default is the object ID. + FileName *string +} + +// The Tree endpoint returns the collection of objects underneath the specified tree. Trees are folders in a Git repository. +func (client *ClientImpl) GetTreeZip(ctx context.Context, args GetTreeZipArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.Sha1 == nil || *args.Sha1 == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Sha1"} + } + routeValues["sha1"] = *args.Sha1 + + queryParams := url.Values{} + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + if args.Recursive != nil { + queryParams.Add("recursive", strconv.FormatBool(*args.Recursive)) + } + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + locationId, _ := uuid.Parse("729f6437-6f92-44ec-8bee-273a7111063c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetTreeZip function +type GetTreeZipArgs struct { + // (required) Repository Id. + RepositoryId *string + // (required) SHA1 hash of the tree object. + Sha1 *string + // (optional) Project ID or project name + Project *string + // (optional) Project Id. + ProjectId *string + // (optional) Search recursively. Include trees underneath this tree. Default is false. + Recursive *bool + // (optional) Name to use if a .zip file is returned. Default is the object ID. + FileName *string +} + +// [Preview API] Retrieve import requests for a repository. +func (client *ClientImpl) QueryImportRequests(ctx context.Context, args QueryImportRequestsArgs) (*[]GitImportRequest, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.IncludeAbandoned != nil { + queryParams.Add("includeAbandoned", strconv.FormatBool(*args.IncludeAbandoned)) + } + locationId, _ := uuid.Parse("01828ddc-3600-4a41-8633-99b3a73a0eb3") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitImportRequest + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryImportRequests function +type QueryImportRequestsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) True to include abandoned import requests in the results. + IncludeAbandoned *bool +} + +// [Preview API] 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. +func (client *ClientImpl) RestoreRepositoryFromRecycleBin(ctx context.Context, args RestoreRepositoryFromRecycleBinArgs) (*GitRepository, error) { + if args.RepositoryDetails == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RepositoryDetails"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = (*args.RepositoryId).String() + + body, marshalErr := json.Marshal(*args.RepositoryDetails) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a663da97-81db-4eb3-8b83-287670f63073") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRepository + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RestoreRepositoryFromRecycleBin function +type RestoreRepositoryFromRecycleBinArgs struct { + // (required) + RepositoryDetails *GitRecycleBinRepositoryDetails + // (required) Project ID or project name + Project *string + // (required) The ID of the repository. + RepositoryId *uuid.UUID +} + +// [Preview API] Sends an e-mail notification about a specific pull request to a set of recipients +func (client *ClientImpl) SharePullRequest(ctx context.Context, args SharePullRequestArgs) error { + if args.UserMessage == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.UserMessage"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.UserMessage) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("696f3a82-47c9-487f-9117-b9d00972ca84") + _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the SharePullRequest function +type SharePullRequestArgs struct { + // (required) + UserMessage *ShareNotificationContext + // (required) ID of the git repository. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Update a comment associated with a specific thread in a pull request. +func (client *ClientImpl) UpdateComment(ctx context.Context, args UpdateCommentArgs) (*Comment, error) { + if args.Comment == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Comment"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + body, marshalErr := json.Marshal(*args.Comment) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("965a3ec7-5ed8-455a-bdcb-835a5ea7fe7b") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Comment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateComment function +type UpdateCommentArgs struct { + // (required) The comment content that should be updated. Comments can be up to 150,000 characters. + Comment *Comment + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the thread that the desired comment is in. + ThreadId *int + // (required) ID of the comment to update. + CommentId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Retry or abandon a failed import request. +func (client *ClientImpl) UpdateImportRequest(ctx context.Context, args UpdateImportRequestArgs) (*GitImportRequest, error) { + if args.ImportRequestToUpdate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ImportRequestToUpdate"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.ImportRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ImportRequestId"} + } + routeValues["importRequestId"] = strconv.Itoa(*args.ImportRequestId) + + body, marshalErr := json.Marshal(*args.ImportRequestToUpdate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("01828ddc-3600-4a41-8633-99b3a73a0eb3") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitImportRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateImportRequest function +type UpdateImportRequestArgs struct { + // (required) The updated version of the import request. Currently, the only change allowed is setting the Status to Queued or Abandoned. + ImportRequestToUpdate *GitImportRequest + // (required) Project ID or project name + Project *string + // (required) The name or ID of the repository. + RepositoryId *string + // (required) The unique identifier for the import request to update. + ImportRequestId *int +} + +// Update a pull request +func (client *ClientImpl) UpdatePullRequest(ctx context.Context, args UpdatePullRequestArgs) (*GitPullRequest, error) { + if args.GitPullRequestToUpdate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GitPullRequestToUpdate"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.GitPullRequestToUpdate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("9946fd70-0d40-406e-b686-b4744cbbcc37") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePullRequest function +type UpdatePullRequestArgs struct { + // (required) The pull request content that should be updated. + GitPullRequestToUpdate *GitPullRequest + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request to update. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Update pull request iteration statuses collection. The only supported operation type is `remove`. +func (client *ClientImpl) UpdatePullRequestIterationStatuses(ctx context.Context, args UpdatePullRequestIterationStatusesArgs) error { + if args.PatchDocument == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PatchDocument"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.IterationId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + body, marshalErr := json.Marshal(*args.PatchDocument) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("75cf11c5-979f-4038-a76e-058a06adf2bf") + _, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the UpdatePullRequestIterationStatuses function +type UpdatePullRequestIterationStatusesArgs struct { + // (required) Operations to apply to the pull request statuses in JSON Patch format. + PatchDocument *[]webapi.JsonPatchOperation + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the pull request iteration. + IterationId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Create or update pull request external properties. The patch operation can be `add`, `replace` or `remove`. For `add` operation, the path can be empty. If the path is empty, the value must be a list of key value pairs. For `replace` operation, the path cannot be empty. If the path does not exist, the property will be added to the collection. For `remove` operation, the path cannot be empty. If the path does not exist, no action will be performed. +func (client *ClientImpl) UpdatePullRequestProperties(ctx context.Context, args UpdatePullRequestPropertiesArgs) (interface{}, error) { + if args.PatchDocument == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PatchDocument"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.PatchDocument) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("48a52185-5b9e-4736-9dc1-bb1e2feac80b") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the UpdatePullRequestProperties function +type UpdatePullRequestPropertiesArgs struct { + // (required) Properties to add, replace or remove in JSON Patch format. + PatchDocument *[]webapi.JsonPatchOperation + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Reset the votes of multiple reviewers on a pull request. NOTE: This endpoint only supports updating votes, but does not support updating required reviewers (use policy) or display names. +func (client *ClientImpl) UpdatePullRequestReviewers(ctx context.Context, args UpdatePullRequestReviewersArgs) error { + if args.PatchVotes == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PatchVotes"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.PatchVotes) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("4b6702c7-aa35-4b89-9c96-b9abf6d3e540") + _, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the UpdatePullRequestReviewers function +type UpdatePullRequestReviewersArgs struct { + // (required) IDs of the reviewers whose votes will be reset to zero + PatchVotes *[]IdentityRefWithVote + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Update pull request statuses collection. The only supported operation type is `remove`. +func (client *ClientImpl) UpdatePullRequestStatuses(ctx context.Context, args UpdatePullRequestStatusesArgs) error { + if args.PatchDocument == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PatchDocument"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + + body, marshalErr := json.Marshal(*args.PatchDocument) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("b5f6bb4f-8d1e-4d79-8d11-4c9172c99c35") + _, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the UpdatePullRequestStatuses function +type UpdatePullRequestStatusesArgs struct { + // (required) Operations to apply to the pull request statuses in JSON Patch format. + PatchDocument *[]webapi.JsonPatchOperation + // (required) The repository ID of the pull request’s target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (optional) Project ID or project name + Project *string +} + +// Lock or Unlock a branch. +func (client *ClientImpl) UpdateRef(ctx context.Context, args UpdateRefArgs) (*GitRef, error) { + if args.NewRefInfo == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.NewRefInfo"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "filter"} + } + queryParams.Add("filter", *args.Filter) + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + body, marshalErr := json.Marshal(*args.NewRefInfo) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2d874a60-a811-4f62-9c9f-963a6ea0a55b") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRef + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRef function +type UpdateRefArgs struct { + // (required) The ref update action (lock/unlock) to perform + NewRefInfo *GitRefUpdate + // (required) The name or ID of the repository. + RepositoryId *string + // (required) The name of the branch to lock/unlock + Filter *string + // (optional) Project ID or project name + Project *string + // (optional) ID or name of the team project. Optional if specifying an ID for repository. + ProjectId *string +} + +// Creating, updating, or deleting refs(branches). +func (client *ClientImpl) UpdateRefs(ctx context.Context, args UpdateRefsArgs) (*[]GitRefUpdateResult, error) { + if args.RefUpdates == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RefUpdates"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + + queryParams := url.Values{} + if args.ProjectId != nil { + queryParams.Add("projectId", *args.ProjectId) + } + body, marshalErr := json.Marshal(*args.RefUpdates) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2d874a60-a811-4f62-9c9f-963a6ea0a55b") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GitRefUpdateResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRefs function +type UpdateRefsArgs struct { + // (required) List of ref updates to attempt to perform + RefUpdates *[]GitRefUpdate + // (required) The name or ID of the repository. + RepositoryId *string + // (optional) Project ID or project name + Project *string + // (optional) ID or name of the team project. Optional if specifying an ID for repository. + ProjectId *string +} + +// Updates the Git repository with either a new repo name or a new default branch. +func (client *ClientImpl) UpdateRepository(ctx context.Context, args UpdateRepositoryArgs) (*GitRepository, error) { + if args.NewRepositoryInfo == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.NewRepositoryInfo"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = (*args.RepositoryId).String() + + body, marshalErr := json.Marshal(*args.NewRepositoryInfo) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("225f7195-f9c7-4d14-ab28-a83f7ff77e1f") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitRepository + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRepository function +type UpdateRepositoryArgs struct { + // (required) Specify a new repo name or a new default branch of the repository + NewRepositoryInfo *GitRepository + // (required) The name or ID of the repository. + RepositoryId *uuid.UUID + // (optional) Project ID or project name + Project *string +} + +// Update a thread in a pull request. +func (client *ClientImpl) UpdateThread(ctx context.Context, args UpdateThreadArgs) (*GitPullRequestCommentThread, error) { + if args.CommentThread == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentThread"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.RepositoryId == nil || *args.RepositoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = *args.RepositoryId + if args.PullRequestId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = strconv.Itoa(*args.PullRequestId) + if args.ThreadId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ThreadId"} + } + routeValues["threadId"] = strconv.Itoa(*args.ThreadId) + + body, marshalErr := json.Marshal(*args.CommentThread) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ab6e2e5d-a0b7-4153-b64a-a4efe0d49449") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GitPullRequestCommentThread + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateThread function +type UpdateThreadArgs struct { + // (required) The thread content that should be updated. + CommentThread *GitPullRequestCommentThread + // (required) The repository ID of the pull request's target branch. + RepositoryId *string + // (required) ID of the pull request. + PullRequestId *int + // (required) ID of the thread to update. + ThreadId *int + // (optional) Project ID or project name + Project *string +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/git/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/git/models.go new file mode 100644 index 0000000000..3ba3b552a0 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/git/models.go @@ -0,0 +1,3224 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package git + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/core" + "github.com/microsoft/azure-devops-go-api/azuredevops/policy" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AssociatedWorkItem struct { + AssignedTo *string `json:"assignedTo,omitempty"` + // Id of associated the work item. + Id *int `json:"id,omitempty"` + State *string `json:"state,omitempty"` + Title *string `json:"title,omitempty"` + // REST Url of the work item. + Url *string `json:"url,omitempty"` + WebUrl *string `json:"webUrl,omitempty"` + WorkItemType *string `json:"workItemType,omitempty"` +} + +type AsyncGitOperationNotification struct { + OperationId *int `json:"operationId,omitempty"` +} + +type AsyncRefOperationCommitLevelEventNotification struct { + OperationId *int `json:"operationId,omitempty"` + CommitId *string `json:"commitId,omitempty"` +} + +type AsyncRefOperationCompletedNotification struct { + OperationId *int `json:"operationId,omitempty"` + NewRefName *string `json:"newRefName,omitempty"` +} + +type AsyncRefOperationConflictNotification struct { + OperationId *int `json:"operationId,omitempty"` + CommitId *string `json:"commitId,omitempty"` +} + +type AsyncRefOperationGeneralFailureNotification struct { + OperationId *int `json:"operationId,omitempty"` +} + +type AsyncRefOperationProgressNotification struct { + OperationId *int `json:"operationId,omitempty"` + CommitId *string `json:"commitId,omitempty"` + Progress *float64 `json:"progress,omitempty"` +} + +type AsyncRefOperationTimeoutNotification struct { + OperationId *int `json:"operationId,omitempty"` +} + +// Meta data for a file attached to an artifact. +type Attachment struct { + // Links to other related objects. + Links interface{} `json:"_links,omitempty"` + // The person that uploaded this attachment. + Author *webapi.IdentityRef `json:"author,omitempty"` + // Content hash of on-disk representation of file content. Its calculated by the server by using SHA1 hash function. + ContentHash *string `json:"contentHash,omitempty"` + // The time the attachment was uploaded. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The description of the attachment. + Description *string `json:"description,omitempty"` + // The display name of the attachment. Can't be null or empty. + DisplayName *string `json:"displayName,omitempty"` + // Id of the attachment. + Id *int `json:"id,omitempty"` + // Extended properties. + Properties interface{} `json:"properties,omitempty"` + // The url to download the content of the attachment. + Url *string `json:"url,omitempty"` +} + +// Real time event (SignalR) for an auto-complete update on a pull request +type AutoCompleteUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Real time event (SignalR) for a source/target branch update on a pull request +type BranchUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` + // If true, the source branch of the pull request was updated + IsSourceUpdate *bool `json:"isSourceUpdate,omitempty"` +} + +type Change struct { + // The type of change that was made to the item. + ChangeType *VersionControlChangeType `json:"changeType,omitempty"` + // Current version. + Item interface{} `json:"item,omitempty"` + // Content of the item after the change. + NewContent *ItemContent `json:"newContent,omitempty"` + // Path of the item on the server. + SourceServerItem *string `json:"sourceServerItem,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` +} + +type ChangeCountDictionary struct { +} + +type ChangeList struct { + AllChangesIncluded *bool `json:"allChangesIncluded,omitempty"` + ChangeCounts *map[VersionControlChangeType]int `json:"changeCounts,omitempty"` + Changes *[]interface{} `json:"changes,omitempty"` + Comment *string `json:"comment,omitempty"` + CommentTruncated *bool `json:"commentTruncated,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + Notes *[]CheckinNote `json:"notes,omitempty"` + Owner *string `json:"owner,omitempty"` + OwnerDisplayName *string `json:"ownerDisplayName,omitempty"` + OwnerId *uuid.UUID `json:"ownerId,omitempty"` + SortDate *azuredevops.Time `json:"sortDate,omitempty"` + Version *string `json:"version,omitempty"` +} + +// Criteria used in a search for change lists +type ChangeListSearchCriteria struct { + // If provided, a version descriptor to compare against base + CompareVersion *string `json:"compareVersion,omitempty"` + // If true, don't include delete history entries + ExcludeDeletes *bool `json:"excludeDeletes,omitempty"` + // Whether or not to follow renames for the given item being queried + FollowRenames *bool `json:"followRenames,omitempty"` + // If provided, only include history entries created after this date (string) + FromDate *string `json:"fromDate,omitempty"` + // If provided, a version descriptor for the earliest change list to include + FromVersion *string `json:"fromVersion,omitempty"` + // Path of item to search under. If the itemPaths memebr is used then it will take precedence over this. + ItemPath *string `json:"itemPath,omitempty"` + // List of item paths to search under. If this member is used then itemPath will be ignored. + ItemPaths *[]string `json:"itemPaths,omitempty"` + // Version of the items to search + ItemVersion *string `json:"itemVersion,omitempty"` + // Number of results to skip (used when clicking more...) + Skip *int `json:"skip,omitempty"` + // If provided, only include history entries created before this date (string) + ToDate *string `json:"toDate,omitempty"` + // If provided, the maximum number of history entries to return + Top *int `json:"top,omitempty"` + // If provided, a version descriptor for the latest change list to include + ToVersion *string `json:"toVersion,omitempty"` + // Alias or display name of user who made the changes + User *string `json:"user,omitempty"` +} + +type CheckinNote struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Represents a comment which is one of potentially many in a comment thread. +type Comment struct { + // Links to other related objects. + Links interface{} `json:"_links,omitempty"` + // The author of the comment. + Author *webapi.IdentityRef `json:"author,omitempty"` + // The comment type at the time of creation. + CommentType *CommentType `json:"commentType,omitempty"` + // The comment content. + Content *string `json:"content,omitempty"` + // The comment ID. IDs start at 1 and are unique to a pull request. + Id *int `json:"id,omitempty"` + // Whether or not this comment was soft-deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // The date the comment's content was last updated. + LastContentUpdatedDate *azuredevops.Time `json:"lastContentUpdatedDate,omitempty"` + // The date the comment was last updated. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // The ID of the parent comment. This is used for replies. + ParentCommentId *int `json:"parentCommentId,omitempty"` + // The date the comment was first published. + PublishedDate *azuredevops.Time `json:"publishedDate,omitempty"` + // A list of the users who have liked this comment. + UsersLiked *[]webapi.IdentityRef `json:"usersLiked,omitempty"` +} + +// Comment iteration context is used to identify which diff was being viewed when the thread was created. +type CommentIterationContext struct { + // The iteration of the file on the left side of the diff when the thread was created. If this value is equal to SecondComparingIteration, then this version is the common commit between the source and target branches of the pull request. + FirstComparingIteration *int `json:"firstComparingIteration,omitempty"` + // The iteration of the file on the right side of the diff when the thread was created. + SecondComparingIteration *int `json:"secondComparingIteration,omitempty"` +} + +type CommentPosition struct { + // The line number of a thread's position. Starts at 1. + Line *int `json:"line,omitempty"` + // The character offset of a thread's position inside of a line. Starts at 0. + Offset *int `json:"offset,omitempty"` +} + +// Represents a comment thread of a pull request. A thread contains meta data about the file it was left on along with one or more comments (an initial comment and the subsequent replies). +type CommentThread struct { + // Links to other related objects. + Links interface{} `json:"_links,omitempty"` + // A list of the comments. + Comments *[]Comment `json:"comments,omitempty"` + // The comment thread id. + Id *int `json:"id,omitempty"` + // Set of identities related to this thread + Identities *map[string]webapi.IdentityRef `json:"identities,omitempty"` + // Specify if the thread is deleted which happens when all comments are deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // The time this thread was last updated. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Optional properties associated with the thread as a collection of key-value pairs. + Properties interface{} `json:"properties,omitempty"` + // The time this thread was published. + PublishedDate *azuredevops.Time `json:"publishedDate,omitempty"` + // The status of the comment thread. + Status *CommentThreadStatus `json:"status,omitempty"` + // Specify thread context such as position in left/right file. + ThreadContext *CommentThreadContext `json:"threadContext,omitempty"` +} + +type CommentThreadContext struct { + // File path relative to the root of the repository. It's up to the client to use any path format. + FilePath *string `json:"filePath,omitempty"` + // Position of last character of the thread's span in left file. + LeftFileEnd *CommentPosition `json:"leftFileEnd,omitempty"` + // Position of first character of the thread's span in left file. + LeftFileStart *CommentPosition `json:"leftFileStart,omitempty"` + // Position of last character of the thread's span in right file. + RightFileEnd *CommentPosition `json:"rightFileEnd,omitempty"` + // Position of first character of the thread's span in right file. + RightFileStart *CommentPosition `json:"rightFileStart,omitempty"` +} + +// The status of a comment thread. +type CommentThreadStatus string + +type commentThreadStatusValuesType struct { + Unknown CommentThreadStatus + Active CommentThreadStatus + Fixed CommentThreadStatus + WontFix CommentThreadStatus + Closed CommentThreadStatus + ByDesign CommentThreadStatus + Pending CommentThreadStatus +} + +var CommentThreadStatusValues = commentThreadStatusValuesType{ + // The thread status is unknown. + Unknown: "unknown", + // The thread status is active. + Active: "active", + // The thread status is resolved as fixed. + Fixed: "fixed", + // The thread status is resolved as won't fix. + WontFix: "wontFix", + // The thread status is closed. + Closed: "closed", + // The thread status is resolved as by design. + ByDesign: "byDesign", + // The thread status is pending. + Pending: "pending", +} + +// Comment tracking criteria is used to identify which iteration context the thread has been tracked to (if any) along with some detail about the original position and filename. +type CommentTrackingCriteria struct { + // The iteration of the file on the left side of the diff that the thread will be tracked to. Threads were tracked if this is greater than 0. + FirstComparingIteration *int `json:"firstComparingIteration,omitempty"` + // Original filepath the thread was created on before tracking. This will be different than the current thread filepath if the file in question was renamed in a later iteration. + OrigFilePath *string `json:"origFilePath,omitempty"` + // Original position of last character of the thread's span in left file. + OrigLeftFileEnd *CommentPosition `json:"origLeftFileEnd,omitempty"` + // Original position of first character of the thread's span in left file. + OrigLeftFileStart *CommentPosition `json:"origLeftFileStart,omitempty"` + // Original position of last character of the thread's span in right file. + OrigRightFileEnd *CommentPosition `json:"origRightFileEnd,omitempty"` + // Original position of first character of the thread's span in right file. + OrigRightFileStart *CommentPosition `json:"origRightFileStart,omitempty"` + // The iteration of the file on the right side of the diff that the thread will be tracked to. Threads were tracked if this is greater than 0. + SecondComparingIteration *int `json:"secondComparingIteration,omitempty"` +} + +// The type of a comment. +type CommentType string + +type commentTypeValuesType struct { + Unknown CommentType + Text CommentType + CodeChange CommentType + System CommentType +} + +var CommentTypeValues = commentTypeValuesType{ + // The comment type is not known. + Unknown: "unknown", + // This is a regular user comment. + Text: "text", + // The comment comes as a result of a code change. + CodeChange: "codeChange", + // The comment represents a system message. + System: "system", +} + +// Real time event (SignalR) for a completion errors on a pull request +type CompletionErrorsEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` + // The error message associated with the completion error + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// Real time event (SignalR) for a discussions update on a pull request +type DiscussionsUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +type FileContentMetadata struct { + ContentType *string `json:"contentType,omitempty"` + Encoding *int `json:"encoding,omitempty"` + Extension *string `json:"extension,omitempty"` + FileName *string `json:"fileName,omitempty"` + IsBinary *bool `json:"isBinary,omitempty"` + IsImage *bool `json:"isImage,omitempty"` + VsLink *string `json:"vsLink,omitempty"` +} + +// Provides properties that describe file differences +type FileDiff struct { + // The collection of line diff blocks + LineDiffBlocks *[]LineDiffBlock `json:"lineDiffBlocks,omitempty"` + // Original path of item if different from current path. + OriginalPath *string `json:"originalPath,omitempty"` + // Current path of item + Path *string `json:"path,omitempty"` +} + +// Provides parameters that describe inputs for the file diff +type FileDiffParams struct { + // Original path of the file + OriginalPath *string `json:"originalPath,omitempty"` + // Current path of the file + Path *string `json:"path,omitempty"` +} + +// Provides properties that describe inputs for the file diffs +type FileDiffsCriteria struct { + // Commit ID of the base version + BaseVersionCommit *string `json:"baseVersionCommit,omitempty"` + // List of parameters for each of the files for which we need to get the file diff + FileDiffParams *[]FileDiffParams `json:"fileDiffParams,omitempty"` + // Commit ID of the target version + TargetVersionCommit *string `json:"targetVersionCommit,omitempty"` +} + +// A Git annotated tag. +type GitAnnotatedTag struct { + // The tagging Message + Message *string `json:"message,omitempty"` + // The name of the annotated tag. + Name *string `json:"name,omitempty"` + // The objectId (Sha1Id) of the tag. + ObjectId *string `json:"objectId,omitempty"` + // User info and date of tagging. + TaggedBy *GitUserDate `json:"taggedBy,omitempty"` + // Tagged git object. + TaggedObject *GitObject `json:"taggedObject,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Current status of the asynchronous operation. +type GitAsyncOperationStatus string + +type gitAsyncOperationStatusValuesType struct { + Queued GitAsyncOperationStatus + InProgress GitAsyncOperationStatus + Completed GitAsyncOperationStatus + Failed GitAsyncOperationStatus + Abandoned GitAsyncOperationStatus +} + +var GitAsyncOperationStatusValues = gitAsyncOperationStatusValuesType{ + // The operation is waiting in a queue and has not yet started. + Queued: "queued", + // The operation is currently in progress. + InProgress: "inProgress", + // The operation has completed. + Completed: "completed", + // The operation has failed. Check for an error message. + Failed: "failed", + // The operation has been abandoned. + Abandoned: "abandoned", +} + +type GitAsyncRefOperation struct { + Links interface{} `json:"_links,omitempty"` + DetailedStatus *GitAsyncRefOperationDetail `json:"detailedStatus,omitempty"` + Parameters *GitAsyncRefOperationParameters `json:"parameters,omitempty"` + Status *GitAsyncOperationStatus `json:"status,omitempty"` + // A URL that can be used to make further requests for status about the operation + Url *string `json:"url,omitempty"` +} + +// Information about the progress of a cherry pick or revert operation. +type GitAsyncRefOperationDetail struct { + // Indicates if there was a conflict generated when trying to cherry pick or revert the changes. + Conflict *bool `json:"conflict,omitempty"` + // The current commit from the list of commits that are being cherry picked or reverted. + CurrentCommitId *string `json:"currentCommitId,omitempty"` + // Detailed information about why the cherry pick or revert failed to complete. + FailureMessage *string `json:"failureMessage,omitempty"` + // A number between 0 and 1 indicating the percent complete of the operation. + Progress *float64 `json:"progress,omitempty"` + // Provides a status code that indicates the reason the cherry pick or revert failed. + Status *GitAsyncRefOperationFailureStatus `json:"status,omitempty"` + // Indicates if the operation went beyond the maximum time allowed for a cherry pick or revert operation. + Timedout *bool `json:"timedout,omitempty"` +} + +type GitAsyncRefOperationFailureStatus string + +type gitAsyncRefOperationFailureStatusValuesType struct { + None GitAsyncRefOperationFailureStatus + InvalidRefName GitAsyncRefOperationFailureStatus + RefNameConflict GitAsyncRefOperationFailureStatus + CreateBranchPermissionRequired GitAsyncRefOperationFailureStatus + WritePermissionRequired GitAsyncRefOperationFailureStatus + TargetBranchDeleted GitAsyncRefOperationFailureStatus + GitObjectTooLarge GitAsyncRefOperationFailureStatus + OperationIndentityNotFound GitAsyncRefOperationFailureStatus + AsyncOperationNotFound GitAsyncRefOperationFailureStatus + Other GitAsyncRefOperationFailureStatus + EmptyCommitterSignature GitAsyncRefOperationFailureStatus +} + +var GitAsyncRefOperationFailureStatusValues = gitAsyncRefOperationFailureStatusValuesType{ + // No status + None: "none", + // Indicates that the ref update request could not be completed because the ref name presented in the request was not valid. + InvalidRefName: "invalidRefName", + // The ref update could not be completed because, in case-insensitive mode, the ref name conflicts with an existing, differently-cased ref name. + RefNameConflict: "refNameConflict", + // The ref update request could not be completed because the user lacks the permission to create a branch + CreateBranchPermissionRequired: "createBranchPermissionRequired", + // The ref update request could not be completed because the user lacks write permissions required to write this ref + WritePermissionRequired: "writePermissionRequired", + // Target branch was deleted after Git async operation started + TargetBranchDeleted: "targetBranchDeleted", + // Git object is too large to materialize into memory + GitObjectTooLarge: "gitObjectTooLarge", + // Identity who authorized the operation was not found + OperationIndentityNotFound: "operationIndentityNotFound", + // Async operation was not found + AsyncOperationNotFound: "asyncOperationNotFound", + // Unexpected failure + Other: "other", + // Initiator of async operation has signature with empty name or email + EmptyCommitterSignature: "emptyCommitterSignature", +} + +// Parameters that are provided in the request body when requesting to cherry pick or revert. +type GitAsyncRefOperationParameters struct { + // Proposed target branch name for the cherry pick or revert operation. + GeneratedRefName *string `json:"generatedRefName,omitempty"` + // The target branch for the cherry pick or revert operation. + OntoRefName *string `json:"ontoRefName,omitempty"` + // The git repository for the cherry pick or revert operation. + Repository *GitRepository `json:"repository,omitempty"` + // Details about the source of the cherry pick or revert operation (e.g. A pull request or a specific commit). + Source *GitAsyncRefOperationSource `json:"source,omitempty"` +} + +// GitAsyncRefOperationSource specifies the pull request or list of commits to use when making a cherry pick and revert operation request. Only one should be provided. +type GitAsyncRefOperationSource struct { + // A list of commits to cherry pick or revert + CommitList *[]GitCommitRef `json:"commitList,omitempty"` + // Id of the pull request to cherry pick or revert + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +type GitBaseVersionDescriptor struct { + // Version string identifier (name of tag/branch, SHA1 of commit) + Version *string `json:"version,omitempty"` + // Version options - Specify additional modifiers to version (e.g Previous) + VersionOptions *GitVersionOptions `json:"versionOptions,omitempty"` + // Version type (branch, tag, or commit). Determines how Id is interpreted + VersionType *GitVersionType `json:"versionType,omitempty"` + // Version string identifier (name of tag/branch, SHA1 of commit) + BaseVersion *string `json:"baseVersion,omitempty"` + // Version options - Specify additional modifiers to version (e.g Previous) + BaseVersionOptions *GitVersionOptions `json:"baseVersionOptions,omitempty"` + // Version type (branch, tag, or commit). Determines how Id is interpreted + BaseVersionType *GitVersionType `json:"baseVersionType,omitempty"` +} + +type GitBlobRef struct { + Links interface{} `json:"_links,omitempty"` + // SHA1 hash of git object + ObjectId *string `json:"objectId,omitempty"` + // Size of blob content (in bytes) + Size *uint64 `json:"size,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Ahead and behind counts for a particular ref. +type GitBranchStats struct { + // Number of commits ahead. + AheadCount *int `json:"aheadCount,omitempty"` + // Number of commits behind. + BehindCount *int `json:"behindCount,omitempty"` + // Current commit. + Commit *GitCommitRef `json:"commit,omitempty"` + // True if this is the result for the base version. + IsBaseVersion *bool `json:"isBaseVersion,omitempty"` + // Name of the ref. + Name *string `json:"name,omitempty"` +} + +type GitChange struct { + // The type of change that was made to the item. + ChangeType *VersionControlChangeType `json:"changeType,omitempty"` + // Current version. + Item interface{} `json:"item,omitempty"` + // Content of the item after the change. + NewContent *ItemContent `json:"newContent,omitempty"` + // Path of the item on the server. + SourceServerItem *string `json:"sourceServerItem,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` + // ID of the change within the group of changes. + ChangeId *int `json:"changeId,omitempty"` + // New Content template to be used when pushing new changes. + NewContentTemplate *GitTemplate `json:"newContentTemplate,omitempty"` + // Original path of item if different from current path. + OriginalPath *string `json:"originalPath,omitempty"` +} + +// This object is returned from Cherry Pick operations and provides the id and status of the operation +type GitCherryPick struct { + Links interface{} `json:"_links,omitempty"` + DetailedStatus *GitAsyncRefOperationDetail `json:"detailedStatus,omitempty"` + Parameters *GitAsyncRefOperationParameters `json:"parameters,omitempty"` + Status *GitAsyncOperationStatus `json:"status,omitempty"` + // A URL that can be used to make further requests for status about the operation + Url *string `json:"url,omitempty"` + CherryPickId *int `json:"cherryPickId,omitempty"` +} + +type GitCommit struct { + // A collection of related REST reference links. + Links interface{} `json:"_links,omitempty"` + // Author of the commit. + Author *GitUserDate `json:"author,omitempty"` + // Counts of the types of changes (edits, deletes, etc.) included with the commit. + ChangeCounts *ChangeCountDictionary `json:"changeCounts,omitempty"` + // An enumeration of the changes included with the commit. + Changes *[]interface{} `json:"changes,omitempty"` + // Comment or message of the commit. + Comment *string `json:"comment,omitempty"` + // Indicates if the comment is truncated from the full Git commit comment message. + CommentTruncated *bool `json:"commentTruncated,omitempty"` + // ID (SHA-1) of the commit. + CommitId *string `json:"commitId,omitempty"` + // Committer of the commit. + Committer *GitUserDate `json:"committer,omitempty"` + // An enumeration of the parent commit IDs for this commit. + Parents *[]string `json:"parents,omitempty"` + // The push associated with this commit. + Push *GitPushRef `json:"push,omitempty"` + // Remote URL path to the commit. + RemoteUrl *string `json:"remoteUrl,omitempty"` + // A list of status metadata from services and extensions that may associate additional information to the commit. + Statuses *[]GitStatus `json:"statuses,omitempty"` + // REST URL for this resource. + Url *string `json:"url,omitempty"` + // A list of workitems associated with this commit. + WorkItems *[]webapi.ResourceRef `json:"workItems,omitempty"` + TreeId *string `json:"treeId,omitempty"` +} + +type GitCommitChanges struct { + ChangeCounts *ChangeCountDictionary `json:"changeCounts,omitempty"` + Changes *[]interface{} `json:"changes,omitempty"` +} + +type GitCommitDiffs struct { + AheadCount *int `json:"aheadCount,omitempty"` + AllChangesIncluded *bool `json:"allChangesIncluded,omitempty"` + BaseCommit *string `json:"baseCommit,omitempty"` + BehindCount *int `json:"behindCount,omitempty"` + ChangeCounts *map[VersionControlChangeType]int `json:"changeCounts,omitempty"` + Changes *[]interface{} `json:"changes,omitempty"` + CommonCommit *string `json:"commonCommit,omitempty"` + TargetCommit *string `json:"targetCommit,omitempty"` +} + +// Provides properties that describe a Git commit and associated metadata. +type GitCommitRef struct { + // A collection of related REST reference links. + Links interface{} `json:"_links,omitempty"` + // Author of the commit. + Author *GitUserDate `json:"author,omitempty"` + // Counts of the types of changes (edits, deletes, etc.) included with the commit. + ChangeCounts *ChangeCountDictionary `json:"changeCounts,omitempty"` + // An enumeration of the changes included with the commit. + Changes *[]interface{} `json:"changes,omitempty"` + // Comment or message of the commit. + Comment *string `json:"comment,omitempty"` + // Indicates if the comment is truncated from the full Git commit comment message. + CommentTruncated *bool `json:"commentTruncated,omitempty"` + // ID (SHA-1) of the commit. + CommitId *string `json:"commitId,omitempty"` + // Committer of the commit. + Committer *GitUserDate `json:"committer,omitempty"` + // An enumeration of the parent commit IDs for this commit. + Parents *[]string `json:"parents,omitempty"` + // The push associated with this commit. + Push *GitPushRef `json:"push,omitempty"` + // Remote URL path to the commit. + RemoteUrl *string `json:"remoteUrl,omitempty"` + // A list of status metadata from services and extensions that may associate additional information to the commit. + Statuses *[]GitStatus `json:"statuses,omitempty"` + // REST URL for this resource. + Url *string `json:"url,omitempty"` + // A list of workitems associated with this commit. + WorkItems *[]webapi.ResourceRef `json:"workItems,omitempty"` +} + +type GitCommitToCreate struct { + BaseRef *GitRef `json:"baseRef,omitempty"` + Comment *string `json:"comment,omitempty"` + PathActions *[]GitPathAction `json:"pathActions,omitempty"` +} + +type GitConflict struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Data object for AddAdd conflict +type GitConflictAddAdd struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + Resolution *GitResolutionMergeContent `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` +} + +// Data object for RenameAdd conflict +type GitConflictAddRename struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionPathConflict `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` + TargetOriginalPath *string `json:"targetOriginalPath,omitempty"` +} + +// Data object for EditDelete conflict +type GitConflictDeleteEdit struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionPickOneAction `json:"resolution,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` +} + +// Data object for RenameDelete conflict +type GitConflictDeleteRename struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionPickOneAction `json:"resolution,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` + TargetNewPath *string `json:"targetNewPath,omitempty"` +} + +// Data object for FileDirectory conflict +type GitConflictDirectoryFile struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + Resolution *GitResolutionPathConflict `json:"resolution,omitempty"` + SourceTree *GitTreeRef `json:"sourceTree,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` +} + +// Data object for DeleteEdit conflict +type GitConflictEditDelete struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionPickOneAction `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` +} + +// Data object for EditEdit conflict +type GitConflictEditEdit struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionMergeContent `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` +} + +// Data object for DirectoryFile conflict +type GitConflictFileDirectory struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + Resolution *GitResolutionPathConflict `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + TargetTree *GitTreeRef `json:"targetTree,omitempty"` +} + +// Data object for Rename1to2 conflict +type GitConflictRename1to2 struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionRename1to2 `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + SourceNewPath *string `json:"sourceNewPath,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` + TargetNewPath *string `json:"targetNewPath,omitempty"` +} + +// Data object for Rename2to1 conflict +type GitConflictRename2to1 struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + Resolution *GitResolutionPathConflict `json:"resolution,omitempty"` + SourceNewBlob *GitBlobRef `json:"sourceNewBlob,omitempty"` + SourceOriginalBlob *GitBlobRef `json:"sourceOriginalBlob,omitempty"` + SourceOriginalPath *string `json:"sourceOriginalPath,omitempty"` + TargetNewBlob *GitBlobRef `json:"targetNewBlob,omitempty"` + TargetOriginalBlob *GitBlobRef `json:"targetOriginalBlob,omitempty"` + TargetOriginalPath *string `json:"targetOriginalPath,omitempty"` +} + +// Data object for AddRename conflict +type GitConflictRenameAdd struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionPathConflict `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + SourceOriginalPath *string `json:"sourceOriginalPath,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` +} + +// Data object for DeleteRename conflict +type GitConflictRenameDelete struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + Resolution *GitResolutionPickOneAction `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + SourceNewPath *string `json:"sourceNewPath,omitempty"` +} + +// Data object for RenameRename conflict +type GitConflictRenameRename struct { + Links interface{} `json:"_links,omitempty"` + ConflictId *int `json:"conflictId,omitempty"` + ConflictPath *string `json:"conflictPath,omitempty"` + ConflictType *GitConflictType `json:"conflictType,omitempty"` + MergeBaseCommit *GitCommitRef `json:"mergeBaseCommit,omitempty"` + MergeOrigin *GitMergeOriginRef `json:"mergeOrigin,omitempty"` + MergeSourceCommit *GitCommitRef `json:"mergeSourceCommit,omitempty"` + MergeTargetCommit *GitCommitRef `json:"mergeTargetCommit,omitempty"` + ResolutionError *GitResolutionError `json:"resolutionError,omitempty"` + ResolutionStatus *GitResolutionStatus `json:"resolutionStatus,omitempty"` + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` + ResolvedDate *azuredevops.Time `json:"resolvedDate,omitempty"` + Url *string `json:"url,omitempty"` + BaseBlob *GitBlobRef `json:"baseBlob,omitempty"` + OriginalPath *string `json:"originalPath,omitempty"` + Resolution *GitResolutionMergeContent `json:"resolution,omitempty"` + SourceBlob *GitBlobRef `json:"sourceBlob,omitempty"` + TargetBlob *GitBlobRef `json:"targetBlob,omitempty"` +} + +// The type of a merge conflict. +type GitConflictType string + +type gitConflictTypeValuesType struct { + None GitConflictType + AddAdd GitConflictType + AddRename GitConflictType + DeleteEdit GitConflictType + DeleteRename GitConflictType + DirectoryFile GitConflictType + DirectoryChild GitConflictType + EditDelete GitConflictType + EditEdit GitConflictType + FileDirectory GitConflictType + Rename1to2 GitConflictType + Rename2to1 GitConflictType + RenameAdd GitConflictType + RenameDelete GitConflictType + RenameRename GitConflictType +} + +var GitConflictTypeValues = gitConflictTypeValuesType{ + // No conflict + None: "none", + // Added on source and target; content differs + AddAdd: "addAdd", + // Added on source and rename destination on target + AddRename: "addRename", + // Deleted on source and edited on target + DeleteEdit: "deleteEdit", + // Deleted on source and renamed on target + DeleteRename: "deleteRename", + // Path is a directory on source and a file on target + DirectoryFile: "directoryFile", + // Children of directory which has DirectoryFile or FileDirectory conflict + DirectoryChild: "directoryChild", + // Edited on source and deleted on target + EditDelete: "editDelete", + // Edited on source and target; content differs + EditEdit: "editEdit", + // Path is a file on source and a directory on target + FileDirectory: "fileDirectory", + // Same file renamed on both source and target; destination paths differ + Rename1to2: "rename1to2", + // Different files renamed to same destination path on both source and target + Rename2to1: "rename2to1", + // Rename destination on source and new file on target + RenameAdd: "renameAdd", + // Renamed on source and deleted on target + RenameDelete: "renameDelete", + // Rename destination on both source and target; content differs + RenameRename: "renameRename", +} + +type GitConflictUpdateResult struct { + // Conflict ID that was provided by input + ConflictId *int `json:"conflictId,omitempty"` + // Reason for failing + CustomMessage *string `json:"customMessage,omitempty"` + // New state of the conflict after updating + UpdatedConflict *GitConflict `json:"updatedConflict,omitempty"` + // Status of the update on the server + UpdateStatus *GitConflictUpdateStatus `json:"updateStatus,omitempty"` +} + +// Represents the possible outcomes from a request to update a pull request conflict +type GitConflictUpdateStatus string + +type gitConflictUpdateStatusValuesType struct { + Succeeded GitConflictUpdateStatus + BadRequest GitConflictUpdateStatus + InvalidResolution GitConflictUpdateStatus + UnsupportedConflictType GitConflictUpdateStatus + NotFound GitConflictUpdateStatus +} + +var GitConflictUpdateStatusValues = gitConflictUpdateStatusValuesType{ + // Indicates that pull request conflict update request was completed successfully + Succeeded: "succeeded", + // Indicates that the update request did not fit the expected data contract + BadRequest: "badRequest", + // Indicates that the requested resolution was not valid + InvalidResolution: "invalidResolution", + // Indicates that the conflict in the update request was not a supported conflict type + UnsupportedConflictType: "unsupportedConflictType", + // Indicates that the conflict could not be found + NotFound: "notFound", +} + +type GitDeletedRepository struct { + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + DeletedBy *webapi.IdentityRef `json:"deletedBy,omitempty"` + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Project *core.TeamProjectReference `json:"project,omitempty"` +} + +type GitFilePathsCollection struct { + CommitId *string `json:"commitId,omitempty"` + Paths *[]string `json:"paths,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Status information about a requested fork operation. +type GitForkOperationStatusDetail struct { + // All valid steps for the forking process + AllSteps *[]string `json:"allSteps,omitempty"` + // Index into AllSteps for the current step + CurrentStep *int `json:"currentStep,omitempty"` + // Error message if the operation failed. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// Information about a fork ref. +type GitForkRef struct { + Links interface{} `json:"_links,omitempty"` + Creator *webapi.IdentityRef `json:"creator,omitempty"` + IsLocked *bool `json:"isLocked,omitempty"` + IsLockedBy *webapi.IdentityRef `json:"isLockedBy,omitempty"` + Name *string `json:"name,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + PeeledObjectId *string `json:"peeledObjectId,omitempty"` + Statuses *[]GitStatus `json:"statuses,omitempty"` + Url *string `json:"url,omitempty"` + // The repository ID of the fork. + Repository *GitRepository `json:"repository,omitempty"` +} + +// Request to sync data between two forks. +type GitForkSyncRequest struct { + // Collection of related links + Links interface{} `json:"_links,omitempty"` + DetailedStatus *GitForkOperationStatusDetail `json:"detailedStatus,omitempty"` + // Unique identifier for the operation. + OperationId *int `json:"operationId,omitempty"` + // Fully-qualified identifier for the source repository. + Source *GlobalGitRepositoryKey `json:"source,omitempty"` + // If supplied, the set of ref mappings to use when performing a "sync" or create. If missing, all refs will be synchronized. + SourceToTargetRefs *[]SourceToTargetRef `json:"sourceToTargetRefs,omitempty"` + Status *GitAsyncOperationStatus `json:"status,omitempty"` +} + +// Parameters for creating a fork request +type GitForkSyncRequestParameters struct { + // Fully-qualified identifier for the source repository. + Source *GlobalGitRepositoryKey `json:"source,omitempty"` + // If supplied, the set of ref mappings to use when performing a "sync" or create. If missing, all refs will be synchronized. + SourceToTargetRefs *[]SourceToTargetRef `json:"sourceToTargetRefs,omitempty"` +} + +type GitForkTeamProjectReference struct { + // Project abbreviation. + Abbreviation *string `json:"abbreviation,omitempty"` + // Url to default team identity image. + DefaultTeamImageUrl *string `json:"defaultTeamImageUrl,omitempty"` + // The project's description (if any). + Description *string `json:"description,omitempty"` + // Project identifier. + Id *uuid.UUID `json:"id,omitempty"` + // Project last update time. + LastUpdateTime *azuredevops.Time `json:"lastUpdateTime,omitempty"` + // Project name. + Name *string `json:"name,omitempty"` + // Project revision. + Revision *uint64 `json:"revision,omitempty"` + // Project state. + State *core.ProjectState `json:"state,omitempty"` + // Url to the full version of the object. + Url *string `json:"url,omitempty"` + // Project visibility. + Visibility *core.ProjectVisibility `json:"visibility,omitempty"` +} + +// Accepted types of version +type GitHistoryMode string + +type gitHistoryModeValuesType struct { + SimplifiedHistory GitHistoryMode + FirstParent GitHistoryMode + FullHistory GitHistoryMode + FullHistorySimplifyMerges GitHistoryMode +} + +var GitHistoryModeValues = gitHistoryModeValuesType{ + // The history mode used by `git log`. This is the default. + SimplifiedHistory: "simplifiedHistory", + // The history mode used by `git log --first-parent` + FirstParent: "firstParent", + // The history mode used by `git log --full-history` + FullHistory: "fullHistory", + // The history mode used by `git log --full-history --simplify-merges` + FullHistorySimplifyMerges: "fullHistorySimplifyMerges", +} + +type GitImportFailedEvent struct { + SourceRepositoryName *string `json:"sourceRepositoryName,omitempty"` + TargetRepository *GitRepository `json:"targetRepository,omitempty"` +} + +// Parameter for creating a git import request when source is Git version control +type GitImportGitSource struct { + // Tells if this is a sync request or not + Overwrite *bool `json:"overwrite,omitempty"` + // Url for the source repo + Url *string `json:"url,omitempty"` +} + +// A request to import data from a remote source control system. +type GitImportRequest struct { + // Links to related resources. + Links interface{} `json:"_links,omitempty"` + // Detailed status of the import, including the current step and an error message, if applicable. + DetailedStatus *GitImportStatusDetail `json:"detailedStatus,omitempty"` + // The unique identifier for this import request. + ImportRequestId *int `json:"importRequestId,omitempty"` + // Parameters for creating the import request. + Parameters *GitImportRequestParameters `json:"parameters,omitempty"` + // The target repository for this import. + Repository *GitRepository `json:"repository,omitempty"` + // Current status of the import. + Status *GitAsyncOperationStatus `json:"status,omitempty"` + // A link back to this import request resource. + Url *string `json:"url,omitempty"` +} + +// Parameters for creating an import request +type GitImportRequestParameters struct { + // Option to delete service endpoint when import is done + DeleteServiceEndpointAfterImportIsDone *bool `json:"deleteServiceEndpointAfterImportIsDone,omitempty"` + // Source for importing git repository + GitSource *GitImportGitSource `json:"gitSource,omitempty"` + // Service Endpoint for connection to external endpoint + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` + // Source for importing tfvc repository + TfvcSource *GitImportTfvcSource `json:"tfvcSource,omitempty"` +} + +// Additional status information about an import request. +type GitImportStatusDetail struct { + // All valid steps for the import process + AllSteps *[]string `json:"allSteps,omitempty"` + // Index into AllSteps for the current step + CurrentStep *int `json:"currentStep,omitempty"` + // Error message if the operation failed. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +type GitImportSucceededEvent struct { + SourceRepositoryName *string `json:"sourceRepositoryName,omitempty"` + TargetRepository *GitRepository `json:"targetRepository,omitempty"` +} + +// Parameter for creating a git import request when source is tfvc version control +type GitImportTfvcSource struct { + // Set true to import History, false otherwise + ImportHistory *bool `json:"importHistory,omitempty"` + // Get history for last n days (max allowed value is 180 days) + ImportHistoryDurationInDays *int `json:"importHistoryDurationInDays,omitempty"` + // Path which we want to import (this can be copied from Path Control in Explorer) + Path *string `json:"path,omitempty"` +} + +type GitItem struct { + Links interface{} `json:"_links,omitempty"` + Content *string `json:"content,omitempty"` + ContentMetadata *FileContentMetadata `json:"contentMetadata,omitempty"` + IsFolder *bool `json:"isFolder,omitempty"` + IsSymLink *bool `json:"isSymLink,omitempty"` + Path *string `json:"path,omitempty"` + Url *string `json:"url,omitempty"` + // SHA1 of commit item was fetched at + CommitId *string `json:"commitId,omitempty"` + // Type of object (Commit, Tree, Blob, Tag, ...) + GitObjectType *GitObjectType `json:"gitObjectType,omitempty"` + // Shallow ref to commit that last changed this item Only populated if latestProcessedChange is requested May not be accurate if latest change is not yet cached + LatestProcessedChange *GitCommitRef `json:"latestProcessedChange,omitempty"` + // Git object id + ObjectId *string `json:"objectId,omitempty"` + // Git object id + OriginalObjectId *string `json:"originalObjectId,omitempty"` +} + +type GitItemDescriptor struct { + // Path to item + Path *string `json:"path,omitempty"` + // Specifies whether to include children (OneLevel), all descendants (Full), or None + RecursionLevel *VersionControlRecursionType `json:"recursionLevel,omitempty"` + // Version string (interpretation based on VersionType defined in subclass + Version *string `json:"version,omitempty"` + // Version modifiers (e.g. previous) + VersionOptions *GitVersionOptions `json:"versionOptions,omitempty"` + // How to interpret version (branch,tag,commit) + VersionType *GitVersionType `json:"versionType,omitempty"` +} + +type GitItemRequestData struct { + // Whether to include metadata for all items + IncludeContentMetadata *bool `json:"includeContentMetadata,omitempty"` + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` + // Collection of items to fetch, including path, version, and recursion level + ItemDescriptors *[]GitItemDescriptor `json:"itemDescriptors,omitempty"` + // Whether to include shallow ref to commit that last changed each item + LatestProcessedChange *bool `json:"latestProcessedChange,omitempty"` +} + +type GitLastChangeItem struct { + // Gets or sets the commit Id this item was modified most recently for the provided version. + CommitId *string `json:"commitId,omitempty"` + // Gets or sets the path of the item. + Path *string `json:"path,omitempty"` +} + +type GitLastChangeTreeItems struct { + // The list of commits referenced by Items, if they were requested. + Commits *[]GitCommitRef `json:"commits,omitempty"` + // The last change of items. + Items *[]GitLastChangeItem `json:"items,omitempty"` + // The last explored time, in case the result is not comprehensive. Null otherwise. + LastExploredTime *azuredevops.Time `json:"lastExploredTime,omitempty"` +} + +type GitMerge struct { + // Comment or message of the commit. + Comment *string `json:"comment,omitempty"` + // An enumeration of the parent commit IDs for the merge commit. + Parents *[]string `json:"parents,omitempty"` + // Reference links. + Links interface{} `json:"_links,omitempty"` + // Detailed status of the merge operation. + DetailedStatus *GitMergeOperationStatusDetail `json:"detailedStatus,omitempty"` + // Unique identifier for the merge operation. + MergeOperationId *int `json:"mergeOperationId,omitempty"` + // Status of the merge operation. + Status *GitAsyncOperationStatus `json:"status,omitempty"` +} + +// Status information about a requested merge operation. +type GitMergeOperationStatusDetail struct { + // Error message if the operation failed. + FailureMessage *string `json:"failureMessage,omitempty"` + // The commitId of the resultant merge commit. + MergeCommitId *string `json:"mergeCommitId,omitempty"` +} + +type GitMergeOriginRef struct { + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Parameters required for performing git merge. +type GitMergeParameters struct { + // Comment or message of the commit. + Comment *string `json:"comment,omitempty"` + // An enumeration of the parent commit IDs for the merge commit. + Parents *[]string `json:"parents,omitempty"` +} + +// Git object identifier and type information. +type GitObject struct { + // Object Id (Sha1Id). + ObjectId *string `json:"objectId,omitempty"` + // Type of object (Commit, Tree, Blob, Tag) + ObjectType *GitObjectType `json:"objectType,omitempty"` +} + +type GitObjectType string + +type gitObjectTypeValuesType struct { + Bad GitObjectType + Commit GitObjectType + Tree GitObjectType + Blob GitObjectType + Tag GitObjectType + Ext2 GitObjectType + OfsDelta GitObjectType + RefDelta GitObjectType +} + +var GitObjectTypeValues = gitObjectTypeValuesType{ + Bad: "bad", + Commit: "commit", + Tree: "tree", + Blob: "blob", + Tag: "tag", + Ext2: "ext2", + OfsDelta: "ofsDelta", + RefDelta: "refDelta", +} + +type GitPathAction struct { + Action *GitPathActions `json:"action,omitempty"` + Base64Content *string `json:"base64Content,omitempty"` + Path *string `json:"path,omitempty"` + RawTextContent *string `json:"rawTextContent,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} + +type GitPathActions string + +type gitPathActionsValuesType struct { + None GitPathActions + Edit GitPathActions + Delete GitPathActions + Add GitPathActions + Rename GitPathActions +} + +var GitPathActionsValues = gitPathActionsValuesType{ + None: "none", + Edit: "edit", + Delete: "delete", + Add: "add", + Rename: "rename", +} + +type GitPathToItemsCollection struct { + Items *map[string][]GitItem `json:"items,omitempty"` +} + +type GitPolicyConfigurationResponse struct { + // The HTTP client methods find the continuation token header in the response and populate this field. + ContinuationToken *string `json:"continuationToken,omitempty"` + PolicyConfigurations *[]policy.PolicyConfiguration `json:"policyConfigurations,omitempty"` +} + +// Represents all the data associated with a pull request. +type GitPullRequest struct { + // Links to other related objects. + Links interface{} `json:"_links,omitempty"` + // A string which uniquely identifies this pull request. To generate an artifact ID for a pull request, use this template: ```vstfs:///Git/PullRequestId/{projectId}/{repositoryId}/{pullRequestId}``` + ArtifactId *string `json:"artifactId,omitempty"` + // If set, auto-complete is enabled for this pull request and this is the identity that enabled it. + AutoCompleteSetBy *webapi.IdentityRef `json:"autoCompleteSetBy,omitempty"` + // The user who closed the pull request. + ClosedBy *webapi.IdentityRef `json:"closedBy,omitempty"` + // The date when the pull request was closed (completed, abandoned, or merged externally). + ClosedDate *azuredevops.Time `json:"closedDate,omitempty"` + // The code review ID of the pull request. Used internally. + CodeReviewId *int `json:"codeReviewId,omitempty"` + // The commits contained in the pull request. + Commits *[]GitCommitRef `json:"commits,omitempty"` + // Options which affect how the pull request will be merged when it is completed. + CompletionOptions *GitPullRequestCompletionOptions `json:"completionOptions,omitempty"` + // The most recent date at which the pull request entered the queue to be completed. Used internally. + CompletionQueueTime *azuredevops.Time `json:"completionQueueTime,omitempty"` + // The identity of the user who created the pull request. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // The date when the pull request was created. + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // The description of the pull request. + Description *string `json:"description,omitempty"` + // If this is a PR from a fork this will contain information about its source. + ForkSource *GitForkRef `json:"forkSource,omitempty"` + // Draft / WIP pull request. + IsDraft *bool `json:"isDraft,omitempty"` + // The labels associated with the pull request. + Labels *[]core.WebApiTagDefinition `json:"labels,omitempty"` + // The commit of the most recent pull request merge. If empty, the most recent merge is in progress or was unsuccessful. + LastMergeCommit *GitCommitRef `json:"lastMergeCommit,omitempty"` + // The commit at the head of the source branch at the time of the last pull request merge. + LastMergeSourceCommit *GitCommitRef `json:"lastMergeSourceCommit,omitempty"` + // The commit at the head of the target branch at the time of the last pull request merge. + LastMergeTargetCommit *GitCommitRef `json:"lastMergeTargetCommit,omitempty"` + // If set, pull request merge failed for this reason. + MergeFailureMessage *string `json:"mergeFailureMessage,omitempty"` + // The type of failure (if any) of the pull request merge. + MergeFailureType *PullRequestMergeFailureType `json:"mergeFailureType,omitempty"` + // The ID of the job used to run the pull request merge. Used internally. + MergeId *uuid.UUID `json:"mergeId,omitempty"` + // Options used when the pull request merge runs. These are separate from completion options since completion happens only once and a new merge will run every time the source branch of the pull request changes. + MergeOptions *GitPullRequestMergeOptions `json:"mergeOptions,omitempty"` + // The current status of the pull request merge. + MergeStatus *PullRequestAsyncStatus `json:"mergeStatus,omitempty"` + // The ID of the pull request. + PullRequestId *int `json:"pullRequestId,omitempty"` + // Used internally. + RemoteUrl *string `json:"remoteUrl,omitempty"` + // The repository containing the target branch of the pull request. + Repository *GitRepository `json:"repository,omitempty"` + // A list of reviewers on the pull request along with the state of their votes. + Reviewers *[]IdentityRefWithVote `json:"reviewers,omitempty"` + // The name of the source branch of the pull request. + SourceRefName *string `json:"sourceRefName,omitempty"` + // The status of the pull request. + Status *PullRequestStatus `json:"status,omitempty"` + // If true, this pull request supports multiple iterations. Iteration support means individual pushes to the source branch of the pull request can be reviewed and comments left in one iteration will be tracked across future iterations. + SupportsIterations *bool `json:"supportsIterations,omitempty"` + // The name of the target branch of the pull request. + TargetRefName *string `json:"targetRefName,omitempty"` + // The title of the pull request. + Title *string `json:"title,omitempty"` + // Used internally. + Url *string `json:"url,omitempty"` + // Any work item references associated with this pull request. + WorkItemRefs *[]webapi.ResourceRef `json:"workItemRefs,omitempty"` +} + +// Change made in a pull request. +type GitPullRequestChange struct { + // The type of change that was made to the item. + ChangeType *VersionControlChangeType `json:"changeType,omitempty"` + // Current version. + Item interface{} `json:"item,omitempty"` + // Content of the item after the change. + NewContent *ItemContent `json:"newContent,omitempty"` + // Path of the item on the server. + SourceServerItem *string `json:"sourceServerItem,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` + // ID of the change within the group of changes. + ChangeId *int `json:"changeId,omitempty"` + // New Content template to be used when pushing new changes. + NewContentTemplate *GitTemplate `json:"newContentTemplate,omitempty"` + // Original path of item if different from current path. + OriginalPath *string `json:"originalPath,omitempty"` + // ID used to track files through multiple changes. + ChangeTrackingId *int `json:"changeTrackingId,omitempty"` +} + +// Represents a comment thread of a pull request. A thread contains meta data about the file it was left on (if any) along with one or more comments (an initial comment and the subsequent replies). +type GitPullRequestCommentThread struct { + // Links to other related objects. + Links interface{} `json:"_links,omitempty"` + // A list of the comments. + Comments *[]Comment `json:"comments,omitempty"` + // The comment thread id. + Id *int `json:"id,omitempty"` + // Set of identities related to this thread + Identities *map[string]webapi.IdentityRef `json:"identities,omitempty"` + // Specify if the thread is deleted which happens when all comments are deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // The time this thread was last updated. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Optional properties associated with the thread as a collection of key-value pairs. + Properties interface{} `json:"properties,omitempty"` + // The time this thread was published. + PublishedDate *azuredevops.Time `json:"publishedDate,omitempty"` + // The status of the comment thread. + Status *CommentThreadStatus `json:"status,omitempty"` + // Specify thread context such as position in left/right file. + ThreadContext *CommentThreadContext `json:"threadContext,omitempty"` + // Extended context information unique to pull requests + PullRequestThreadContext *GitPullRequestCommentThreadContext `json:"pullRequestThreadContext,omitempty"` +} + +// Comment thread context contains details about what diffs were being viewed at the time of thread creation and whether or not the thread has been tracked from that original diff. +type GitPullRequestCommentThreadContext struct { + // Used to track a comment across iterations. This value can be found by looking at the iteration's changes list. Must be set for pull requests with iteration support. Otherwise, it's not required for 'legacy' pull requests. + ChangeTrackingId *int `json:"changeTrackingId,omitempty"` + // The iteration context being viewed when the thread was created. + IterationContext *CommentIterationContext `json:"iterationContext,omitempty"` + // The criteria used to track this thread. If this property is filled out when the thread is returned, then the thread has been tracked from its original location using the given criteria. + TrackingCriteria *CommentTrackingCriteria `json:"trackingCriteria,omitempty"` +} + +// Preferences about how the pull request should be completed. +type GitPullRequestCompletionOptions struct { + // If true, policies will be explicitly bypassed while the pull request is completed. + BypassPolicy *bool `json:"bypassPolicy,omitempty"` + // If policies are bypassed, this reason is stored as to why bypass was used. + BypassReason *string `json:"bypassReason,omitempty"` + // If true, the source branch of the pull request will be deleted after completion. + DeleteSourceBranch *bool `json:"deleteSourceBranch,omitempty"` + // If set, this will be used as the commit message of the merge commit. + MergeCommitMessage *string `json:"mergeCommitMessage,omitempty"` + // Specify the strategy used to merge the pull request during completion. If MergeStrategy is not set to any value, a no-FF merge will be created if SquashMerge == false. If MergeStrategy is not set to any value, the pull request commits will be squash if SquashMerge == true. The SquashMerge member is deprecated. It is recommended that you explicitly set MergeStrategy in all cases. If an explicit value is provided for MergeStrategy, the SquashMerge member will be ignored. + MergeStrategy *GitPullRequestMergeStrategy `json:"mergeStrategy,omitempty"` + // SquashMerge is deprecated. You should explicitly set the value of MergeStrategy. If MergeStrategy is set to any value, the SquashMerge value will be ignored. If MergeStrategy is not set, the merge strategy will be no-fast-forward if this flag is false, or squash if true. + SquashMerge *bool `json:"squashMerge,omitempty"` + // If true, we will attempt to transition any work items linked to the pull request into the next logical state (i.e. Active -> Resolved) + TransitionWorkItems *bool `json:"transitionWorkItems,omitempty"` + // If true, the current completion attempt was triggered via auto-complete. Used internally. + TriggeredByAutoComplete *bool `json:"triggeredByAutoComplete,omitempty"` +} + +// Provides properties that describe a Git pull request iteration. Iterations are created as a result of creating and pushing updates to a pull request. +type GitPullRequestIteration struct { + // A collection of related REST reference links. + Links interface{} `json:"_links,omitempty"` + // Author of the pull request iteration. + Author *webapi.IdentityRef `json:"author,omitempty"` + // Changes included with the pull request iteration. + ChangeList *[]GitPullRequestChange `json:"changeList,omitempty"` + // The commits included with the pull request iteration. + Commits *[]GitCommitRef `json:"commits,omitempty"` + // The first common Git commit of the source and target refs. + CommonRefCommit *GitCommitRef `json:"commonRefCommit,omitempty"` + // The creation date of the pull request iteration. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Description of the pull request iteration. + Description *string `json:"description,omitempty"` + // Indicates if the Commits property contains a truncated list of commits in this pull request iteration. + HasMoreCommits *bool `json:"hasMoreCommits,omitempty"` + // ID of the pull request iteration. Iterations are created as a result of creating and pushing updates to a pull request. + Id *int `json:"id,omitempty"` + // If the iteration reason is Retarget, this is the refName of the new target + NewTargetRefName *string `json:"newTargetRefName,omitempty"` + // If the iteration reason is Retarget, this is the original target refName + OldTargetRefName *string `json:"oldTargetRefName,omitempty"` + // The Git push information associated with this pull request iteration. + Push *GitPushRef `json:"push,omitempty"` + // The reason for which the pull request iteration was created. + Reason *IterationReason `json:"reason,omitempty"` + // The source Git commit of this iteration. + SourceRefCommit *GitCommitRef `json:"sourceRefCommit,omitempty"` + // The target Git commit of this iteration. + TargetRefCommit *GitCommitRef `json:"targetRefCommit,omitempty"` + // The updated date of the pull request iteration. + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` +} + +// Collection of changes made in a pull request. +type GitPullRequestIterationChanges struct { + // Changes made in the iteration. + ChangeEntries *[]GitPullRequestChange `json:"changeEntries,omitempty"` + // Value to specify as skip to get the next page of changes. This will be zero if there are no more changes. + NextSkip *int `json:"nextSkip,omitempty"` + // Value to specify as top to get the next page of changes. This will be zero if there are no more changes. + NextTop *int `json:"nextTop,omitempty"` +} + +// The options which are used when a pull request merge is created. +type GitPullRequestMergeOptions struct { + DetectRenameFalsePositives *bool `json:"detectRenameFalsePositives,omitempty"` + // If true, rename detection will not be performed during the merge. + DisableRenames *bool `json:"disableRenames,omitempty"` +} + +// Enumeration of possible merge strategies which can be used to complete a pull request. +type GitPullRequestMergeStrategy string + +type gitPullRequestMergeStrategyValuesType struct { + NoFastForward GitPullRequestMergeStrategy + Squash GitPullRequestMergeStrategy + Rebase GitPullRequestMergeStrategy + RebaseMerge GitPullRequestMergeStrategy +} + +var GitPullRequestMergeStrategyValues = gitPullRequestMergeStrategyValuesType{ + // A two-parent, no-fast-forward merge. The source branch is unchanged. This is the default behavior. + NoFastForward: "noFastForward", + // Put all changes from the pull request into a single-parent commit. + Squash: "squash", + // Rebase the source branch on top of the target branch HEAD commit, and fast-forward the target branch. The source branch is updated during the rebase operation. + Rebase: "rebase", + // Rebase the source branch on top of the target branch HEAD commit, and create a two-parent, no-fast-forward merge. The source branch is updated during the rebase operation. + RebaseMerge: "rebaseMerge", +} + +// A set of pull request queries and their results. +type GitPullRequestQuery struct { + // The queries to perform. + Queries *[]GitPullRequestQueryInput `json:"queries,omitempty"` + // The results of the queries. This matches the QueryInputs list so Results[n] are the results of QueryInputs[n]. Each entry in the list is a dictionary of commit->pull requests. + Results *[]map[string][]GitPullRequest `json:"results,omitempty"` +} + +// Pull request query input parameters. +type GitPullRequestQueryInput struct { + // The list of commit IDs to search for. + Items *[]string `json:"items,omitempty"` + // The type of query to perform. + Type *GitPullRequestQueryType `json:"type,omitempty"` +} + +// Accepted types of pull request queries. +type GitPullRequestQueryType string + +type gitPullRequestQueryTypeValuesType struct { + NotSet GitPullRequestQueryType + LastMergeCommit GitPullRequestQueryType + Commit GitPullRequestQueryType +} + +var GitPullRequestQueryTypeValues = gitPullRequestQueryTypeValuesType{ + // No query type set. + NotSet: "notSet", + // Search for pull requests that created the supplied merge commits. + LastMergeCommit: "lastMergeCommit", + // Search for pull requests that merged the supplied commits. + Commit: "commit", +} + +type GitPullRequestReviewFileContentInfo struct { + Links interface{} `json:"_links,omitempty"` + // The file change path. + Path *string `json:"path,omitempty"` + // Content hash of on-disk representation of file content. Its calculated by the client by using SHA1 hash function. Ensure that uploaded file has same encoding as in source control. + ShA1Hash *string `json:"shA1Hash,omitempty"` +} + +type GitPullRequestReviewFileType string + +type gitPullRequestReviewFileTypeValuesType struct { + ChangeEntry GitPullRequestReviewFileType + Attachment GitPullRequestReviewFileType +} + +var GitPullRequestReviewFileTypeValues = gitPullRequestReviewFileTypeValuesType{ + ChangeEntry: "changeEntry", + Attachment: "attachment", +} + +// Pull requests can be searched for matching this criteria. +type GitPullRequestSearchCriteria struct { + // If set, search for pull requests that were created by this identity. + CreatorId *uuid.UUID `json:"creatorId,omitempty"` + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` + // If set, search for pull requests whose target branch is in this repository. + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` + // If set, search for pull requests that have this identity as a reviewer. + ReviewerId *uuid.UUID `json:"reviewerId,omitempty"` + // If set, search for pull requests from this branch. + SourceRefName *string `json:"sourceRefName,omitempty"` + // If set, search for pull requests whose source branch is in this repository. + SourceRepositoryId *uuid.UUID `json:"sourceRepositoryId,omitempty"` + // If set, search for pull requests that are in this state. Defaults to Active if unset. + Status *PullRequestStatus `json:"status,omitempty"` + // If set, search for pull requests into this branch. + TargetRefName *string `json:"targetRefName,omitempty"` +} + +// This class contains the metadata of a service/extension posting pull request status. Status can be associated with a pull request or an iteration. +type GitPullRequestStatus struct { + // Reference links. + Links interface{} `json:"_links,omitempty"` + // Context of the status. + Context *GitStatusContext `json:"context,omitempty"` + // Identity that created the status. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Creation date and time of the status. + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // Status description. Typically describes current state of the status. + Description *string `json:"description,omitempty"` + // Status identifier. + Id *int `json:"id,omitempty"` + // State of the status. + State *GitStatusState `json:"state,omitempty"` + // URL with status details. + TargetUrl *string `json:"targetUrl,omitempty"` + // Last update date and time of the status. + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // ID of the iteration to associate status with. Minimum value is 1. + IterationId *int `json:"iterationId,omitempty"` + // Custom properties of the status. + Properties interface{} `json:"properties,omitempty"` +} + +type GitPush struct { + Links interface{} `json:"_links,omitempty"` + Date *azuredevops.Time `json:"date,omitempty"` + PushCorrelationId *uuid.UUID `json:"pushCorrelationId,omitempty"` + PushedBy *webapi.IdentityRef `json:"pushedBy,omitempty"` + PushId *int `json:"pushId,omitempty"` + Url *string `json:"url,omitempty"` + Commits *[]GitCommitRef `json:"commits,omitempty"` + RefUpdates *[]GitRefUpdate `json:"refUpdates,omitempty"` + Repository *GitRepository `json:"repository,omitempty"` +} + +type GitPushEventData struct { + AfterId *string `json:"afterId,omitempty"` + BeforeId *string `json:"beforeId,omitempty"` + Branch *string `json:"branch,omitempty"` + Commits *[]GitCommit `json:"commits,omitempty"` + Repository *GitRepository `json:"repository,omitempty"` +} + +type GitPushRef struct { + Links interface{} `json:"_links,omitempty"` + Date *azuredevops.Time `json:"date,omitempty"` + // Deprecated: This is unused as of Dev15 M115 and may be deleted in the future + PushCorrelationId *uuid.UUID `json:"pushCorrelationId,omitempty"` + PushedBy *webapi.IdentityRef `json:"pushedBy,omitempty"` + PushId *int `json:"pushId,omitempty"` + Url *string `json:"url,omitempty"` +} + +type GitPushSearchCriteria struct { + FromDate *azuredevops.Time `json:"fromDate,omitempty"` + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` + IncludeRefUpdates *bool `json:"includeRefUpdates,omitempty"` + PusherId *uuid.UUID `json:"pusherId,omitempty"` + RefName *string `json:"refName,omitempty"` + ToDate *azuredevops.Time `json:"toDate,omitempty"` +} + +type GitQueryBranchStatsCriteria struct { + BaseCommit *GitVersionDescriptor `json:"baseCommit,omitempty"` + TargetCommits *[]GitVersionDescriptor `json:"targetCommits,omitempty"` +} + +type GitQueryCommitsCriteria struct { + // Number of entries to skip + Skip *int `json:"$skip,omitempty"` + // Maximum number of entries to retrieve + Top *int `json:"$top,omitempty"` + // Alias or display name of the author + Author *string `json:"author,omitempty"` + // Only applicable when ItemVersion specified. If provided, start walking history starting at this commit. + CompareVersion *GitVersionDescriptor `json:"compareVersion,omitempty"` + // Only applies when an itemPath is specified. This determines whether to exclude delete entries of the specified path. + ExcludeDeletes *bool `json:"excludeDeletes,omitempty"` + // If provided, a lower bound for filtering commits alphabetically + FromCommitId *string `json:"fromCommitId,omitempty"` + // If provided, only include history entries created after this date (string) + FromDate *string `json:"fromDate,omitempty"` + // What Git history mode should be used. This only applies to the search criteria when Ids = null and an itemPath is specified. + HistoryMode *GitHistoryMode `json:"historyMode,omitempty"` + // If provided, specifies the exact commit ids of the commits to fetch. May not be combined with other parameters. + Ids *[]string `json:"ids,omitempty"` + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` + // Whether to include the push information + IncludePushData *bool `json:"includePushData,omitempty"` + // Whether to include the image Url for committers and authors + IncludeUserImageUrl *bool `json:"includeUserImageUrl,omitempty"` + // Whether to include linked work items + IncludeWorkItems *bool `json:"includeWorkItems,omitempty"` + // Path of item to search under + ItemPath *string `json:"itemPath,omitempty"` + // If provided, identifies the commit or branch to search + ItemVersion *GitVersionDescriptor `json:"itemVersion,omitempty"` + // If provided, an upper bound for filtering commits alphabetically + ToCommitId *string `json:"toCommitId,omitempty"` + // If provided, only include history entries created before this date (string) + ToDate *string `json:"toDate,omitempty"` + // Alias or display name of the committer + User *string `json:"user,omitempty"` +} + +type GitQueryRefsCriteria struct { + // List of commit Ids to be searched + CommitIds *[]string `json:"commitIds,omitempty"` + // List of complete or partial names for refs to be searched + RefNames *[]string `json:"refNames,omitempty"` + // Type of search on refNames, if provided + SearchType *GitRefSearchType `json:"searchType,omitempty"` +} + +type GitRecycleBinRepositoryDetails struct { + // Setting to false will undo earlier deletion and restore the repository. + Deleted *bool `json:"deleted,omitempty"` +} + +type GitRef struct { + Links interface{} `json:"_links,omitempty"` + Creator *webapi.IdentityRef `json:"creator,omitempty"` + IsLocked *bool `json:"isLocked,omitempty"` + IsLockedBy *webapi.IdentityRef `json:"isLockedBy,omitempty"` + Name *string `json:"name,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + PeeledObjectId *string `json:"peeledObjectId,omitempty"` + Statuses *[]GitStatus `json:"statuses,omitempty"` + Url *string `json:"url,omitempty"` +} + +type GitRefFavorite struct { + Links interface{} `json:"_links,omitempty"` + Id *int `json:"id,omitempty"` + IdentityId *uuid.UUID `json:"identityId,omitempty"` + Name *string `json:"name,omitempty"` + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` + Type *RefFavoriteType `json:"type,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Search type on ref name +type GitRefSearchType string + +type gitRefSearchTypeValuesType struct { + Exact GitRefSearchType + StartsWith GitRefSearchType + Contains GitRefSearchType +} + +var GitRefSearchTypeValues = gitRefSearchTypeValuesType{ + Exact: "exact", + StartsWith: "startsWith", + Contains: "contains", +} + +type GitRefUpdate struct { + IsLocked *bool `json:"isLocked,omitempty"` + Name *string `json:"name,omitempty"` + NewObjectId *string `json:"newObjectId,omitempty"` + OldObjectId *string `json:"oldObjectId,omitempty"` + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` +} + +// Enumerates the modes under which ref updates can be written to their repositories. +type GitRefUpdateMode string + +type gitRefUpdateModeValuesType struct { + BestEffort GitRefUpdateMode + AllOrNone GitRefUpdateMode +} + +var GitRefUpdateModeValues = gitRefUpdateModeValuesType{ + // Indicates the Git protocol model where any refs that can be updated will be updated, but any failures will not prevent other updates from succeeding. + BestEffort: "bestEffort", + // Indicates that all ref updates must succeed or none will succeed. All ref updates will be atomically written. If any failure is encountered, previously successful updates will be rolled back and the entire operation will fail. + AllOrNone: "allOrNone", +} + +type GitRefUpdateResult struct { + // Custom message for the result object For instance, Reason for failing. + CustomMessage *string `json:"customMessage,omitempty"` + // Whether the ref is locked or not + IsLocked *bool `json:"isLocked,omitempty"` + // Ref name + Name *string `json:"name,omitempty"` + // New object ID + NewObjectId *string `json:"newObjectId,omitempty"` + // Old object ID + OldObjectId *string `json:"oldObjectId,omitempty"` + // Name of the plugin that rejected the updated. + RejectedBy *string `json:"rejectedBy,omitempty"` + // Repository ID + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` + // True if the ref update succeeded, false otherwise + Success *bool `json:"success,omitempty"` + // Status of the update from the TFS server. + UpdateStatus *GitRefUpdateStatus `json:"updateStatus,omitempty"` +} + +// Represents the possible outcomes from a request to update a ref in a repository. +type GitRefUpdateStatus string + +type gitRefUpdateStatusValuesType struct { + Succeeded GitRefUpdateStatus + ForcePushRequired GitRefUpdateStatus + StaleOldObjectId GitRefUpdateStatus + InvalidRefName GitRefUpdateStatus + Unprocessed GitRefUpdateStatus + UnresolvableToCommit GitRefUpdateStatus + WritePermissionRequired GitRefUpdateStatus + ManageNotePermissionRequired GitRefUpdateStatus + CreateBranchPermissionRequired GitRefUpdateStatus + CreateTagPermissionRequired GitRefUpdateStatus + RejectedByPlugin GitRefUpdateStatus + Locked GitRefUpdateStatus + RefNameConflict GitRefUpdateStatus + RejectedByPolicy GitRefUpdateStatus + SucceededNonExistentRef GitRefUpdateStatus + SucceededCorruptRef GitRefUpdateStatus +} + +var GitRefUpdateStatusValues = gitRefUpdateStatusValuesType{ + // Indicates that the ref update request was completed successfully. + Succeeded: "succeeded", + // Indicates that the ref update request could not be completed because part of the graph would be disconnected by this change, and the caller does not have ForcePush permission on the repository. + ForcePushRequired: "forcePushRequired", + // Indicates that the ref update request could not be completed because the old object ID presented in the request was not the object ID of the ref when the database attempted the update. The most likely scenario is that the caller lost a race to update the ref. + StaleOldObjectId: "staleOldObjectId", + // Indicates that the ref update request could not be completed because the ref name presented in the request was not valid. + InvalidRefName: "invalidRefName", + // The request was not processed + Unprocessed: "unprocessed", + // The ref update request could not be completed because the new object ID for the ref could not be resolved to a commit object (potentially through any number of tags) + UnresolvableToCommit: "unresolvableToCommit", + // The ref update request could not be completed because the user lacks write permissions required to write this ref + WritePermissionRequired: "writePermissionRequired", + // The ref update request could not be completed because the user lacks note creation permissions required to write this note + ManageNotePermissionRequired: "manageNotePermissionRequired", + // The ref update request could not be completed because the user lacks the permission to create a branch + CreateBranchPermissionRequired: "createBranchPermissionRequired", + // The ref update request could not be completed because the user lacks the permission to create a tag + CreateTagPermissionRequired: "createTagPermissionRequired", + // The ref update could not be completed because it was rejected by the plugin. + RejectedByPlugin: "rejectedByPlugin", + // The ref update could not be completed because the ref is locked by another user. + Locked: "locked", + // The ref update could not be completed because, in case-insensitive mode, the ref name conflicts with an existing, differently-cased ref name. + RefNameConflict: "refNameConflict", + // The ref update could not be completed because it was rejected by policy. + RejectedByPolicy: "rejectedByPolicy", + // Indicates that the ref update request was completed successfully, but the ref doesn't actually exist so no changes were made. This should only happen during deletes. + SucceededNonExistentRef: "succeededNonExistentRef", + // Indicates that the ref update request was completed successfully, but the passed-in ref was corrupt - as in, the old object ID was bad. This should only happen during deletes. + SucceededCorruptRef: "succeededCorruptRef", +} + +type GitRepository struct { + Links interface{} `json:"_links,omitempty"` + DefaultBranch *string `json:"defaultBranch,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + // True if the repository was created as a fork + IsFork *bool `json:"isFork,omitempty"` + Name *string `json:"name,omitempty"` + ParentRepository *GitRepositoryRef `json:"parentRepository,omitempty"` + Project *core.TeamProjectReference `json:"project,omitempty"` + RemoteUrl *string `json:"remoteUrl,omitempty"` + // Compressed size (bytes) of the repository. + Size *uint64 `json:"size,omitempty"` + SshUrl *string `json:"sshUrl,omitempty"` + Url *string `json:"url,omitempty"` + ValidRemoteUrls *[]string `json:"validRemoteUrls,omitempty"` + WebUrl *string `json:"webUrl,omitempty"` +} + +type GitRepositoryCreateOptions struct { + Name *string `json:"name,omitempty"` + ParentRepository *GitRepositoryRef `json:"parentRepository,omitempty"` + Project *core.TeamProjectReference `json:"project,omitempty"` +} + +type GitRepositoryRef struct { + // Team Project Collection where this Fork resides + Collection *core.TeamProjectCollectionReference `json:"collection,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + // True if the repository was created as a fork + IsFork *bool `json:"isFork,omitempty"` + Name *string `json:"name,omitempty"` + Project *core.TeamProjectReference `json:"project,omitempty"` + RemoteUrl *string `json:"remoteUrl,omitempty"` + SshUrl *string `json:"sshUrl,omitempty"` + Url *string `json:"url,omitempty"` +} + +type GitRepositoryStats struct { + ActivePullRequestsCount *int `json:"activePullRequestsCount,omitempty"` + BranchesCount *int `json:"branchesCount,omitempty"` + CommitsCount *int `json:"commitsCount,omitempty"` + RepositoryId *string `json:"repositoryId,omitempty"` +} + +type GitResolution struct { + // User who created the resolution. + Author *webapi.IdentityRef `json:"author,omitempty"` +} + +// The type of a merge conflict. +type GitResolutionError string + +type gitResolutionErrorValuesType struct { + None GitResolutionError + MergeContentNotFound GitResolutionError + PathInUse GitResolutionError + InvalidPath GitResolutionError + UnknownAction GitResolutionError + UnknownMergeType GitResolutionError + OtherError GitResolutionError +} + +var GitResolutionErrorValues = gitResolutionErrorValuesType{ + // No error + None: "none", + // User set a blob id for resolving a content merge, but blob was not found in repo during application + MergeContentNotFound: "mergeContentNotFound", + // Attempted to resolve a conflict by moving a file to another path, but path was already in use + PathInUse: "pathInUse", + // No error + InvalidPath: "invalidPath", + // GitResolutionAction was set to an unrecognized value + UnknownAction: "unknownAction", + // GitResolutionMergeType was set to an unrecognized value + UnknownMergeType: "unknownMergeType", + // Any error for which a more specific code doesn't apply + OtherError: "otherError", +} + +type GitResolutionMergeContent struct { + // User who created the resolution. + Author *webapi.IdentityRef `json:"author,omitempty"` + MergeType *GitResolutionMergeType `json:"mergeType,omitempty"` + UserMergedBlob *GitBlobRef `json:"userMergedBlob,omitempty"` + UserMergedContent *[]byte `json:"userMergedContent,omitempty"` +} + +type GitResolutionMergeType string + +type gitResolutionMergeTypeValuesType struct { + Undecided GitResolutionMergeType + TakeSourceContent GitResolutionMergeType + TakeTargetContent GitResolutionMergeType + AutoMerged GitResolutionMergeType + UserMerged GitResolutionMergeType +} + +var GitResolutionMergeTypeValues = gitResolutionMergeTypeValuesType{ + Undecided: "undecided", + TakeSourceContent: "takeSourceContent", + TakeTargetContent: "takeTargetContent", + AutoMerged: "autoMerged", + UserMerged: "userMerged", +} + +type GitResolutionPathConflict struct { + // User who created the resolution. + Author *webapi.IdentityRef `json:"author,omitempty"` + Action *GitResolutionPathConflictAction `json:"action,omitempty"` + RenamePath *string `json:"renamePath,omitempty"` +} + +type GitResolutionPathConflictAction string + +type gitResolutionPathConflictActionValuesType struct { + Undecided GitResolutionPathConflictAction + KeepSourceRenameTarget GitResolutionPathConflictAction + KeepSourceDeleteTarget GitResolutionPathConflictAction + KeepTargetRenameSource GitResolutionPathConflictAction + KeepTargetDeleteSource GitResolutionPathConflictAction +} + +var GitResolutionPathConflictActionValues = gitResolutionPathConflictActionValuesType{ + Undecided: "undecided", + KeepSourceRenameTarget: "keepSourceRenameTarget", + KeepSourceDeleteTarget: "keepSourceDeleteTarget", + KeepTargetRenameSource: "keepTargetRenameSource", + KeepTargetDeleteSource: "keepTargetDeleteSource", +} + +type GitResolutionPickOneAction struct { + // User who created the resolution. + Author *webapi.IdentityRef `json:"author,omitempty"` + Action *GitResolutionWhichAction `json:"action,omitempty"` +} + +type GitResolutionRename1to2 struct { + // User who created the resolution. + Author *webapi.IdentityRef `json:"author,omitempty"` + MergeType *GitResolutionMergeType `json:"mergeType,omitempty"` + UserMergedBlob *GitBlobRef `json:"userMergedBlob,omitempty"` + UserMergedContent *[]byte `json:"userMergedContent,omitempty"` + Action *GitResolutionRename1to2Action `json:"action,omitempty"` +} + +type GitResolutionRename1to2Action string + +type gitResolutionRename1to2ActionValuesType struct { + Undecided GitResolutionRename1to2Action + KeepSourcePath GitResolutionRename1to2Action + KeepTargetPath GitResolutionRename1to2Action + KeepBothFiles GitResolutionRename1to2Action +} + +var GitResolutionRename1to2ActionValues = gitResolutionRename1to2ActionValuesType{ + Undecided: "undecided", + KeepSourcePath: "keepSourcePath", + KeepTargetPath: "keepTargetPath", + KeepBothFiles: "keepBothFiles", +} + +// Resolution status of a conflict. +type GitResolutionStatus string + +type gitResolutionStatusValuesType struct { + Unresolved GitResolutionStatus + PartiallyResolved GitResolutionStatus + Resolved GitResolutionStatus +} + +var GitResolutionStatusValues = gitResolutionStatusValuesType{ + Unresolved: "unresolved", + PartiallyResolved: "partiallyResolved", + Resolved: "resolved", +} + +type GitResolutionWhichAction string + +type gitResolutionWhichActionValuesType struct { + Undecided GitResolutionWhichAction + PickSourceAction GitResolutionWhichAction + PickTargetAction GitResolutionWhichAction +} + +var GitResolutionWhichActionValues = gitResolutionWhichActionValuesType{ + Undecided: "undecided", + PickSourceAction: "pickSourceAction", + PickTargetAction: "pickTargetAction", +} + +type GitRevert struct { + Links interface{} `json:"_links,omitempty"` + DetailedStatus *GitAsyncRefOperationDetail `json:"detailedStatus,omitempty"` + Parameters *GitAsyncRefOperationParameters `json:"parameters,omitempty"` + Status *GitAsyncOperationStatus `json:"status,omitempty"` + // A URL that can be used to make further requests for status about the operation + Url *string `json:"url,omitempty"` + RevertId *int `json:"revertId,omitempty"` +} + +// This class contains the metadata of a service/extension posting a status. +type GitStatus struct { + // Reference links. + Links interface{} `json:"_links,omitempty"` + // Context of the status. + Context *GitStatusContext `json:"context,omitempty"` + // Identity that created the status. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Creation date and time of the status. + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // Status description. Typically describes current state of the status. + Description *string `json:"description,omitempty"` + // Status identifier. + Id *int `json:"id,omitempty"` + // State of the status. + State *GitStatusState `json:"state,omitempty"` + // URL with status details. + TargetUrl *string `json:"targetUrl,omitempty"` + // Last update date and time of the status. + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` +} + +// Status context that uniquely identifies the status. +type GitStatusContext struct { + // Genre of the status. Typically name of the service/tool generating the status, can be empty. + Genre *string `json:"genre,omitempty"` + // Name identifier of the status, cannot be null or empty. + Name *string `json:"name,omitempty"` +} + +// State of the status. +type GitStatusState string + +type gitStatusStateValuesType struct { + NotSet GitStatusState + Pending GitStatusState + Succeeded GitStatusState + Failed GitStatusState + Error GitStatusState + NotApplicable GitStatusState +} + +var GitStatusStateValues = gitStatusStateValuesType{ + // Status state not set. Default state. + NotSet: "notSet", + // Status pending. + Pending: "pending", + // Status succeeded. + Succeeded: "succeeded", + // Status failed. + Failed: "failed", + // Status with an error. + Error: "error", + // Status is not applicable to the target object. + NotApplicable: "notApplicable", +} + +// An object describing the git suggestion. Git suggestions are currently limited to suggested pull requests. +type GitSuggestion struct { + // Specific properties describing the suggestion. + Properties *map[string]interface{} `json:"properties,omitempty"` + // The type of suggestion (e.g. pull request). + Type *string `json:"type,omitempty"` +} + +type GitTargetVersionDescriptor struct { + // Version string identifier (name of tag/branch, SHA1 of commit) + Version *string `json:"version,omitempty"` + // Version options - Specify additional modifiers to version (e.g Previous) + VersionOptions *GitVersionOptions `json:"versionOptions,omitempty"` + // Version type (branch, tag, or commit). Determines how Id is interpreted + VersionType *GitVersionType `json:"versionType,omitempty"` + // Version string identifier (name of tag/branch, SHA1 of commit) + TargetVersion *string `json:"targetVersion,omitempty"` + // Version options - Specify additional modifiers to version (e.g Previous) + TargetVersionOptions *GitVersionOptions `json:"targetVersionOptions,omitempty"` + // Version type (branch, tag, or commit). Determines how Id is interpreted + TargetVersionType *GitVersionType `json:"targetVersionType,omitempty"` +} + +type GitTemplate struct { + // Name of the Template + Name *string `json:"name,omitempty"` + // Type of the Template + Type *string `json:"type,omitempty"` +} + +type GitTreeDiff struct { + // ObjectId of the base tree of this diff. + BaseTreeId *string `json:"baseTreeId,omitempty"` + // List of tree entries that differ between the base and target tree. Renames and object type changes are returned as a delete for the old object and add for the new object. If a continuation token is returned in the response header, some tree entries are yet to be processed and may yield more diff entries. If the continuation token is not returned all the diff entries have been included in this response. + DiffEntries *[]GitTreeDiffEntry `json:"diffEntries,omitempty"` + // ObjectId of the target tree of this diff. + TargetTreeId *string `json:"targetTreeId,omitempty"` + // REST Url to this resource. + Url *string `json:"url,omitempty"` +} + +type GitTreeDiffEntry struct { + // SHA1 hash of the object in the base tree, if it exists. Will be null in case of adds. + BaseObjectId *string `json:"baseObjectId,omitempty"` + // Type of change that affected this entry. + ChangeType *VersionControlChangeType `json:"changeType,omitempty"` + // Object type of the tree entry. Blob, Tree or Commit("submodule") + ObjectType *GitObjectType `json:"objectType,omitempty"` + // Relative path in base and target trees. + Path *string `json:"path,omitempty"` + // SHA1 hash of the object in the target tree, if it exists. Will be null in case of deletes. + TargetObjectId *string `json:"targetObjectId,omitempty"` +} + +type GitTreeDiffResponse struct { + // The HTTP client methods find the continuation token header in the response and populate this field. + ContinuationToken *[]string `json:"continuationToken,omitempty"` + TreeDiff *GitTreeDiff `json:"treeDiff,omitempty"` +} + +type GitTreeEntryRef struct { + // Blob or tree + GitObjectType *GitObjectType `json:"gitObjectType,omitempty"` + // Mode represented as octal string + Mode *string `json:"mode,omitempty"` + // SHA1 hash of git object + ObjectId *string `json:"objectId,omitempty"` + // Path relative to parent tree object + RelativePath *string `json:"relativePath,omitempty"` + // Size of content + Size *uint64 `json:"size,omitempty"` + // url to retrieve tree or blob + Url *string `json:"url,omitempty"` +} + +type GitTreeRef struct { + Links interface{} `json:"_links,omitempty"` + // SHA1 hash of git object + ObjectId *string `json:"objectId,omitempty"` + // Sum of sizes of all children + Size *uint64 `json:"size,omitempty"` + // Blobs and trees under this tree + TreeEntries *[]GitTreeEntryRef `json:"treeEntries,omitempty"` + // Url to tree + Url *string `json:"url,omitempty"` +} + +// User info and date for Git operations. +type GitUserDate struct { + // Date of the Git operation. + Date *azuredevops.Time `json:"date,omitempty"` + // Email address of the user performing the Git operation. + Email *string `json:"email,omitempty"` + // Url for the user's avatar. + ImageUrl *string `json:"imageUrl,omitempty"` + // Name of the user performing the Git operation. + Name *string `json:"name,omitempty"` +} + +type GitVersionDescriptor struct { + // Version string identifier (name of tag/branch, SHA1 of commit) + Version *string `json:"version,omitempty"` + // Version options - Specify additional modifiers to version (e.g Previous) + VersionOptions *GitVersionOptions `json:"versionOptions,omitempty"` + // Version type (branch, tag, or commit). Determines how Id is interpreted + VersionType *GitVersionType `json:"versionType,omitempty"` +} + +// Accepted types of version options +type GitVersionOptions string + +type gitVersionOptionsValuesType struct { + None GitVersionOptions + PreviousChange GitVersionOptions + FirstParent GitVersionOptions +} + +var GitVersionOptionsValues = gitVersionOptionsValuesType{ + // Not specified + None: "none", + // Commit that changed item prior to the current version + PreviousChange: "previousChange", + // First parent of commit (HEAD^) + FirstParent: "firstParent", +} + +// Accepted types of version +type GitVersionType string + +type gitVersionTypeValuesType struct { + Branch GitVersionType + Tag GitVersionType + Commit GitVersionType +} + +var GitVersionTypeValues = gitVersionTypeValuesType{ + // Interpret the version as a branch name + Branch: "branch", + // Interpret the version as a tag name + Tag: "tag", + // Interpret the version as a commit ID (SHA1) + Commit: "commit", +} + +// Globally unique key for a repository. +type GlobalGitRepositoryKey struct { + // Team Project Collection ID of the collection for the repository. + CollectionId *uuid.UUID `json:"collectionId,omitempty"` + // Team Project ID of the project for the repository. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // ID of the repository. + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` +} + +type HistoryEntry struct { + // The Change list (changeset/commit/shelveset) for this point in history + ChangeList interface{} `json:"changeList,omitempty"` + // The change made to the item from this change list (only relevant for File history, not folders) + ItemChangeType *VersionControlChangeType `json:"itemChangeType,omitempty"` + // The path of the item at this point in history (only relevant for File history, not folders) + ServerItem *string `json:"serverItem,omitempty"` +} + +// Identity information including a vote on a pull request. +type IdentityRefWithVote struct { + // This field contains zero or more interesting links about the graph subject. These links may be invoked to obtain additional relationships or more detailed information about this graph subject. + Links interface{} `json:"_links,omitempty"` + // The descriptor is the primary way to reference the graph subject while the system is running. This field will uniquely identify the same graph subject across both Accounts and Organizations. + Descriptor *string `json:"descriptor,omitempty"` + // This is the non-unique display name of the graph subject. To change this field, you must alter its value in the source provider. + DisplayName *string `json:"displayName,omitempty"` + // This url is the full route to the source resource of this graph subject. + Url *string `json:"url,omitempty"` + // Deprecated - Can be retrieved by querying the Graph user referenced in the "self" entry of the IdentityRef "_links" dictionary + DirectoryAlias *string `json:"directoryAlias,omitempty"` + Id *string `json:"id,omitempty"` + // Deprecated - Available in the "avatar" entry of the IdentityRef "_links" dictionary + ImageUrl *string `json:"imageUrl,omitempty"` + // Deprecated - Can be retrieved by querying the Graph membership state referenced in the "membershipState" entry of the GraphUser "_links" dictionary + Inactive *bool `json:"inactive,omitempty"` + // Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsAadUserType/Descriptor.IsAadGroupType) + IsAadIdentity *bool `json:"isAadIdentity,omitempty"` + // Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsGroupType) + IsContainer *bool `json:"isContainer,omitempty"` + IsDeletedInOrigin *bool `json:"isDeletedInOrigin,omitempty"` + // Deprecated - not in use in most preexisting implementations of ToIdentityRef + ProfileUrl *string `json:"profileUrl,omitempty"` + // Deprecated - use Domain+PrincipalName instead + UniqueName *string `json:"uniqueName,omitempty"` + // Indicates if this is a required reviewer for this pull request.
Branches can have policies that require particular reviewers are required for pull requests. + IsRequired *bool `json:"isRequired,omitempty"` + // URL to retrieve information about this identity + ReviewerUrl *string `json:"reviewerUrl,omitempty"` + // Vote on a pull request:
10 - approved 5 - approved with suggestions 0 - no vote -5 - waiting for author -10 - rejected + Vote *int `json:"vote,omitempty"` + // Groups or teams that that this reviewer contributed to.
Groups and teams can be reviewers on pull requests but can not vote directly. When a member of the group or team votes, that vote is rolled up into the group or team vote. VotedFor is a list of such votes. + VotedFor *[]IdentityRefWithVote `json:"votedFor,omitempty"` +} + +type ImportRepositoryValidation struct { + GitSource *GitImportGitSource `json:"gitSource,omitempty"` + Password *string `json:"password,omitempty"` + TfvcSource *GitImportTfvcSource `json:"tfvcSource,omitempty"` + Username *string `json:"username,omitempty"` +} + +type IncludedGitCommit struct { + CommitId *string `json:"commitId,omitempty"` + CommitTime *azuredevops.Time `json:"commitTime,omitempty"` + ParentCommitIds *[]string `json:"parentCommitIds,omitempty"` + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` +} + +// Real time event (SignalR) for IsDraft update on a pull request +type IsDraftUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +type ItemContent struct { + Content *string `json:"content,omitempty"` + ContentType *ItemContentType `json:"contentType,omitempty"` +} + +// [Flags] +type ItemContentType string + +type itemContentTypeValuesType struct { + RawText ItemContentType + Base64Encoded ItemContentType +} + +var ItemContentTypeValues = itemContentTypeValuesType{ + RawText: "rawText", + Base64Encoded: "base64Encoded", +} + +// Optional details to include when returning an item model +type ItemDetailsOptions struct { + // If true, include metadata about the file type + IncludeContentMetadata *bool `json:"includeContentMetadata,omitempty"` + // Specifies whether to include children (OneLevel), all descendants (Full) or None for folder items + RecursionLevel *VersionControlRecursionType `json:"recursionLevel,omitempty"` +} + +type ItemModel struct { + Links interface{} `json:"_links,omitempty"` + Content *string `json:"content,omitempty"` + ContentMetadata *FileContentMetadata `json:"contentMetadata,omitempty"` + IsFolder *bool `json:"isFolder,omitempty"` + IsSymLink *bool `json:"isSymLink,omitempty"` + Path *string `json:"path,omitempty"` + Url *string `json:"url,omitempty"` +} + +// [Flags] The reason for which the pull request iteration was created. +type IterationReason string + +type iterationReasonValuesType struct { + Push IterationReason + ForcePush IterationReason + Create IterationReason + Rebase IterationReason + Unknown IterationReason + Retarget IterationReason +} + +var IterationReasonValues = iterationReasonValuesType{ + Push: "push", + ForcePush: "forcePush", + Create: "create", + Rebase: "rebase", + Unknown: "unknown", + Retarget: "retarget", +} + +// Real time event (SignalR) for updated labels on a pull request +type LabelsUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// The class to represent the line diff block +type LineDiffBlock struct { + // Type of change that was made to the block. + ChangeType *LineDiffBlockChangeType `json:"changeType,omitempty"` + // Line number where this block starts in modified file. + ModifiedLineNumberStart *int `json:"modifiedLineNumberStart,omitempty"` + // Count of lines in this block in modified file. + ModifiedLinesCount *int `json:"modifiedLinesCount,omitempty"` + // Line number where this block starts in original file. + OriginalLineNumberStart *int `json:"originalLineNumberStart,omitempty"` + // Count of lines in this block in original file. + OriginalLinesCount *int `json:"originalLinesCount,omitempty"` +} + +// Type of change for a line diff block +type LineDiffBlockChangeType string + +type lineDiffBlockChangeTypeValuesType struct { + None LineDiffBlockChangeType + Add LineDiffBlockChangeType + Delete LineDiffBlockChangeType + Edit LineDiffBlockChangeType +} + +var LineDiffBlockChangeTypeValues = lineDiffBlockChangeTypeValuesType{ + // No change - both the blocks are identical + None: "none", + // Lines were added to the block in the modified file + Add: "add", + // Lines were deleted from the block in the original file + Delete: "delete", + // Lines were modified + Edit: "edit", +} + +// Real time event (SignalR) for a merge completed on a pull request +type MergeCompletedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Real time event (SignalR) for a policy evaluation update on a pull request +type PolicyEvaluationUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// The status of a pull request merge. +type PullRequestAsyncStatus string + +type pullRequestAsyncStatusValuesType struct { + NotSet PullRequestAsyncStatus + Queued PullRequestAsyncStatus + Conflicts PullRequestAsyncStatus + Succeeded PullRequestAsyncStatus + RejectedByPolicy PullRequestAsyncStatus + Failure PullRequestAsyncStatus +} + +var PullRequestAsyncStatusValues = pullRequestAsyncStatusValuesType{ + // Status is not set. Default state. + NotSet: "notSet", + // Pull request merge is queued. + Queued: "queued", + // Pull request merge failed due to conflicts. + Conflicts: "conflicts", + // Pull request merge succeeded. + Succeeded: "succeeded", + // Pull request merge rejected by policy. + RejectedByPolicy: "rejectedByPolicy", + // Pull request merge failed. + Failure: "failure", +} + +// Real time event (SignalR) for pull request creation +type PullRequestCreatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// The specific type of a pull request merge failure. +type PullRequestMergeFailureType string + +type pullRequestMergeFailureTypeValuesType struct { + None PullRequestMergeFailureType + Unknown PullRequestMergeFailureType + CaseSensitive PullRequestMergeFailureType + ObjectTooLarge PullRequestMergeFailureType +} + +var PullRequestMergeFailureTypeValues = pullRequestMergeFailureTypeValuesType{ + // Type is not set. Default type. + None: "none", + // Pull request merge failure type unknown. + Unknown: "unknown", + // Pull request merge failed due to case mismatch. + CaseSensitive: "caseSensitive", + // Pull request merge failed due to an object being too large. + ObjectTooLarge: "objectTooLarge", +} + +// Status of a pull request. +type PullRequestStatus string + +type pullRequestStatusValuesType struct { + NotSet PullRequestStatus + Active PullRequestStatus + Abandoned PullRequestStatus + Completed PullRequestStatus + All PullRequestStatus +} + +var PullRequestStatusValues = pullRequestStatusValuesType{ + // Status not set. Default state. + NotSet: "notSet", + // Pull request is active. + Active: "active", + // Pull request is abandoned. + Abandoned: "abandoned", + // Pull request is completed. + Completed: "completed", + // Used in pull request search criteria to include all statuses. + All: "all", +} + +// Initial config contract sent to extensions creating tabs on the pull request page +type PullRequestTabExtensionConfig struct { + PullRequestId *int `json:"pullRequestId,omitempty"` + RepositoryId *string `json:"repositoryId,omitempty"` +} + +// Base contract for a real time pull request event (SignalR) +type RealTimePullRequestEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +type RefFavoriteType string + +type refFavoriteTypeValuesType struct { + Invalid RefFavoriteType + Folder RefFavoriteType + Ref RefFavoriteType +} + +var RefFavoriteTypeValues = refFavoriteTypeValuesType{ + Invalid: "invalid", + Folder: "folder", + Ref: "ref", +} + +// Real time event (SignalR) for when the target branch of a pull request is changed +type RetargetEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Real time event (SignalR) for an update to reviewers on a pull request +type ReviewersUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Real time event (SignalR) for reviewer votes being reset on a pull request +type ReviewersVotesResetEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Real time event (SignalR) for a reviewer vote update on a pull request +type ReviewerVoteUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Context used while sharing a pull request. +type ShareNotificationContext struct { + // Optional user note or message. + Message *string `json:"message,omitempty"` + // Identities of users who will receive a share notification. + Receivers *[]webapi.IdentityRef `json:"receivers,omitempty"` +} + +type SourceToTargetRef struct { + // The source ref to copy. For example, refs/heads/master. + SourceRef *string `json:"sourceRef,omitempty"` + // The target ref to update. For example, refs/heads/master. + TargetRef *string `json:"targetRef,omitempty"` +} + +// Real time event (SignalR) for an added status on a pull request +type StatusAddedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Real time event (SignalR) for deleted statuses on a pull request +type StatusesDeletedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Real time event (SignalR) for a status update on a pull request +type StatusUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +// Represents a Supported IDE entity. +type SupportedIde struct { + // The download URL for the IDE. + DownloadUrl *string `json:"downloadUrl,omitempty"` + // The type of the IDE. + IdeType *SupportedIdeType `json:"ideType,omitempty"` + // The name of the IDE. + Name *string `json:"name,omitempty"` + // The URL to open the protocol handler for the IDE. + ProtocolHandlerUrl *string `json:"protocolHandlerUrl,omitempty"` + // A list of SupportedPlatforms. + SupportedPlatforms *[]string `json:"supportedPlatforms,omitempty"` +} + +// Enumeration that represents the types of IDEs supported. +type SupportedIdeType string + +type supportedIdeTypeValuesType struct { + Unknown SupportedIdeType + AndroidStudio SupportedIdeType + AppCode SupportedIdeType + CLion SupportedIdeType + DataGrip SupportedIdeType + Eclipse SupportedIdeType + IntelliJ SupportedIdeType + Mps SupportedIdeType + PhpStorm SupportedIdeType + PyCharm SupportedIdeType + RubyMine SupportedIdeType + Tower SupportedIdeType + VisualStudio SupportedIdeType + VsCode SupportedIdeType + WebStorm SupportedIdeType +} + +var SupportedIdeTypeValues = supportedIdeTypeValuesType{ + Unknown: "unknown", + AndroidStudio: "androidStudio", + AppCode: "appCode", + CLion: "cLion", + DataGrip: "dataGrip", + Eclipse: "eclipse", + IntelliJ: "intelliJ", + Mps: "mps", + PhpStorm: "phpStorm", + PyCharm: "pyCharm", + RubyMine: "rubyMine", + Tower: "tower", + VisualStudio: "visualStudio", + VsCode: "vsCode", + WebStorm: "webStorm", +} + +type TfvcBranch struct { + // Path for the branch. + Path *string `json:"path,omitempty"` + // A collection of REST reference links. + Links interface{} `json:"_links,omitempty"` + // Creation date of the branch. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Description of the branch. + Description *string `json:"description,omitempty"` + // Is the branch deleted? + IsDeleted *bool `json:"isDeleted,omitempty"` + // Alias or display name of user + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` + // List of children for the branch. + Children *[]TfvcBranch `json:"children,omitempty"` + // List of branch mappings. + Mappings *[]TfvcBranchMapping `json:"mappings,omitempty"` + // Path of the branch's parent. + Parent *TfvcShallowBranchRef `json:"parent,omitempty"` + // List of paths of the related branches. + RelatedBranches *[]TfvcShallowBranchRef `json:"relatedBranches,omitempty"` +} + +type TfvcBranchMapping struct { + // Depth of the branch. + Depth *string `json:"depth,omitempty"` + // Server item for the branch. + ServerItem *string `json:"serverItem,omitempty"` + // Type of the branch. + Type *string `json:"type,omitempty"` +} + +type TfvcBranchRef struct { + // Path for the branch. + Path *string `json:"path,omitempty"` + // A collection of REST reference links. + Links interface{} `json:"_links,omitempty"` + // Creation date of the branch. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Description of the branch. + Description *string `json:"description,omitempty"` + // Is the branch deleted? + IsDeleted *bool `json:"isDeleted,omitempty"` + // Alias or display name of user + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` +} + +type TfvcChange struct { + // The type of change that was made to the item. + ChangeType *VersionControlChangeType `json:"changeType,omitempty"` + // Current version. + Item interface{} `json:"item,omitempty"` + // Content of the item after the change. + NewContent *ItemContent `json:"newContent,omitempty"` + // Path of the item on the server. + SourceServerItem *string `json:"sourceServerItem,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` + // List of merge sources in case of rename or branch creation. + MergeSources *[]TfvcMergeSource `json:"mergeSources,omitempty"` + // Version at which a (shelved) change was pended against + PendingVersion *int `json:"pendingVersion,omitempty"` +} + +type TfvcChangeset struct { + // A collection of REST reference links. + Links interface{} `json:"_links,omitempty"` + // Alias or display name of user + Author *webapi.IdentityRef `json:"author,omitempty"` + // Id of the changeset. + ChangesetId *int `json:"changesetId,omitempty"` + // Alias or display name of user + CheckedInBy *webapi.IdentityRef `json:"checkedInBy,omitempty"` + // Comment for the changeset. + Comment *string `json:"comment,omitempty"` + // Was the Comment result truncated? + CommentTruncated *bool `json:"commentTruncated,omitempty"` + // Creation date of the changeset. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` + // Account Id of the changeset. + AccountId *uuid.UUID `json:"accountId,omitempty"` + // List of associated changes. + Changes *[]TfvcChange `json:"changes,omitempty"` + // Checkin Notes for the changeset. + CheckinNotes *[]CheckinNote `json:"checkinNotes,omitempty"` + // Collection Id of the changeset. + CollectionId *uuid.UUID `json:"collectionId,omitempty"` + // Are more changes available. + HasMoreChanges *bool `json:"hasMoreChanges,omitempty"` + // Policy Override for the changeset. + PolicyOverride *TfvcPolicyOverrideInfo `json:"policyOverride,omitempty"` + // Team Project Ids for the changeset. + TeamProjectIds *[]uuid.UUID `json:"teamProjectIds,omitempty"` + // List of work items associated with the changeset. + WorkItems *[]AssociatedWorkItem `json:"workItems,omitempty"` +} + +type TfvcChangesetRef struct { + // A collection of REST reference links. + Links interface{} `json:"_links,omitempty"` + // Alias or display name of user + Author *webapi.IdentityRef `json:"author,omitempty"` + // Id of the changeset. + ChangesetId *int `json:"changesetId,omitempty"` + // Alias or display name of user + CheckedInBy *webapi.IdentityRef `json:"checkedInBy,omitempty"` + // Comment for the changeset. + Comment *string `json:"comment,omitempty"` + // Was the Comment result truncated? + CommentTruncated *bool `json:"commentTruncated,omitempty"` + // Creation date of the changeset. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // URL to retrieve the item. + Url *string `json:"url,omitempty"` +} + +// Criteria used in a search for change lists +type TfvcChangesetSearchCriteria struct { + // Alias or display name of user who made the changes + Author *string `json:"author,omitempty"` + // Whether or not to follow renames for the given item being queried + FollowRenames *bool `json:"followRenames,omitempty"` + // If provided, only include changesets created after this date (string) Think of a better name for this. + FromDate *string `json:"fromDate,omitempty"` + // If provided, only include changesets after this changesetID + FromId *int `json:"fromId,omitempty"` + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` + // Path of item to search under + ItemPath *string `json:"itemPath,omitempty"` + Mappings *[]TfvcMappingFilter `json:"mappings,omitempty"` + // If provided, only include changesets created before this date (string) Think of a better name for this. + ToDate *string `json:"toDate,omitempty"` + // If provided, a version descriptor for the latest change list to include + ToId *int `json:"toId,omitempty"` +} + +type TfvcChangesetsRequestData struct { + // List of changeset Ids. + ChangesetIds *[]int `json:"changesetIds,omitempty"` + // Length of the comment. + CommentLength *int `json:"commentLength,omitempty"` + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` +} + +type TfvcCheckinEventData struct { + Changeset *TfvcChangeset `json:"changeset,omitempty"` + Project *core.TeamProjectReference `json:"project,omitempty"` +} + +type TfvcHistoryEntry struct { + // The Change list (changeset/commit/shelveset) for this point in history + ChangeList interface{} `json:"changeList,omitempty"` + // The change made to the item from this change list (only relevant for File history, not folders) + ItemChangeType *VersionControlChangeType `json:"itemChangeType,omitempty"` + // The path of the item at this point in history (only relevant for File history, not folders) + ServerItem *string `json:"serverItem,omitempty"` + // The encoding of the item at this point in history (only relevant for File history, not folders) + Encoding *int `json:"encoding,omitempty"` + // The file id of the item at this point in history (only relevant for File history, not folders) + FileId *int `json:"fileId,omitempty"` +} + +type TfvcItem struct { + Links interface{} `json:"_links,omitempty"` + Content *string `json:"content,omitempty"` + ContentMetadata *FileContentMetadata `json:"contentMetadata,omitempty"` + IsFolder *bool `json:"isFolder,omitempty"` + IsSymLink *bool `json:"isSymLink,omitempty"` + Path *string `json:"path,omitempty"` + Url *string `json:"url,omitempty"` + ChangeDate *azuredevops.Time `json:"changeDate,omitempty"` + DeletionId *int `json:"deletionId,omitempty"` + // File encoding from database, -1 represents binary. + Encoding *int `json:"encoding,omitempty"` + // MD5 hash as a base 64 string, applies to files only. + HashValue *string `json:"hashValue,omitempty"` + IsBranch *bool `json:"isBranch,omitempty"` + IsPendingChange *bool `json:"isPendingChange,omitempty"` + // The size of the file, if applicable. + Size *uint64 `json:"size,omitempty"` + Version *int `json:"version,omitempty"` +} + +// Item path and Version descriptor properties +type TfvcItemDescriptor struct { + Path *string `json:"path,omitempty"` + RecursionLevel *VersionControlRecursionType `json:"recursionLevel,omitempty"` + Version *string `json:"version,omitempty"` + VersionOption *TfvcVersionOption `json:"versionOption,omitempty"` + VersionType *TfvcVersionType `json:"versionType,omitempty"` +} + +type TfvcItemPreviousHash struct { + Links interface{} `json:"_links,omitempty"` + Content *string `json:"content,omitempty"` + ContentMetadata *FileContentMetadata `json:"contentMetadata,omitempty"` + IsFolder *bool `json:"isFolder,omitempty"` + IsSymLink *bool `json:"isSymLink,omitempty"` + Path *string `json:"path,omitempty"` + Url *string `json:"url,omitempty"` + ChangeDate *azuredevops.Time `json:"changeDate,omitempty"` + DeletionId *int `json:"deletionId,omitempty"` + // File encoding from database, -1 represents binary. + Encoding *int `json:"encoding,omitempty"` + // MD5 hash as a base 64 string, applies to files only. + HashValue *string `json:"hashValue,omitempty"` + IsBranch *bool `json:"isBranch,omitempty"` + IsPendingChange *bool `json:"isPendingChange,omitempty"` + // The size of the file, if applicable. + Size *uint64 `json:"size,omitempty"` + Version *int `json:"version,omitempty"` + // MD5 hash as a base 64 string, applies to files only. + PreviousHashValue *string `json:"previousHashValue,omitempty"` +} + +type TfvcItemRequestData struct { + // If true, include metadata about the file type + IncludeContentMetadata *bool `json:"includeContentMetadata,omitempty"` + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` + ItemDescriptors *[]TfvcItemDescriptor `json:"itemDescriptors,omitempty"` +} + +type TfvcLabel struct { + Links interface{} `json:"_links,omitempty"` + Description *string `json:"description,omitempty"` + Id *int `json:"id,omitempty"` + LabelScope *string `json:"labelScope,omitempty"` + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + Name *string `json:"name,omitempty"` + Owner *webapi.IdentityRef `json:"owner,omitempty"` + Url *string `json:"url,omitempty"` + Items *[]TfvcItem `json:"items,omitempty"` +} + +type TfvcLabelRef struct { + Links interface{} `json:"_links,omitempty"` + Description *string `json:"description,omitempty"` + Id *int `json:"id,omitempty"` + LabelScope *string `json:"labelScope,omitempty"` + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + Name *string `json:"name,omitempty"` + Owner *webapi.IdentityRef `json:"owner,omitempty"` + Url *string `json:"url,omitempty"` +} + +type TfvcLabelRequestData struct { + // Whether to include the _links field on the shallow references + IncludeLinks *bool `json:"includeLinks,omitempty"` + ItemLabelFilter *string `json:"itemLabelFilter,omitempty"` + LabelScope *string `json:"labelScope,omitempty"` + MaxItemCount *int `json:"maxItemCount,omitempty"` + Name *string `json:"name,omitempty"` + Owner *string `json:"owner,omitempty"` +} + +type TfvcMappingFilter struct { + Exclude *bool `json:"exclude,omitempty"` + ServerPath *string `json:"serverPath,omitempty"` +} + +type TfvcMergeSource struct { + // Indicates if this a rename source. If false, it is a merge source. + IsRename *bool `json:"isRename,omitempty"` + // The server item of the merge source + ServerItem *string `json:"serverItem,omitempty"` + // Start of the version range + VersionFrom *int `json:"versionFrom,omitempty"` + // End of the version range + VersionTo *int `json:"versionTo,omitempty"` +} + +type TfvcPolicyFailureInfo struct { + Message *string `json:"message,omitempty"` + PolicyName *string `json:"policyName,omitempty"` +} + +type TfvcPolicyOverrideInfo struct { + Comment *string `json:"comment,omitempty"` + PolicyFailures *[]TfvcPolicyFailureInfo `json:"policyFailures,omitempty"` +} + +type TfvcShallowBranchRef struct { + // Path for the branch. + Path *string `json:"path,omitempty"` +} + +// This is the deep shelveset class +type TfvcShelveset struct { + Links interface{} `json:"_links,omitempty"` + Comment *string `json:"comment,omitempty"` + CommentTruncated *bool `json:"commentTruncated,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Owner *webapi.IdentityRef `json:"owner,omitempty"` + Url *string `json:"url,omitempty"` + Changes *[]TfvcChange `json:"changes,omitempty"` + Notes *[]CheckinNote `json:"notes,omitempty"` + PolicyOverride *TfvcPolicyOverrideInfo `json:"policyOverride,omitempty"` + WorkItems *[]AssociatedWorkItem `json:"workItems,omitempty"` +} + +// This is the shallow shelveset class +type TfvcShelvesetRef struct { + Links interface{} `json:"_links,omitempty"` + Comment *string `json:"comment,omitempty"` + CommentTruncated *bool `json:"commentTruncated,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Owner *webapi.IdentityRef `json:"owner,omitempty"` + Url *string `json:"url,omitempty"` +} + +type TfvcShelvesetRequestData struct { + // Whether to include policyOverride and notes Only applies when requesting a single deep shelveset + IncludeDetails *bool `json:"includeDetails,omitempty"` + // Whether to include the _links field on the shallow references. Does not apply when requesting a single deep shelveset object. Links will always be included in the deep shelveset. + IncludeLinks *bool `json:"includeLinks,omitempty"` + // Whether to include workItems + IncludeWorkItems *bool `json:"includeWorkItems,omitempty"` + // Max number of changes to include + MaxChangeCount *int `json:"maxChangeCount,omitempty"` + // Max length of comment + MaxCommentLength *int `json:"maxCommentLength,omitempty"` + // Shelveset's name + Name *string `json:"name,omitempty"` + // Owner's ID. Could be a name or a guid. + Owner *string `json:"owner,omitempty"` +} + +type TfvcStatistics struct { + // Id of the last changeset the stats are based on. + ChangesetId *int `json:"changesetId,omitempty"` + // Count of files at the requested scope. + FileCountTotal *uint64 `json:"fileCountTotal,omitempty"` +} + +type TfvcVersionDescriptor struct { + Version *string `json:"version,omitempty"` + VersionOption *TfvcVersionOption `json:"versionOption,omitempty"` + VersionType *TfvcVersionType `json:"versionType,omitempty"` +} + +type TfvcVersionOption string + +type tfvcVersionOptionValuesType struct { + None TfvcVersionOption + Previous TfvcVersionOption + UseRename TfvcVersionOption +} + +var TfvcVersionOptionValues = tfvcVersionOptionValuesType{ + None: "none", + Previous: "previous", + UseRename: "useRename", +} + +type TfvcVersionType string + +type tfvcVersionTypeValuesType struct { + None TfvcVersionType + Changeset TfvcVersionType + Shelveset TfvcVersionType + Change TfvcVersionType + Date TfvcVersionType + Latest TfvcVersionType + Tip TfvcVersionType + MergeSource TfvcVersionType +} + +var TfvcVersionTypeValues = tfvcVersionTypeValuesType{ + None: "none", + Changeset: "changeset", + Shelveset: "shelveset", + Change: "change", + Date: "date", + Latest: "latest", + Tip: "tip", + MergeSource: "mergeSource", +} + +// Real time event (SignalR) for a title/description update on a pull request +type TitleDescriptionUpdatedEvent struct { + // The id of this event. Can be used to track send/receive state between client and server. + EventId *uuid.UUID `json:"eventId,omitempty"` + // The id of the pull request this event was generated for. + PullRequestId *int `json:"pullRequestId,omitempty"` +} + +type UpdateRefsRequest struct { + RefUpdateRequests *[]GitRefUpdate `json:"refUpdateRequests,omitempty"` + UpdateMode *GitRefUpdateMode `json:"updateMode,omitempty"` +} + +// [Flags] +type VersionControlChangeType string + +type versionControlChangeTypeValuesType struct { + None VersionControlChangeType + Add VersionControlChangeType + Edit VersionControlChangeType + Encoding VersionControlChangeType + Rename VersionControlChangeType + Delete VersionControlChangeType + Undelete VersionControlChangeType + Branch VersionControlChangeType + Merge VersionControlChangeType + Lock VersionControlChangeType + Rollback VersionControlChangeType + SourceRename VersionControlChangeType + TargetRename VersionControlChangeType + Property VersionControlChangeType + All VersionControlChangeType +} + +var VersionControlChangeTypeValues = versionControlChangeTypeValuesType{ + None: "none", + Add: "add", + Edit: "edit", + Encoding: "encoding", + Rename: "rename", + Delete: "delete", + Undelete: "undelete", + Branch: "branch", + Merge: "merge", + Lock: "lock", + Rollback: "rollback", + SourceRename: "sourceRename", + TargetRename: "targetRename", + Property: "property", + All: "all", +} + +type VersionControlProjectInfo struct { + DefaultSourceControlType *core.SourceControlTypes `json:"defaultSourceControlType,omitempty"` + Project *core.TeamProjectReference `json:"project,omitempty"` + SupportsGit *bool `json:"supportsGit,omitempty"` + SupportsTFVC *bool `json:"supportsTFVC,omitempty"` +} + +type VersionControlRecursionType string + +type versionControlRecursionTypeValuesType struct { + None VersionControlRecursionType + OneLevel VersionControlRecursionType + OneLevelPlusNestedEmptyFolders VersionControlRecursionType + Full VersionControlRecursionType +} + +var VersionControlRecursionTypeValues = versionControlRecursionTypeValuesType{ + // Only return the specified item. + None: "none", + // Return the specified item and its direct children. + OneLevel: "oneLevel", + // Return the specified item and its direct children, as well as recursive chains of nested child folders that only contain a single folder. + OneLevelPlusNestedEmptyFolders: "oneLevelPlusNestedEmptyFolders", + // Return specified item and all descendants + Full: "full", +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/go.mod b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/go.mod new file mode 100644 index 0000000000..0486f05889 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/go.mod @@ -0,0 +1,5 @@ +module github.com/microsoft/azure-devops-go-api/azuredevops + +go 1.12 + +require github.com/google/uuid v1.1.1 diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/go.sum b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/go.sum new file mode 100644 index 0000000000..b864886e0d --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/go.sum @@ -0,0 +1,2 @@ +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/identity/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/identity/client.go new file mode 100644 index 0000000000..226eab9186 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/identity/client.go @@ -0,0 +1,996 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package identity + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/delegatedauthorization" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("8a3d49b8-91f0-46ef-b33d-dda338c25db3") + +type Client interface { + // [Preview API] + AddMember(context.Context, AddMemberArgs) (*bool, error) + CreateGroups(context.Context, CreateGroupsArgs) (*[]Identity, error) + CreateIdentity(context.Context, CreateIdentityArgs) (*Identity, error) + // [Preview API] + CreateOrBindWithClaims(context.Context, CreateOrBindWithClaimsArgs) (*Identity, error) + // [Preview API] + CreateScope(context.Context, CreateScopeArgs) (*IdentityScope, error) + DeleteGroup(context.Context, DeleteGroupArgs) error + // [Preview API] + DeleteScope(context.Context, DeleteScopeArgs) error + // [Preview API] + GetDescriptorById(context.Context, GetDescriptorByIdArgs) (*string, error) + GetIdentityChanges(context.Context, GetIdentityChangesArgs) (*ChangedIdentities, error) + // [Preview API] + GetIdentitySnapshot(context.Context, GetIdentitySnapshotArgs) (*IdentitySnapshot, error) + // Read the max sequence id of all the identities. + GetMaxSequenceId(context.Context, GetMaxSequenceIdArgs) (*uint64, error) + // [Preview API] + GetScopeById(context.Context, GetScopeByIdArgs) (*IdentityScope, error) + // [Preview API] + GetScopeByName(context.Context, GetScopeByNameArgs) (*IdentityScope, error) + // Read identity of the home tenant request user. + GetSelf(context.Context, GetSelfArgs) (*IdentitySelf, error) + // [Preview API] + GetSignedInToken(context.Context, GetSignedInTokenArgs) (*delegatedauthorization.AccessTokenResult, error) + // [Preview API] + GetSignoutToken(context.Context, GetSignoutTokenArgs) (*delegatedauthorization.AccessTokenResult, error) + // [Preview API] + GetTenant(context.Context, GetTenantArgs) (*TenantInfo, error) + GetUserIdentityIdsByDomainId(context.Context, GetUserIdentityIdsByDomainIdArgs) (*[]uuid.UUID, error) + ListGroups(context.Context, ListGroupsArgs) (*[]Identity, error) + ReadIdentities(context.Context, ReadIdentitiesArgs) (*[]Identity, error) + ReadIdentitiesByScope(context.Context, ReadIdentitiesByScopeArgs) (*[]Identity, error) + ReadIdentity(context.Context, ReadIdentityArgs) (*Identity, error) + // [Preview API] + ReadIdentityBatch(context.Context, ReadIdentityBatchArgs) (*[]Identity, error) + // [Preview API] + ReadMember(context.Context, ReadMemberArgs) (*string, error) + // [Preview API] + ReadMemberOf(context.Context, ReadMemberOfArgs) (*string, error) + // [Preview API] + ReadMembers(context.Context, ReadMembersArgs) (*[]string, error) + // [Preview API] + ReadMembersOf(context.Context, ReadMembersOfArgs) (*[]string, error) + // [Preview API] + RemoveMember(context.Context, RemoveMemberArgs) (*bool, error) + UpdateIdentities(context.Context, UpdateIdentitiesArgs) (*[]IdentityUpdateData, error) + UpdateIdentity(context.Context, UpdateIdentityArgs) error + // [Preview API] + UpdateScope(context.Context, UpdateScopeArgs) error +} + +type ClientImpl struct { + Client azuredevops.Client +} + +func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { + client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) + if err != nil { + return nil, err + } + return &ClientImpl{ + Client: *client, + }, nil +} + +// [Preview API] +func (client *ClientImpl) AddMember(ctx context.Context, args AddMemberArgs) (*bool, error) { + routeValues := make(map[string]string) + if args.ContainerId == nil || *args.ContainerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = *args.ContainerId + if args.MemberId == nil || *args.MemberId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.MemberId"} + } + routeValues["memberId"] = *args.MemberId + + locationId, _ := uuid.Parse("8ba35978-138e-41f8-8963-7b1ea2c5f775") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue bool + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddMember function +type AddMemberArgs struct { + // (required) + ContainerId *string + // (required) + MemberId *string +} + +func (client *ClientImpl) CreateGroups(ctx context.Context, args CreateGroupsArgs) (*[]Identity, error) { + if args.Container == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Container"} + } + body, marshalErr := json.Marshal(args.Container) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("5966283b-4196-4d57-9211-1b68f41ec1c2") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Identity + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateGroups function +type CreateGroupsArgs struct { + // (required) + Container interface{} +} + +func (client *ClientImpl) CreateIdentity(ctx context.Context, args CreateIdentityArgs) (*Identity, error) { + if args.FrameworkIdentityInfo == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.FrameworkIdentityInfo"} + } + body, marshalErr := json.Marshal(*args.FrameworkIdentityInfo) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("dd55f0eb-6ea2-4fe4-9ebe-919e7dd1dfb4") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Identity + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateIdentity function +type CreateIdentityArgs struct { + // (required) + FrameworkIdentityInfo *FrameworkIdentityInfo +} + +// [Preview API] +func (client *ClientImpl) CreateOrBindWithClaims(ctx context.Context, args CreateOrBindWithClaimsArgs) (*Identity, error) { + if args.SourceIdentity == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SourceIdentity"} + } + body, marshalErr := json.Marshal(*args.SourceIdentity) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("90ddfe71-171c-446c-bf3b-b597cd562afd") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Identity + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateOrBindWithClaims function +type CreateOrBindWithClaimsArgs struct { + // (required) + SourceIdentity *Identity +} + +// [Preview API] +func (client *ClientImpl) CreateScope(ctx context.Context, args CreateScopeArgs) (*IdentityScope, error) { + if args.Info == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Info"} + } + routeValues := make(map[string]string) + if args.ScopeId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeId"} + } + routeValues["scopeId"] = (*args.ScopeId).String() + + body, marshalErr := json.Marshal(*args.Info) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4e11e2bf-1e79-4eb5-8f34-a6337bd0de38") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue IdentityScope + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateScope function +type CreateScopeArgs struct { + // (required) + Info *CreateScopeInfo + // (required) + ScopeId *uuid.UUID +} + +func (client *ClientImpl) DeleteGroup(ctx context.Context, args DeleteGroupArgs) error { + routeValues := make(map[string]string) + if args.GroupId == nil || *args.GroupId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + + locationId, _ := uuid.Parse("5966283b-4196-4d57-9211-1b68f41ec1c2") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteGroup function +type DeleteGroupArgs struct { + // (required) + GroupId *string +} + +// [Preview API] +func (client *ClientImpl) DeleteScope(ctx context.Context, args DeleteScopeArgs) error { + routeValues := make(map[string]string) + if args.ScopeId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeId"} + } + routeValues["scopeId"] = (*args.ScopeId).String() + + locationId, _ := uuid.Parse("4e11e2bf-1e79-4eb5-8f34-a6337bd0de38") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteScope function +type DeleteScopeArgs struct { + // (required) + ScopeId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) GetDescriptorById(ctx context.Context, args GetDescriptorByIdArgs) (*string, error) { + routeValues := make(map[string]string) + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + + queryParams := url.Values{} + if args.IsMasterId != nil { + queryParams.Add("isMasterId", strconv.FormatBool(*args.IsMasterId)) + } + locationId, _ := uuid.Parse("a230389a-94f2-496c-839f-c929787496dd") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue string + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDescriptorById function +type GetDescriptorByIdArgs struct { + // (required) + Id *uuid.UUID + // (optional) + IsMasterId *bool +} + +func (client *ClientImpl) GetIdentityChanges(ctx context.Context, args GetIdentityChangesArgs) (*ChangedIdentities, error) { + queryParams := url.Values{} + if args.IdentitySequenceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "identitySequenceId"} + } + queryParams.Add("identitySequenceId", strconv.Itoa(*args.IdentitySequenceId)) + if args.GroupSequenceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "groupSequenceId"} + } + queryParams.Add("groupSequenceId", strconv.Itoa(*args.GroupSequenceId)) + if args.OrganizationIdentitySequenceId != nil { + queryParams.Add("organizationIdentitySequenceId", strconv.Itoa(*args.OrganizationIdentitySequenceId)) + } + if args.PageSize != nil { + queryParams.Add("pageSize", strconv.Itoa(*args.PageSize)) + } + if args.ScopeId != nil { + queryParams.Add("scopeId", (*args.ScopeId).String()) + } + locationId, _ := uuid.Parse("28010c54-d0c0-4c89-a5b0-1c9e188b9fb7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ChangedIdentities + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetIdentityChanges function +type GetIdentityChangesArgs struct { + // (required) + IdentitySequenceId *int + // (required) + GroupSequenceId *int + // (optional) + OrganizationIdentitySequenceId *int + // (optional) + PageSize *int + // (optional) + ScopeId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) GetIdentitySnapshot(ctx context.Context, args GetIdentitySnapshotArgs) (*IdentitySnapshot, error) { + routeValues := make(map[string]string) + if args.ScopeId == nil || *args.ScopeId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeId"} + } + routeValues["scopeId"] = *args.ScopeId + + locationId, _ := uuid.Parse("d56223df-8ccd-45c9-89b4-eddf692400d7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue IdentitySnapshot + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetIdentitySnapshot function +type GetIdentitySnapshotArgs struct { + // (required) + ScopeId *string +} + +// Read the max sequence id of all the identities. +func (client *ClientImpl) GetMaxSequenceId(ctx context.Context, args GetMaxSequenceIdArgs) (*uint64, error) { + locationId, _ := uuid.Parse("e4a70778-cb2c-4e85-b7cc-3f3c7ae2d408") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue uint64 + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetMaxSequenceId function +type GetMaxSequenceIdArgs struct { +} + +// [Preview API] +func (client *ClientImpl) GetScopeById(ctx context.Context, args GetScopeByIdArgs) (*IdentityScope, error) { + routeValues := make(map[string]string) + if args.ScopeId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeId"} + } + routeValues["scopeId"] = (*args.ScopeId).String() + + locationId, _ := uuid.Parse("4e11e2bf-1e79-4eb5-8f34-a6337bd0de38") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue IdentityScope + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetScopeById function +type GetScopeByIdArgs struct { + // (required) + ScopeId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) GetScopeByName(ctx context.Context, args GetScopeByNameArgs) (*IdentityScope, error) { + queryParams := url.Values{} + if args.ScopeName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "scopeName"} + } + queryParams.Add("scopeName", *args.ScopeName) + locationId, _ := uuid.Parse("4e11e2bf-1e79-4eb5-8f34-a6337bd0de38") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue IdentityScope + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetScopeByName function +type GetScopeByNameArgs struct { + // (required) + ScopeName *string +} + +// Read identity of the home tenant request user. +func (client *ClientImpl) GetSelf(ctx context.Context, args GetSelfArgs) (*IdentitySelf, error) { + locationId, _ := uuid.Parse("4bb02b5b-c120-4be2-b68e-21f7c50a4b82") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue IdentitySelf + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSelf function +type GetSelfArgs struct { +} + +// [Preview API] +func (client *ClientImpl) GetSignedInToken(ctx context.Context, args GetSignedInTokenArgs) (*delegatedauthorization.AccessTokenResult, error) { + locationId, _ := uuid.Parse("6074ff18-aaad-4abb-a41e-5c75f6178057") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue delegatedauthorization.AccessTokenResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSignedInToken function +type GetSignedInTokenArgs struct { +} + +// [Preview API] +func (client *ClientImpl) GetSignoutToken(ctx context.Context, args GetSignoutTokenArgs) (*delegatedauthorization.AccessTokenResult, error) { + locationId, _ := uuid.Parse("be39e83c-7529-45e9-9c67-0410885880da") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue delegatedauthorization.AccessTokenResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSignoutToken function +type GetSignoutTokenArgs struct { +} + +// [Preview API] +func (client *ClientImpl) GetTenant(ctx context.Context, args GetTenantArgs) (*TenantInfo, error) { + routeValues := make(map[string]string) + if args.TenantId == nil || *args.TenantId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TenantId"} + } + routeValues["tenantId"] = *args.TenantId + + locationId, _ := uuid.Parse("5f0a1723-2e2c-4c31-8cae-002d01bdd592") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TenantInfo + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTenant function +type GetTenantArgs struct { + // (required) + TenantId *string +} + +func (client *ClientImpl) GetUserIdentityIdsByDomainId(ctx context.Context, args GetUserIdentityIdsByDomainIdArgs) (*[]uuid.UUID, error) { + queryParams := url.Values{} + if args.DomainId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "domainId"} + } + queryParams.Add("domainId", (*args.DomainId).String()) + locationId, _ := uuid.Parse("28010c54-d0c0-4c89-a5b0-1c9e188b9fb7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []uuid.UUID + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetUserIdentityIdsByDomainId function +type GetUserIdentityIdsByDomainIdArgs struct { + // (required) + DomainId *uuid.UUID +} + +func (client *ClientImpl) ListGroups(ctx context.Context, args ListGroupsArgs) (*[]Identity, error) { + queryParams := url.Values{} + if args.ScopeIds != nil { + queryParams.Add("scopeIds", *args.ScopeIds) + } + if args.Recurse != nil { + queryParams.Add("recurse", strconv.FormatBool(*args.Recurse)) + } + if args.Deleted != nil { + queryParams.Add("deleted", strconv.FormatBool(*args.Deleted)) + } + if args.Properties != nil { + queryParams.Add("properties", *args.Properties) + } + locationId, _ := uuid.Parse("5966283b-4196-4d57-9211-1b68f41ec1c2") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Identity + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListGroups function +type ListGroupsArgs struct { + // (optional) + ScopeIds *string + // (optional) + Recurse *bool + // (optional) + Deleted *bool + // (optional) + Properties *string +} + +func (client *ClientImpl) ReadIdentities(ctx context.Context, args ReadIdentitiesArgs) (*[]Identity, error) { + queryParams := url.Values{} + if args.Descriptors != nil { + queryParams.Add("descriptors", *args.Descriptors) + } + if args.IdentityIds != nil { + queryParams.Add("identityIds", *args.IdentityIds) + } + if args.SubjectDescriptors != nil { + queryParams.Add("subjectDescriptors", *args.SubjectDescriptors) + } + if args.SocialDescriptors != nil { + queryParams.Add("socialDescriptors", *args.SocialDescriptors) + } + if args.SearchFilter != nil { + queryParams.Add("searchFilter", *args.SearchFilter) + } + if args.FilterValue != nil { + queryParams.Add("filterValue", *args.FilterValue) + } + if args.QueryMembership != nil { + queryParams.Add("queryMembership", string(*args.QueryMembership)) + } + if args.Properties != nil { + queryParams.Add("properties", *args.Properties) + } + if args.IncludeRestrictedVisibility != nil { + queryParams.Add("includeRestrictedVisibility", strconv.FormatBool(*args.IncludeRestrictedVisibility)) + } + if args.Options != nil { + queryParams.Add("options", string(*args.Options)) + } + locationId, _ := uuid.Parse("28010c54-d0c0-4c89-a5b0-1c9e188b9fb7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Identity + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadIdentities function +type ReadIdentitiesArgs struct { + // (optional) + Descriptors *string + // (optional) + IdentityIds *string + // (optional) + SubjectDescriptors *string + // (optional) + SocialDescriptors *string + // (optional) + SearchFilter *string + // (optional) + FilterValue *string + // (optional) + QueryMembership *QueryMembership + // (optional) + Properties *string + // (optional) + IncludeRestrictedVisibility *bool + // (optional) + Options *ReadIdentitiesOptions +} + +func (client *ClientImpl) ReadIdentitiesByScope(ctx context.Context, args ReadIdentitiesByScopeArgs) (*[]Identity, error) { + queryParams := url.Values{} + if args.ScopeId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "scopeId"} + } + queryParams.Add("scopeId", (*args.ScopeId).String()) + if args.QueryMembership != nil { + queryParams.Add("queryMembership", string(*args.QueryMembership)) + } + if args.Properties != nil { + queryParams.Add("properties", *args.Properties) + } + locationId, _ := uuid.Parse("28010c54-d0c0-4c89-a5b0-1c9e188b9fb7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Identity + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadIdentitiesByScope function +type ReadIdentitiesByScopeArgs struct { + // (required) + ScopeId *uuid.UUID + // (optional) + QueryMembership *QueryMembership + // (optional) + Properties *string +} + +func (client *ClientImpl) ReadIdentity(ctx context.Context, args ReadIdentityArgs) (*Identity, error) { + routeValues := make(map[string]string) + if args.IdentityId == nil || *args.IdentityId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.IdentityId"} + } + routeValues["identityId"] = *args.IdentityId + + queryParams := url.Values{} + if args.QueryMembership != nil { + queryParams.Add("queryMembership", string(*args.QueryMembership)) + } + if args.Properties != nil { + queryParams.Add("properties", *args.Properties) + } + locationId, _ := uuid.Parse("28010c54-d0c0-4c89-a5b0-1c9e188b9fb7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Identity + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadIdentity function +type ReadIdentityArgs struct { + // (required) + IdentityId *string + // (optional) + QueryMembership *QueryMembership + // (optional) + Properties *string +} + +// [Preview API] +func (client *ClientImpl) ReadIdentityBatch(ctx context.Context, args ReadIdentityBatchArgs) (*[]Identity, error) { + if args.BatchInfo == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BatchInfo"} + } + body, marshalErr := json.Marshal(*args.BatchInfo) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("299e50df-fe45-4d3a-8b5b-a5836fac74dc") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Identity + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadIdentityBatch function +type ReadIdentityBatchArgs struct { + // (required) + BatchInfo *IdentityBatchInfo +} + +// [Preview API] +func (client *ClientImpl) ReadMember(ctx context.Context, args ReadMemberArgs) (*string, error) { + routeValues := make(map[string]string) + if args.ContainerId == nil || *args.ContainerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = *args.ContainerId + if args.MemberId == nil || *args.MemberId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.MemberId"} + } + routeValues["memberId"] = *args.MemberId + + queryParams := url.Values{} + if args.QueryMembership != nil { + queryParams.Add("queryMembership", string(*args.QueryMembership)) + } + locationId, _ := uuid.Parse("8ba35978-138e-41f8-8963-7b1ea2c5f775") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue string + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadMember function +type ReadMemberArgs struct { + // (required) + ContainerId *string + // (required) + MemberId *string + // (optional) + QueryMembership *QueryMembership +} + +// [Preview API] +func (client *ClientImpl) ReadMemberOf(ctx context.Context, args ReadMemberOfArgs) (*string, error) { + routeValues := make(map[string]string) + if args.MemberId == nil || *args.MemberId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.MemberId"} + } + routeValues["memberId"] = *args.MemberId + if args.ContainerId == nil || *args.ContainerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = *args.ContainerId + + queryParams := url.Values{} + if args.QueryMembership != nil { + queryParams.Add("queryMembership", string(*args.QueryMembership)) + } + locationId, _ := uuid.Parse("22865b02-9e4a-479e-9e18-e35b8803b8a0") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue string + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadMemberOf function +type ReadMemberOfArgs struct { + // (required) + MemberId *string + // (required) + ContainerId *string + // (optional) + QueryMembership *QueryMembership +} + +// [Preview API] +func (client *ClientImpl) ReadMembers(ctx context.Context, args ReadMembersArgs) (*[]string, error) { + routeValues := make(map[string]string) + if args.ContainerId == nil || *args.ContainerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = *args.ContainerId + + queryParams := url.Values{} + if args.QueryMembership != nil { + queryParams.Add("queryMembership", string(*args.QueryMembership)) + } + locationId, _ := uuid.Parse("8ba35978-138e-41f8-8963-7b1ea2c5f775") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadMembers function +type ReadMembersArgs struct { + // (required) + ContainerId *string + // (optional) + QueryMembership *QueryMembership +} + +// [Preview API] +func (client *ClientImpl) ReadMembersOf(ctx context.Context, args ReadMembersOfArgs) (*[]string, error) { + routeValues := make(map[string]string) + if args.MemberId == nil || *args.MemberId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.MemberId"} + } + routeValues["memberId"] = *args.MemberId + + queryParams := url.Values{} + if args.QueryMembership != nil { + queryParams.Add("queryMembership", string(*args.QueryMembership)) + } + locationId, _ := uuid.Parse("22865b02-9e4a-479e-9e18-e35b8803b8a0") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadMembersOf function +type ReadMembersOfArgs struct { + // (required) + MemberId *string + // (optional) + QueryMembership *QueryMembership +} + +// [Preview API] +func (client *ClientImpl) RemoveMember(ctx context.Context, args RemoveMemberArgs) (*bool, error) { + routeValues := make(map[string]string) + if args.ContainerId == nil || *args.ContainerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = *args.ContainerId + if args.MemberId == nil || *args.MemberId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.MemberId"} + } + routeValues["memberId"] = *args.MemberId + + locationId, _ := uuid.Parse("8ba35978-138e-41f8-8963-7b1ea2c5f775") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue bool + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RemoveMember function +type RemoveMemberArgs struct { + // (required) + ContainerId *string + // (required) + MemberId *string +} + +func (client *ClientImpl) UpdateIdentities(ctx context.Context, args UpdateIdentitiesArgs) (*[]IdentityUpdateData, error) { + if args.Identities == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Identities"} + } + body, marshalErr := json.Marshal(*args.Identities) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("28010c54-d0c0-4c89-a5b0-1c9e188b9fb7") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []IdentityUpdateData + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateIdentities function +type UpdateIdentitiesArgs struct { + // (required) + Identities *azuredevops.VssJsonCollectionWrapper +} + +func (client *ClientImpl) UpdateIdentity(ctx context.Context, args UpdateIdentityArgs) error { + if args.Identity == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Identity"} + } + routeValues := make(map[string]string) + if args.IdentityId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.IdentityId"} + } + routeValues["identityId"] = (*args.IdentityId).String() + + body, marshalErr := json.Marshal(*args.Identity) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("28010c54-d0c0-4c89-a5b0-1c9e188b9fb7") + _, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the UpdateIdentity function +type UpdateIdentityArgs struct { + // (required) + Identity *Identity + // (required) + IdentityId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) UpdateScope(ctx context.Context, args UpdateScopeArgs) error { + if args.PatchDocument == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PatchDocument"} + } + routeValues := make(map[string]string) + if args.ScopeId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeId"} + } + routeValues["scopeId"] = (*args.ScopeId).String() + + body, marshalErr := json.Marshal(*args.PatchDocument) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("4e11e2bf-1e79-4eb5-8f34-a6337bd0de38") + _, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the UpdateScope function +type UpdateScopeArgs struct { + // (required) + PatchDocument *[]webapi.JsonPatchOperation + // (required) + ScopeId *uuid.UUID +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/identity/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/identity/models.go new file mode 100644 index 0000000000..54f9b75e73 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/identity/models.go @@ -0,0 +1,234 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package identity + +import ( + "github.com/google/uuid" +) + +// Container class for changed identities +type ChangedIdentities struct { + // Changed Identities + Identities *[]Identity `json:"identities,omitempty"` + // More data available, set to true if pagesize is specified. + MoreData *bool `json:"moreData,omitempty"` + // Last Identity SequenceId + SequenceContext *ChangedIdentitiesContext `json:"sequenceContext,omitempty"` +} + +// Context class for changed identities +type ChangedIdentitiesContext struct { + // Last Group SequenceId + GroupSequenceId *int `json:"groupSequenceId,omitempty"` + // Last Identity SequenceId + IdentitySequenceId *int `json:"identitySequenceId,omitempty"` + // Last Group OrganizationIdentitySequenceId + OrganizationIdentitySequenceId *int `json:"organizationIdentitySequenceId,omitempty"` + // Page size + PageSize *int `json:"pageSize,omitempty"` +} + +type CreateScopeInfo struct { + AdminGroupDescription *string `json:"adminGroupDescription,omitempty"` + AdminGroupName *string `json:"adminGroupName,omitempty"` + CreatorId *uuid.UUID `json:"creatorId,omitempty"` + ParentScopeId *uuid.UUID `json:"parentScopeId,omitempty"` + ScopeName *string `json:"scopeName,omitempty"` + ScopeType *GroupScopeType `json:"scopeType,omitempty"` +} + +type FrameworkIdentityInfo struct { + DisplayName *string `json:"displayName,omitempty"` + Identifier *string `json:"identifier,omitempty"` + IdentityType *FrameworkIdentityType `json:"identityType,omitempty"` + Role *string `json:"role,omitempty"` +} + +type FrameworkIdentityType string + +type frameworkIdentityTypeValuesType struct { + None FrameworkIdentityType + ServiceIdentity FrameworkIdentityType + AggregateIdentity FrameworkIdentityType + ImportedIdentity FrameworkIdentityType +} + +var FrameworkIdentityTypeValues = frameworkIdentityTypeValuesType{ + None: "none", + ServiceIdentity: "serviceIdentity", + AggregateIdentity: "aggregateIdentity", + ImportedIdentity: "importedIdentity", +} + +type GroupMembership struct { + Active *bool `json:"active,omitempty"` + Descriptor *string `json:"descriptor,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + QueriedId *uuid.UUID `json:"queriedId,omitempty"` +} + +type GroupScopeType string + +type groupScopeTypeValuesType struct { + Generic GroupScopeType + ServiceHost GroupScopeType + TeamProject GroupScopeType +} + +var GroupScopeTypeValues = groupScopeTypeValuesType{ + Generic: "generic", + ServiceHost: "serviceHost", + TeamProject: "teamProject", +} + +type Identity struct { + // The custom display name for the identity (if any). Setting this property to an empty string will clear the existing custom display name. Setting this property to null will not affect the existing persisted value (since null values do not get sent over the wire or to the database) + CustomDisplayName *string `json:"customDisplayName,omitempty"` + Descriptor *string `json:"descriptor,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsContainer *bool `json:"isContainer,omitempty"` + MasterId *uuid.UUID `json:"masterId,omitempty"` + MemberIds *[]uuid.UUID `json:"memberIds,omitempty"` + MemberOf *[]string `json:"memberOf,omitempty"` + Members *[]string `json:"members,omitempty"` + MetaTypeId *int `json:"metaTypeId,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // The display name for the identity as specified by the source identity provider. + ProviderDisplayName *string `json:"providerDisplayName,omitempty"` + ResourceVersion *int `json:"resourceVersion,omitempty"` + SocialDescriptor *string `json:"socialDescriptor,omitempty"` + SubjectDescriptor *string `json:"subjectDescriptor,omitempty"` + UniqueUserId *int `json:"uniqueUserId,omitempty"` +} + +// Base Identity class to allow "trimmed" identity class in the GetConnectionData API Makes sure that on-the-wire representations of the derived classes are compatible with each other (e.g. Server responds with PublicIdentity object while client deserializes it as Identity object) Derived classes should not have additional [DataMember] properties +type IdentityBase struct { + // The custom display name for the identity (if any). Setting this property to an empty string will clear the existing custom display name. Setting this property to null will not affect the existing persisted value (since null values do not get sent over the wire or to the database) + CustomDisplayName *string `json:"customDisplayName,omitempty"` + Descriptor *string `json:"descriptor,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsContainer *bool `json:"isContainer,omitempty"` + MasterId *uuid.UUID `json:"masterId,omitempty"` + MemberIds *[]uuid.UUID `json:"memberIds,omitempty"` + MemberOf *[]string `json:"memberOf,omitempty"` + Members *[]string `json:"members,omitempty"` + MetaTypeId *int `json:"metaTypeId,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // The display name for the identity as specified by the source identity provider. + ProviderDisplayName *string `json:"providerDisplayName,omitempty"` + ResourceVersion *int `json:"resourceVersion,omitempty"` + SocialDescriptor *string `json:"socialDescriptor,omitempty"` + SubjectDescriptor *string `json:"subjectDescriptor,omitempty"` + UniqueUserId *int `json:"uniqueUserId,omitempty"` +} + +type IdentityBatchInfo struct { + Descriptors *[]string `json:"descriptors,omitempty"` + IdentityIds *[]uuid.UUID `json:"identityIds,omitempty"` + IncludeRestrictedVisibility *bool `json:"includeRestrictedVisibility,omitempty"` + PropertyNames *[]string `json:"propertyNames,omitempty"` + QueryMembership *QueryMembership `json:"queryMembership,omitempty"` + SocialDescriptors *[]string `json:"socialDescriptors,omitempty"` + SubjectDescriptors *[]string `json:"subjectDescriptors,omitempty"` +} + +type IdentityScope struct { + Administrators *string `json:"administrators,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsGlobal *bool `json:"isGlobal,omitempty"` + LocalScopeId *uuid.UUID `json:"localScopeId,omitempty"` + Name *string `json:"name,omitempty"` + ParentId *uuid.UUID `json:"parentId,omitempty"` + ScopeType *GroupScopeType `json:"scopeType,omitempty"` + SecuringHostId *uuid.UUID `json:"securingHostId,omitempty"` + SubjectDescriptor *string `json:"subjectDescriptor,omitempty"` +} + +// Identity information. +type IdentitySelf struct { + // The UserPrincipalName (UPN) of the account. This value comes from the source provider. + AccountName *string `json:"accountName,omitempty"` + // The display name. For AAD accounts with multiple tenants this is the display name of the profile in the home tenant. + DisplayName *string `json:"displayName,omitempty"` + // This represents the name of the container of origin. For AAD accounts this is the tenantID of the home tenant. For MSA accounts this is the string "Windows Live ID". + Domain *string `json:"domain,omitempty"` + // This is the VSID of the home tenant profile. If the profile is signed into the home tenant or if the profile has no tenants then this Id is the same as the Id returned by the profile/profiles/me endpoint. Going forward it is recommended that you use the combined values of Origin, OriginId and Domain to uniquely identify a user rather than this Id. + Id *uuid.UUID `json:"id,omitempty"` + // The type of source provider for the origin identifier. For MSA accounts this is "msa". For AAD accounts this is "aad". + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. If there are multiple tenants this is the unique identifier of the account in the home tenant. (For MSA this is the PUID in hex notation, for AAD this is the object id.) + OriginId *string `json:"originId,omitempty"` + // For AAD accounts this is all of the tenants that this account is a member of. + Tenants *[]TenantInfo `json:"tenants,omitempty"` +} + +type IdentitySnapshot struct { + Groups *[]Identity `json:"groups,omitempty"` + IdentityIds *[]uuid.UUID `json:"identityIds,omitempty"` + Memberships *[]GroupMembership `json:"memberships,omitempty"` + ScopeId *uuid.UUID `json:"scopeId,omitempty"` + Scopes *[]IdentityScope `json:"scopes,omitempty"` +} + +type IdentityUpdateData struct { + Id *uuid.UUID `json:"id,omitempty"` + Index *int `json:"index,omitempty"` + Updated *bool `json:"updated,omitempty"` +} + +type QueryMembership string + +type queryMembershipValuesType struct { + None QueryMembership + Direct QueryMembership + Expanded QueryMembership + ExpandedUp QueryMembership + ExpandedDown QueryMembership +} + +var QueryMembershipValues = queryMembershipValuesType{ + // Query will not return any membership data + None: "none", + // Query will return only direct membership data + Direct: "direct", + // Query will return expanded membership data + Expanded: "expanded", + // Query will return expanded up membership data (parents only) + ExpandedUp: "expandedUp", + // Query will return expanded down membership data (children only) + ExpandedDown: "expandedDown", +} + +// [Flags] +type ReadIdentitiesOptions string + +type readIdentitiesOptionsValuesType struct { + None ReadIdentitiesOptions + FilterIllegalMemberships ReadIdentitiesOptions +} + +var ReadIdentitiesOptionsValues = readIdentitiesOptionsValuesType{ + None: "none", + FilterIllegalMemberships: "filterIllegalMemberships", +} + +type SwapIdentityInfo struct { + Id1 *uuid.UUID `json:"id1,omitempty"` + Id2 *uuid.UUID `json:"id2,omitempty"` +} + +type TenantInfo struct { + HomeTenant *bool `json:"homeTenant,omitempty"` + TenantId *uuid.UUID `json:"tenantId,omitempty"` + TenantName *string `json:"tenantName,omitempty"` + VerifiedDomains *[]string `json:"verifiedDomains,omitempty"` +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/models.go new file mode 100644 index 0000000000..0079749ffa --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/models.go @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azuredevops + +import ( + "encoding/json" + "strconv" + "strings" + "time" + + "github.com/google/uuid" +) + +// ApiResourceLocation Information about the location of a REST API resource +type ApiResourceLocation struct { + // Area name for this resource + Area *string `json:"area,omitempty"` + // Unique Identifier for this location + Id *uuid.UUID `json:"id,omitempty"` + // Maximum api version that this resource supports (current server version for this resource) + MaxVersion *string `json:"maxVersion,omitempty"` + // Minimum api version that this resource supports + MinVersion *string `json:"minVersion,omitempty"` + // The latest version of this resource location that is in "Release" (non-preview) mode + ReleasedVersion *string `json:"releasedVersion,omitempty"` + // Resource name + ResourceName *string `json:"resourceName,omitempty"` + // The current resource version supported by this resource location + ResourceVersion *int `json:"resourceVersion,omitempty"` + // This location's route template (templated relative path) + RouteTemplate *string `json:"routeTemplate,omitempty"` +} + +// WrappedImproperError +type WrappedImproperError struct { + Count *int `json:"count,omitempty"` + Value *ImproperError `json:"value,omitempty"` +} + +// ImproperError +type ImproperError struct { + Message *string `json:"Message,omitempty"` +} + +// KeyValuePair +type KeyValuePair struct { + Key *interface{} `json:"key,omitempty"` + Value *interface{} `json:"value,omitempty"` +} + +// ResourceAreaInfo +type ResourceAreaInfo struct { + Id *uuid.UUID `json:"id,omitempty"` + LocationUrl *string `json:"locationUrl,omitempty"` + Name *string `json:"name,omitempty"` +} + +type Time struct { + Time time.Time +} + +func (t *Time) UnmarshalJSON(b []byte) error { + t2 := time.Time{} + err := json.Unmarshal(b, &t2) + + if err != nil { + parseError, ok := err.(*time.ParseError) + if ok { + if parseError.Value == "\"0001-01-01T00:00:00\"" { + // ignore errors for 0001-01-01T00:00:00 dates. The Azure DevOps service + // returns default dates in a format that is invalid for a time.Time. The + // correct value would have a 'z' at the end to represent utc. We are going + // to ignore this error, and set the value to the default time.Time value. + // https://github.com/microsoft/azure-devops-go-api/issues/17 + err = nil + } else { + // workaround for bug https://github.com/microsoft/azure-devops-go-api/issues/59 + // policy.CreatePolicyConfiguration returns an invalid date format of form + // "2006-01-02T15:04:05.999999999" + var innerError error + t2, innerError = time.Parse("2006-01-02T15:04:05.999999999", strings.Trim(parseError.Value, "\"")) + if innerError == nil { + err = nil + } + } + } + } + + t.Time = t2 + return err +} + +func (t *Time) MarshalJSON() ([]byte, error) { + return json.Marshal(t.Time) +} + +// AsQueryParameter formats time value for query parameter usage. +func (t Time) AsQueryParameter() string { + return t.Time.Format(time.RFC3339Nano) +} + +func (t Time) String() string { + return t.Time.String() +} + +func (t Time) Equal(u Time) bool { + return t.Time.Equal(u.Time) +} + +// ServerSystemError +type ServerSystemError struct { + ClassName *string `json:"className,omitempty"` + InnerException *ServerSystemError `json:"innerException,omitempty"` + Message *string `json:"message,omitempty"` +} + +func (e ServerSystemError) Error() string { + return *e.Message +} + +// VssJsonCollectionWrapper - +type VssJsonCollectionWrapper struct { + Count *int `json:"count"` + Value *[]interface{} `json:"value"` +} + +// WrappedError +type WrappedError struct { + ExceptionId *string `json:"$id,omitempty"` + InnerError *WrappedError `json:"innerException,omitempty"` + Message *string `json:"message,omitempty"` + TypeName *string `json:"typeName,omitempty"` + TypeKey *string `json:"typeKey,omitempty"` + ErrorCode *int `json:"errorCode,omitempty"` + EventId *int `json:"eventId,omitempty"` + CustomProperties *map[string]interface{} `json:"customProperties,omitempty"` + StatusCode *int +} + +func (e WrappedError) Error() string { + if e.Message == nil { + if e.StatusCode != nil { + return "REST call returned status code " + strconv.Itoa(*e.StatusCode) + } + return "" + } + return *e.Message +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/operations/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/operations/client.go new file mode 100644 index 0000000000..f6939dc8c4 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/operations/client.go @@ -0,0 +1,64 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package operations + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +type Client interface { + // Gets an operation from the the operationId using the given pluginId. + GetOperation(context.Context, GetOperationArgs) (*Operation, error) +} + +type ClientImpl struct { + Client azuredevops.Client +} + +func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { + client := connection.GetClientByUrl(connection.BaseUrl) + return &ClientImpl{ + Client: *client, + } +} + +// Gets an operation from the the operationId using the given pluginId. +func (client *ClientImpl) GetOperation(ctx context.Context, args GetOperationArgs) (*Operation, error) { + routeValues := make(map[string]string) + if args.OperationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.OperationId"} + } + routeValues["operationId"] = (*args.OperationId).String() + + queryParams := url.Values{} + if args.PluginId != nil { + queryParams.Add("pluginId", (*args.PluginId).String()) + } + locationId, _ := uuid.Parse("9a1b74b4-2ca8-4a9f-8470-c2f2e6fdc949") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Operation + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetOperation function +type GetOperationArgs struct { + // (required) The ID for the operation. + OperationId *uuid.UUID + // (optional) The ID for the plugin. + PluginId *uuid.UUID +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/operations/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/operations/models.go new file mode 100644 index 0000000000..49abd0b048 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/operations/models.go @@ -0,0 +1,77 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package operations + +import ( + "github.com/google/uuid" +) + +// Contains information about the progress or result of an async operation. +type Operation struct { + // Unique identifier for the operation. + Id *uuid.UUID `json:"id,omitempty"` + // Unique identifier for the plugin. + PluginId *uuid.UUID `json:"pluginId,omitempty"` + // The current status of the operation. + Status *OperationStatus `json:"status,omitempty"` + // URL to get the full operation object. + Url *string `json:"url,omitempty"` + // Links to other related objects. + Links interface{} `json:"_links,omitempty"` + // Detailed messaged about the status of an operation. + DetailedMessage *string `json:"detailedMessage,omitempty"` + // Result message for an operation. + ResultMessage *string `json:"resultMessage,omitempty"` + // URL to the operation result. + ResultUrl *OperationResultReference `json:"resultUrl,omitempty"` +} + +// Reference for an async operation. +type OperationReference struct { + // Unique identifier for the operation. + Id *uuid.UUID `json:"id,omitempty"` + // Unique identifier for the plugin. + PluginId *uuid.UUID `json:"pluginId,omitempty"` + // The current status of the operation. + Status *OperationStatus `json:"status,omitempty"` + // URL to get the full operation object. + Url *string `json:"url,omitempty"` +} + +type OperationResultReference struct { + // URL to the operation result. + ResultUrl *string `json:"resultUrl,omitempty"` +} + +// The status of an operation. +type OperationStatus string + +type operationStatusValuesType struct { + NotSet OperationStatus + Queued OperationStatus + InProgress OperationStatus + Cancelled OperationStatus + Succeeded OperationStatus + Failed OperationStatus +} + +var OperationStatusValues = operationStatusValuesType{ + // The operation does not have a status set. + NotSet: "notSet", + // The operation has been queued. + Queued: "queued", + // The operation is in progress. + InProgress: "inProgress", + // The operation was cancelled by the user. + Cancelled: "cancelled", + // The operation completed successfully. + Succeeded: "succeeded", + // The operation completed with a failure. + Failed: "failed", +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/policy/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/policy/client.go new file mode 100644 index 0000000000..985639faec --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/policy/client.go @@ -0,0 +1,500 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package policy + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("fb13a388-40dd-4a04-b530-013a739c72ef") + +type Client interface { + // Create a policy configuration of a given policy type. + CreatePolicyConfiguration(context.Context, CreatePolicyConfigurationArgs) (*PolicyConfiguration, error) + // Delete a policy configuration by its ID. + DeletePolicyConfiguration(context.Context, DeletePolicyConfigurationArgs) error + // Get a policy configuration by its ID. + GetPolicyConfiguration(context.Context, GetPolicyConfigurationArgs) (*PolicyConfiguration, error) + // Retrieve a specific revision of a given policy by ID. + GetPolicyConfigurationRevision(context.Context, GetPolicyConfigurationRevisionArgs) (*PolicyConfiguration, error) + // Retrieve all revisions for a given policy. + GetPolicyConfigurationRevisions(context.Context, GetPolicyConfigurationRevisionsArgs) (*[]PolicyConfiguration, error) + // Get a list of policy configurations in a project. + GetPolicyConfigurations(context.Context, GetPolicyConfigurationsArgs) (*GetPolicyConfigurationsResponseValue, error) + // [Preview API] Gets the present evaluation state of a policy. + GetPolicyEvaluation(context.Context, GetPolicyEvaluationArgs) (*PolicyEvaluationRecord, error) + // [Preview API] Retrieves a list of all the policy evaluation statuses for a specific pull request. + GetPolicyEvaluations(context.Context, GetPolicyEvaluationsArgs) (*[]PolicyEvaluationRecord, error) + // Retrieve a specific policy type by ID. + GetPolicyType(context.Context, GetPolicyTypeArgs) (*PolicyType, error) + // Retrieve all available policy types. + GetPolicyTypes(context.Context, GetPolicyTypesArgs) (*[]PolicyType, error) + // [Preview API] Requeue the policy evaluation. + RequeuePolicyEvaluation(context.Context, RequeuePolicyEvaluationArgs) (*PolicyEvaluationRecord, error) + // Update a policy configuration by its ID. + UpdatePolicyConfiguration(context.Context, UpdatePolicyConfigurationArgs) (*PolicyConfiguration, error) +} + +type ClientImpl struct { + Client azuredevops.Client +} + +func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { + client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) + if err != nil { + return nil, err + } + return &ClientImpl{ + Client: *client, + }, nil +} + +// Create a policy configuration of a given policy type. +func (client *ClientImpl) CreatePolicyConfiguration(ctx context.Context, args CreatePolicyConfigurationArgs) (*PolicyConfiguration, error) { + if args.Configuration == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Configuration"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ConfigurationId != nil { + routeValues["configurationId"] = strconv.Itoa(*args.ConfigurationId) + } + + body, marshalErr := json.Marshal(*args.Configuration) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("dad91cbe-d183-45f8-9c6e-9c1164472121") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PolicyConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePolicyConfiguration function +type CreatePolicyConfigurationArgs struct { + // (required) The policy configuration to create. + Configuration *PolicyConfiguration + // (required) Project ID or project name + Project *string + // (optional) + ConfigurationId *int +} + +// Delete a policy configuration by its ID. +func (client *ClientImpl) DeletePolicyConfiguration(ctx context.Context, args DeletePolicyConfigurationArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ConfigurationId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ConfigurationId"} + } + routeValues["configurationId"] = strconv.Itoa(*args.ConfigurationId) + + locationId, _ := uuid.Parse("dad91cbe-d183-45f8-9c6e-9c1164472121") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeletePolicyConfiguration function +type DeletePolicyConfigurationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the policy configuration to delete. + ConfigurationId *int +} + +// Get a policy configuration by its ID. +func (client *ClientImpl) GetPolicyConfiguration(ctx context.Context, args GetPolicyConfigurationArgs) (*PolicyConfiguration, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ConfigurationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ConfigurationId"} + } + routeValues["configurationId"] = strconv.Itoa(*args.ConfigurationId) + + locationId, _ := uuid.Parse("dad91cbe-d183-45f8-9c6e-9c1164472121") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PolicyConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPolicyConfiguration function +type GetPolicyConfigurationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the policy configuration + ConfigurationId *int +} + +// Retrieve a specific revision of a given policy by ID. +func (client *ClientImpl) GetPolicyConfigurationRevision(ctx context.Context, args GetPolicyConfigurationRevisionArgs) (*PolicyConfiguration, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ConfigurationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ConfigurationId"} + } + routeValues["configurationId"] = strconv.Itoa(*args.ConfigurationId) + if args.RevisionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RevisionId"} + } + routeValues["revisionId"] = strconv.Itoa(*args.RevisionId) + + locationId, _ := uuid.Parse("fe1e68a2-60d3-43cb-855b-85e41ae97c95") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PolicyConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPolicyConfigurationRevision function +type GetPolicyConfigurationRevisionArgs struct { + // (required) Project ID or project name + Project *string + // (required) The policy configuration ID. + ConfigurationId *int + // (required) The revision ID. + RevisionId *int +} + +// Retrieve all revisions for a given policy. +func (client *ClientImpl) GetPolicyConfigurationRevisions(ctx context.Context, args GetPolicyConfigurationRevisionsArgs) (*[]PolicyConfiguration, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ConfigurationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ConfigurationId"} + } + routeValues["configurationId"] = strconv.Itoa(*args.ConfigurationId) + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + locationId, _ := uuid.Parse("fe1e68a2-60d3-43cb-855b-85e41ae97c95") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []PolicyConfiguration + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPolicyConfigurationRevisions function +type GetPolicyConfigurationRevisionsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The policy configuration ID. + ConfigurationId *int + // (optional) The number of revisions to retrieve. + Top *int + // (optional) The number of revisions to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100. + Skip *int +} + +// Get a list of policy configurations in a project. +func (client *ClientImpl) GetPolicyConfigurations(ctx context.Context, args GetPolicyConfigurationsArgs) (*GetPolicyConfigurationsResponseValue, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.Scope != nil { + queryParams.Add("scope", *args.Scope) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.PolicyType != nil { + queryParams.Add("policyType", (*args.PolicyType).String()) + } + locationId, _ := uuid.Parse("dad91cbe-d183-45f8-9c6e-9c1164472121") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetPolicyConfigurationsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetPolicyConfigurations function +type GetPolicyConfigurationsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) [Provided for legacy reasons] The scope on which a subset of policies is defined. + Scope *string + // (optional) Maximum number of policies to return. + Top *int + // (optional) The continuation token used for pagination. + ContinuationToken *string + // (optional) Filter returned policies to only this type + PolicyType *uuid.UUID +} + +// Return type for the GetPolicyConfigurations function +type GetPolicyConfigurationsResponseValue struct { + Value []PolicyConfiguration + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Gets the present evaluation state of a policy. +func (client *ClientImpl) GetPolicyEvaluation(ctx context.Context, args GetPolicyEvaluationArgs) (*PolicyEvaluationRecord, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.EvaluationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EvaluationId"} + } + routeValues["evaluationId"] = (*args.EvaluationId).String() + + locationId, _ := uuid.Parse("46aecb7a-5d2c-4647-897b-0209505a9fe4") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PolicyEvaluationRecord + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPolicyEvaluation function +type GetPolicyEvaluationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the policy evaluation to be retrieved. + EvaluationId *uuid.UUID +} + +// [Preview API] Retrieves a list of all the policy evaluation statuses for a specific pull request. +func (client *ClientImpl) GetPolicyEvaluations(ctx context.Context, args GetPolicyEvaluationsArgs) (*[]PolicyEvaluationRecord, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.ArtifactId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "artifactId"} + } + queryParams.Add("artifactId", *args.ArtifactId) + if args.IncludeNotApplicable != nil { + queryParams.Add("includeNotApplicable", strconv.FormatBool(*args.IncludeNotApplicable)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + locationId, _ := uuid.Parse("c23ddff5-229c-4d04-a80b-0fdce9f360c8") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []PolicyEvaluationRecord + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPolicyEvaluations function +type GetPolicyEvaluationsArgs struct { + // (required) Project ID or project name + Project *string + // (required) A string which uniquely identifies the target of a policy evaluation. + ArtifactId *string + // (optional) Some policies might determine that they do not apply to a specific pull request. Setting this parameter to true will return evaluation records even for policies which don't apply to this pull request. + IncludeNotApplicable *bool + // (optional) The number of policy evaluation records to retrieve. + Top *int + // (optional) The number of policy evaluation records to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100. + Skip *int +} + +// Retrieve a specific policy type by ID. +func (client *ClientImpl) GetPolicyType(ctx context.Context, args GetPolicyTypeArgs) (*PolicyType, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TypeId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TypeId"} + } + routeValues["typeId"] = (*args.TypeId).String() + + locationId, _ := uuid.Parse("44096322-2d3d-466a-bb30-d1b7de69f61f") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PolicyType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPolicyType function +type GetPolicyTypeArgs struct { + // (required) Project ID or project name + Project *string + // (required) The policy ID. + TypeId *uuid.UUID +} + +// Retrieve all available policy types. +func (client *ClientImpl) GetPolicyTypes(ctx context.Context, args GetPolicyTypesArgs) (*[]PolicyType, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + locationId, _ := uuid.Parse("44096322-2d3d-466a-bb30-d1b7de69f61f") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []PolicyType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPolicyTypes function +type GetPolicyTypesArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] Requeue the policy evaluation. +func (client *ClientImpl) RequeuePolicyEvaluation(ctx context.Context, args RequeuePolicyEvaluationArgs) (*PolicyEvaluationRecord, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.EvaluationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EvaluationId"} + } + routeValues["evaluationId"] = (*args.EvaluationId).String() + + locationId, _ := uuid.Parse("46aecb7a-5d2c-4647-897b-0209505a9fe4") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PolicyEvaluationRecord + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RequeuePolicyEvaluation function +type RequeuePolicyEvaluationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the policy evaluation to be retrieved. + EvaluationId *uuid.UUID +} + +// Update a policy configuration by its ID. +func (client *ClientImpl) UpdatePolicyConfiguration(ctx context.Context, args UpdatePolicyConfigurationArgs) (*PolicyConfiguration, error) { + if args.Configuration == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Configuration"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ConfigurationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ConfigurationId"} + } + routeValues["configurationId"] = strconv.Itoa(*args.ConfigurationId) + + body, marshalErr := json.Marshal(*args.Configuration) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("dad91cbe-d183-45f8-9c6e-9c1164472121") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PolicyConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePolicyConfiguration function +type UpdatePolicyConfigurationArgs struct { + // (required) The policy configuration to update. + Configuration *PolicyConfiguration + // (required) Project ID or project name + Project *string + // (required) ID of the existing policy configuration to be updated. + ConfigurationId *int +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/policy/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/policy/models.go new file mode 100644 index 0000000000..c0c405c317 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/policy/models.go @@ -0,0 +1,134 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package policy + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// The full policy configuration with settings. +type PolicyConfiguration struct { + // The policy configuration ID. + Id *int `json:"id,omitempty"` + // The policy configuration type. + Type *PolicyTypeRef `json:"type,omitempty"` + // The URL where the policy configuration can be retrieved. + Url *string `json:"url,omitempty"` + // The policy configuration revision ID. + Revision *int `json:"revision,omitempty"` + // The links to other objects related to this object. + Links interface{} `json:"_links,omitempty"` + // A reference to the identity that created the policy. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // The date and time when the policy was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Indicates whether the policy is blocking. + IsBlocking *bool `json:"isBlocking,omitempty"` + // Indicates whether the policy has been (soft) deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Indicates whether the policy is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // The policy configuration settings. + Settings interface{} `json:"settings,omitempty"` +} + +// Policy configuration reference. +type PolicyConfigurationRef struct { + // The policy configuration ID. + Id *int `json:"id,omitempty"` + // The policy configuration type. + Type *PolicyTypeRef `json:"type,omitempty"` + // The URL where the policy configuration can be retrieved. + Url *string `json:"url,omitempty"` +} + +// This record encapsulates the current state of a policy as it applies to one specific pull request. Each pull request has a unique PolicyEvaluationRecord for each pull request which the policy applies to. +type PolicyEvaluationRecord struct { + // Links to other related objects + Links interface{} `json:"_links,omitempty"` + // A string which uniquely identifies the target of a policy evaluation. + ArtifactId *string `json:"artifactId,omitempty"` + // Time when this policy finished evaluating on this pull request. + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Contains all configuration data for the policy which is being evaluated. + Configuration *PolicyConfiguration `json:"configuration,omitempty"` + // Internal context data of this policy evaluation. + Context interface{} `json:"context,omitempty"` + // Guid which uniquely identifies this evaluation record (one policy running on one pull request). + EvaluationId *uuid.UUID `json:"evaluationId,omitempty"` + // Time when this policy was first evaluated on this pull request. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` + // Status of the policy (Running, Approved, Failed, etc.) + Status *PolicyEvaluationStatus `json:"status,omitempty"` +} + +// Status of a policy which is running against a specific pull request. +type PolicyEvaluationStatus string + +type policyEvaluationStatusValuesType struct { + Queued PolicyEvaluationStatus + Running PolicyEvaluationStatus + Approved PolicyEvaluationStatus + Rejected PolicyEvaluationStatus + NotApplicable PolicyEvaluationStatus + Broken PolicyEvaluationStatus +} + +var PolicyEvaluationStatusValues = policyEvaluationStatusValuesType{ + // The policy is either queued to run, or is waiting for some event before progressing. + Queued: "queued", + // The policy is currently running. + Running: "running", + // The policy has been fulfilled for this pull request. + Approved: "approved", + // The policy has rejected this pull request. + Rejected: "rejected", + // The policy does not apply to this pull request. + NotApplicable: "notApplicable", + // The policy has encountered an unexpected error. + Broken: "broken", +} + +// User-friendly policy type with description (used for querying policy types). +type PolicyType struct { + // Display name of the policy type. + DisplayName *string `json:"displayName,omitempty"` + // The policy type ID. + Id *uuid.UUID `json:"id,omitempty"` + // The URL where the policy type can be retrieved. + Url *string `json:"url,omitempty"` + // The links to other objects related to this object. + Links interface{} `json:"_links,omitempty"` + // Detailed description of the policy type. + Description *string `json:"description,omitempty"` +} + +// Policy type reference. +type PolicyTypeRef struct { + // Display name of the policy type. + DisplayName *string `json:"displayName,omitempty"` + // The policy type ID. + Id *uuid.UUID `json:"id,omitempty"` + // The URL where the policy type can be retrieved. + Url *string `json:"url,omitempty"` +} + +// A particular revision for a policy configuration. +type VersionedPolicyConfigurationRef struct { + // The policy configuration ID. + Id *int `json:"id,omitempty"` + // The policy configuration type. + Type *PolicyTypeRef `json:"type,omitempty"` + // The URL where the policy configuration can be retrieved. + Url *string `json:"url,omitempty"` + // The policy configuration revision ID. + Revision *int `json:"revision,omitempty"` +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/system/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/system/models.go new file mode 100644 index 0000000000..245ca996ad --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/system/models.go @@ -0,0 +1,97 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package system + +type SqlDbType string + +type sqlDbTypeValuesType struct { + BigInt SqlDbType + Binary SqlDbType + Bit SqlDbType + Char SqlDbType + DateTime SqlDbType + Decimal SqlDbType + Float SqlDbType + Image SqlDbType + Int SqlDbType + Money SqlDbType + NChar SqlDbType + NText SqlDbType + NVarChar SqlDbType + Real SqlDbType + UniqueIdentifier SqlDbType + SmallDateTime SqlDbType + SmallInt SqlDbType + SmallMoney SqlDbType + Text SqlDbType + Timestamp SqlDbType + TinyInt SqlDbType + VarBinary SqlDbType + VarChar SqlDbType + Variant SqlDbType + Xml SqlDbType + Udt SqlDbType + Structured SqlDbType + Date SqlDbType + Time SqlDbType + DateTime2 SqlDbType + DateTimeOffset SqlDbType +} + +var SqlDbTypeValues = sqlDbTypeValuesType{ + BigInt: "bigInt", + Binary: "binary", + Bit: "bit", + Char: "char", + DateTime: "dateTime", + Decimal: "decimal", + Float: "float", + Image: "image", + Int: "int", + Money: "money", + NChar: "nChar", + NText: "nText", + NVarChar: "nVarChar", + Real: "real", + UniqueIdentifier: "uniqueIdentifier", + SmallDateTime: "smallDateTime", + SmallInt: "smallInt", + SmallMoney: "smallMoney", + Text: "text", + Timestamp: "timestamp", + TinyInt: "tinyInt", + VarBinary: "varBinary", + VarChar: "varChar", + Variant: "variant", + Xml: "xml", + Udt: "udt", + Structured: "structured", + Date: "date", + Time: "time", + DateTime2: "dateTime2", + DateTimeOffset: "dateTimeOffset", +} + +type TraceLevel string + +type traceLevelValuesType struct { + Off TraceLevel + Error TraceLevel + Warning TraceLevel + Info TraceLevel + Verbose TraceLevel +} + +var TraceLevelValues = traceLevelValuesType{ + Off: "off", + Error: "error", + Warning: "warning", + Info: "info", + Verbose: "verbose", +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/version.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/version.go new file mode 100644 index 0000000000..443147c517 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/version.go @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azuredevops + +import ( + "strconv" + "strings" +) + +type Version struct { + Major int + Minor int +} + +func NewVersion(version string) (*Version, error) { + split := strings.Split(version, ".") + if len(split) > 1 { + major, err := strconv.Atoi(split[0]) + if err != nil { + return nil, err + } + minor, err := strconv.Atoi(split[1]) + if err != nil { + return nil, err + } + return &Version{ + Major: major, + Minor: minor, + }, nil + } + return nil, &InvalidVersionStringError{version: version} +} + +func (version Version) CompareTo(compareToVersion Version) int { + if version.Major > compareToVersion.Major { + return 1 + } else if version.Major < compareToVersion.Major { + return -1 + } else if version.Minor > compareToVersion.Minor { + return 1 + } else if version.Minor < compareToVersion.Minor { + return -1 + } + return 0 +} + +func (version Version) String() string { + return strconv.Itoa(version.Major) + "." + strconv.Itoa(version.Minor) +} + +type InvalidVersionStringError struct { + version string +} + +func (e *InvalidVersionStringError) Error() string { + return "The version string was invalid: " + e.version +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/versionnegotiation.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/versionnegotiation.go new file mode 100644 index 0000000000..f1a2a2f33a --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/versionnegotiation.go @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azuredevops + +import "strconv" + +func negotiateRequestVersion(location *ApiResourceLocation, apiVersion string) (string, error) { + if apiVersion == "" { + // if no api-version is sent to the server, the server will decide the version. The server uses the latest + // released version if the endpoint has been released, otherwise it will use the latest preview version. + return apiVersion, nil + } + + matches := apiVersionRegEx.FindStringSubmatch(apiVersion) + if len(matches) == 0 && matches[0] != "" { + return apiVersion, &InvalidApiVersion{apiVersion} + } + + requestedApiVersion, err := NewVersion(matches[1]) + if err != nil { + return apiVersion, err + } + locationMinVersion, err := NewVersion(*location.MinVersion) + if err != nil { + return apiVersion, err + } + if locationMinVersion.CompareTo(*requestedApiVersion) > 0 { + // Client is older than the server. The server no longer supports this + // resource (deprecated). + return apiVersion, nil + } else { + locationMaxVersion, err := NewVersion(*location.MaxVersion) + if err != nil { + return apiVersion, err + } + if locationMaxVersion.CompareTo(*requestedApiVersion) < 0 { + // Client is newer than the server. Negotiate down to the latest version + // on the server + negotiatedVersion := string(*location.MaxVersion) + if *location.ReleasedVersion < *location.MaxVersion { + negotiatedVersion += "-preview" + } + return negotiatedVersion, nil + } else { + // We can send at the requested api version. Make sure the resource version + // is not bigger than what the server supports + negotiatedVersion := matches[1] + if len(matches) > 3 && matches[3] != "" { // matches '-preview' + negotiatedVersion += "-preview" + if len(matches) > 5 && matches[5] != "" { // has a resource version + requestedResourceVersion, _ := strconv.Atoi(matches[5]) + if *location.ResourceVersion < requestedResourceVersion { + negotiatedVersion += "." + strconv.Itoa(*location.ResourceVersion) + } else { + negotiatedVersion += "." + matches[5] + } + } + } else { + // requesting released version, ensure server supports a released version, and if not append '-preview' + locationReleasedVersion, err := NewVersion(*location.ReleasedVersion) + if err != nil { + return apiVersion, err + } + if (locationReleasedVersion.Major == 0 && locationReleasedVersion.Minor == 0) || locationReleasedVersion.CompareTo(*requestedApiVersion) < 0 { + negotiatedVersion += "-preview" + } + } + return negotiatedVersion, nil + } + } +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/webapi/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/webapi/models.go new file mode 100644 index 0000000000..b653f7d92b --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/webapi/models.go @@ -0,0 +1,335 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package webapi + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/system" +) + +// Information about the location of a REST API resource +type ApiResourceLocation struct { + // Area name for this resource + Area *string `json:"area,omitempty"` + // Unique Identifier for this location + Id *uuid.UUID `json:"id,omitempty"` + // Maximum api version that this resource supports (current server version for this resource) + MaxVersion *string `json:"maxVersion,omitempty"` + // Minimum api version that this resource supports + MinVersion *string `json:"minVersion,omitempty"` + // The latest version of this resource location that is in "Release" (non-preview) mode + ReleasedVersion *string `json:"releasedVersion,omitempty"` + // Resource name + ResourceName *string `json:"resourceName,omitempty"` + // The current resource version supported by this resource location + ResourceVersion *int `json:"resourceVersion,omitempty"` + // This location's route template (templated relative path) + RouteTemplate *string `json:"routeTemplate,omitempty"` +} + +// [Flags] Enumeration of the options that can be passed in on Connect. +type ConnectOptions string + +type connectOptionsValuesType struct { + None ConnectOptions + IncludeServices ConnectOptions + IncludeLastUserAccess ConnectOptions + IncludeInheritedDefinitionsOnly ConnectOptions + IncludeNonInheritedDefinitionsOnly ConnectOptions +} + +var ConnectOptionsValues = connectOptionsValuesType{ + // Retrieve no optional data. + None: "none", + // Includes information about AccessMappings and ServiceDefinitions. + IncludeServices: "includeServices", + // Includes the last user access for this host. + IncludeLastUserAccess: "includeLastUserAccess", + // This is only valid on the deployment host and when true. Will only return inherited definitions. + IncludeInheritedDefinitionsOnly: "includeInheritedDefinitionsOnly", + // When true will only return non inherited definitions. Only valid at non-deployment host. + IncludeNonInheritedDefinitionsOnly: "includeNonInheritedDefinitionsOnly", +} + +// [Flags] +type DeploymentFlags string + +type deploymentFlagsValuesType struct { + None DeploymentFlags + Hosted DeploymentFlags + OnPremises DeploymentFlags +} + +var DeploymentFlagsValues = deploymentFlagsValuesType{ + None: "none", + Hosted: "hosted", + OnPremises: "onPremises", +} + +// Defines an "actor" for an event. +type EventActor struct { + // Required: This is the identity of the user for the specified role. + Id *uuid.UUID `json:"id,omitempty"` + // Required: The event specific name of a role. + Role *string `json:"role,omitempty"` +} + +// Defines a scope for an event. +type EventScope struct { + // Required: This is the identity of the scope for the type. + Id *uuid.UUID `json:"id,omitempty"` + // Optional: The display name of the scope + Name *string `json:"name,omitempty"` + // Required: The event specific type of a scope. + Type *string `json:"type,omitempty"` +} + +type IdentityRef struct { + // This field contains zero or more interesting links about the graph subject. These links may be invoked to obtain additional relationships or more detailed information about this graph subject. + Links interface{} `json:"_links,omitempty"` + // The descriptor is the primary way to reference the graph subject while the system is running. This field will uniquely identify the same graph subject across both Accounts and Organizations. + Descriptor *string `json:"descriptor,omitempty"` + // This is the non-unique display name of the graph subject. To change this field, you must alter its value in the source provider. + DisplayName *string `json:"displayName,omitempty"` + // This url is the full route to the source resource of this graph subject. + Url *string `json:"url,omitempty"` + // Deprecated - Can be retrieved by querying the Graph user referenced in the "self" entry of the IdentityRef "_links" dictionary + DirectoryAlias *string `json:"directoryAlias,omitempty"` + Id *string `json:"id,omitempty"` + // Deprecated - Available in the "avatar" entry of the IdentityRef "_links" dictionary + ImageUrl *string `json:"imageUrl,omitempty"` + // Deprecated - Can be retrieved by querying the Graph membership state referenced in the "membershipState" entry of the GraphUser "_links" dictionary + Inactive *bool `json:"inactive,omitempty"` + // Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsAadUserType/Descriptor.IsAadGroupType) + IsAadIdentity *bool `json:"isAadIdentity,omitempty"` + // Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsGroupType) + IsContainer *bool `json:"isContainer,omitempty"` + IsDeletedInOrigin *bool `json:"isDeletedInOrigin,omitempty"` + // Deprecated - not in use in most preexisting implementations of ToIdentityRef + ProfileUrl *string `json:"profileUrl,omitempty"` + // Deprecated - use Domain+PrincipalName instead + UniqueName *string `json:"uniqueName,omitempty"` +} + +type IdentityRefWithEmail struct { + // This field contains zero or more interesting links about the graph subject. These links may be invoked to obtain additional relationships or more detailed information about this graph subject. + Links interface{} `json:"_links,omitempty"` + // The descriptor is the primary way to reference the graph subject while the system is running. This field will uniquely identify the same graph subject across both Accounts and Organizations. + Descriptor *string `json:"descriptor,omitempty"` + // This is the non-unique display name of the graph subject. To change this field, you must alter its value in the source provider. + DisplayName *string `json:"displayName,omitempty"` + // This url is the full route to the source resource of this graph subject. + Url *string `json:"url,omitempty"` + // Deprecated - Can be retrieved by querying the Graph user referenced in the "self" entry of the IdentityRef "_links" dictionary + DirectoryAlias *string `json:"directoryAlias,omitempty"` + Id *string `json:"id,omitempty"` + // Deprecated - Available in the "avatar" entry of the IdentityRef "_links" dictionary + ImageUrl *string `json:"imageUrl,omitempty"` + // Deprecated - Can be retrieved by querying the Graph membership state referenced in the "membershipState" entry of the GraphUser "_links" dictionary + Inactive *bool `json:"inactive,omitempty"` + // Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsAadUserType/Descriptor.IsAadGroupType) + IsAadIdentity *bool `json:"isAadIdentity,omitempty"` + // Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsGroupType) + IsContainer *bool `json:"isContainer,omitempty"` + IsDeletedInOrigin *bool `json:"isDeletedInOrigin,omitempty"` + // Deprecated - not in use in most preexisting implementations of ToIdentityRef + ProfileUrl *string `json:"profileUrl,omitempty"` + // Deprecated - use Domain+PrincipalName instead + UniqueName *string `json:"uniqueName,omitempty"` + PreferredEmailAddress *string `json:"preferredEmailAddress,omitempty"` +} + +// The JSON model for a JSON Patch operation +type JsonPatchOperation struct { + // The path to copy from for the Move/Copy operation. + From *string `json:"from,omitempty"` + // The patch operation + Op *Operation `json:"op,omitempty"` + // The path for the operation. In the case of an array, a zero based index can be used to specify the position in the array (e.g. /biscuits/0/name). The "-" character can be used instead of an index to insert at the end of the array (e.g. /biscuits/-). + Path *string `json:"path,omitempty"` + // The value for the operation. This is either a primitive or a JToken. + Value interface{} `json:"value,omitempty"` +} + +type JsonWebToken struct { + // Gets a value indicating whether or not this token has been successfully authenticated with the remote server. + IsAuthenticated *bool `json:"isAuthenticated,omitempty"` + // Metadata about the token in a collection of properties. + Properties *map[string]string `json:"properties,omitempty"` +} + +type JWTAlgorithm string + +type jwtAlgorithmValuesType struct { + None JWTAlgorithm + HS256 JWTAlgorithm + RS256 JWTAlgorithm +} + +var JWTAlgorithmValues = jwtAlgorithmValuesType{ + None: "none", + HS256: "hS256", + RS256: "rS256", +} + +type Operation string + +type operationValuesType struct { + Add Operation + Remove Operation + Replace Operation + Move Operation + Copy Operation + Test Operation +} + +var OperationValues = operationValuesType{ + Add: "add", + Remove: "remove", + Replace: "replace", + Move: "move", + Copy: "copy", + Test: "test", +} + +// Represents the public key portion of an RSA asymmetric key. +type PublicKey struct { + // Gets or sets the exponent for the public key. + Exponent *[]byte `json:"exponent,omitempty"` + // Gets or sets the modulus for the public key. + Modulus *[]byte `json:"modulus,omitempty"` +} + +type Publisher struct { + // Name of the publishing service. + Name *string `json:"name,omitempty"` + // Service Owner Guid Eg. Tfs : 00025394-6065-48CA-87D9-7F5672854EF7 + ServiceOwnerId *uuid.UUID `json:"serviceOwnerId,omitempty"` +} + +// The class to represent a REST reference link. RFC: http://tools.ietf.org/html/draft-kelly-json-hal-06 The RFC is not fully implemented, additional properties are allowed on the reference link but as of yet we don't have a need for them. +type ReferenceLink struct { + Href *string `json:"href,omitempty"` +} + +type ResourceRef struct { + Id *string `json:"id,omitempty"` + Url *string `json:"url,omitempty"` +} + +type ServiceEvent struct { + // This is the id of the type. Constants that will be used by subscribers to identify/filter events being published on a topic. + EventType *string `json:"eventType,omitempty"` + // This is the service that published this event. + Publisher *Publisher `json:"publisher,omitempty"` + // The resource object that carries specific information about the event. The object must have the ServiceEventObject applied for serialization/deserialization to work. + Resource interface{} `json:"resource,omitempty"` + // This dictionary carries the context descriptors along with their ids. + ResourceContainers *map[string]interface{} `json:"resourceContainers,omitempty"` + // This is the version of the resource. + ResourceVersion *string `json:"resourceVersion,omitempty"` +} + +// A signed url allowing limited-time anonymous access to private resources. +type SignedUrl struct { + SignatureExpires *azuredevops.Time `json:"signatureExpires,omitempty"` + Url *string `json:"url,omitempty"` +} + +type TeamMember struct { + Identity *IdentityRef `json:"identity,omitempty"` + IsTeamAdmin *bool `json:"isTeamAdmin,omitempty"` +} + +// A single secured timing consisting of a duration and start time +type TimingEntry struct { + // Duration of the entry in ticks + ElapsedTicks *uint64 `json:"elapsedTicks,omitempty"` + // Properties to distinguish timings within the same group or to provide data to send with telemetry + Properties *map[string]interface{} `json:"properties,omitempty"` + // Offset from Server Request Context start time in microseconds + StartOffset *uint64 `json:"startOffset,omitempty"` +} + +// A set of secured performance timings all keyed off of the same string +type TimingGroup struct { + // The total number of timing entries associated with this group + Count *int `json:"count,omitempty"` + // Overall duration of all entries in this group in ticks + ElapsedTicks *uint64 `json:"elapsedTicks,omitempty"` + // A list of timing entries in this group. Only the first few entries in each group are collected. + Timings *[]TimingEntry `json:"timings,omitempty"` +} + +// This class describes a trace filter, i.e. a set of criteria on whether or not a trace event should be emitted +type TraceFilter struct { + Area *string `json:"area,omitempty"` + ExceptionType *string `json:"exceptionType,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Layer *string `json:"layer,omitempty"` + Level *system.TraceLevel `json:"level,omitempty"` + Method *string `json:"method,omitempty"` + // Used to serialize additional identity information (display name, etc) to clients. Not set by default. Server-side callers should use OwnerId. + Owner *IdentityRef `json:"owner,omitempty"` + OwnerId *uuid.UUID `json:"ownerId,omitempty"` + Path *string `json:"path,omitempty"` + ProcessName *string `json:"processName,omitempty"` + Service *string `json:"service,omitempty"` + ServiceHost *uuid.UUID `json:"serviceHost,omitempty"` + TimeCreated *azuredevops.Time `json:"timeCreated,omitempty"` + TraceId *uuid.UUID `json:"traceId,omitempty"` + Tracepoint *int `json:"tracepoint,omitempty"` + Uri *string `json:"uri,omitempty"` + UserAgent *string `json:"userAgent,omitempty"` + UserLogin *string `json:"userLogin,omitempty"` +} + +type VssJsonCollectionWrapper struct { + Count *int `json:"count,omitempty"` + Value *[]interface{} `json:"value,omitempty"` +} + +type VssJsonCollectionWrapperBase struct { + Count *int `json:"count,omitempty"` +} + +// This is the type used for firing notifications intended for the subsystem in the Notifications SDK. For components that can't take a dependency on the Notifications SDK directly, they can use ITeamFoundationEventService.PublishNotification and the Notifications SDK ISubscriber implementation will get it. +type VssNotificationEvent struct { + // Optional: A list of actors which are additional identities with corresponding roles that are relevant to the event. + Actors *[]EventActor `json:"actors,omitempty"` + // Optional: A list of artifacts referenced or impacted by this event. + ArtifactUris *[]string `json:"artifactUris,omitempty"` + // Required: The event payload. If Data is a string, it must be in Json or XML format. Otherwise it must have a serialization format attribute. + Data interface{} `json:"data,omitempty"` + // Required: The name of the event. This event must be registered in the context it is being fired. + EventType *string `json:"eventType,omitempty"` + // How long before the event expires and will be cleaned up. The default is to use the system default. + ExpiresIn interface{} `json:"expiresIn,omitempty"` + // The id of the item, artifact, extension, project, etc. + ItemId *string `json:"itemId,omitempty"` + // How long to wait before processing this event. The default is to process immediately. + ProcessDelay interface{} `json:"processDelay,omitempty"` + // Optional: A list of scopes which are are relevant to the event. + Scopes *[]EventScope `json:"scopes,omitempty"` + // This is the time the original source event for this VssNotificationEvent was created. For example, for something like a build completion notification SourceEventCreatedTime should be the time the build finished not the time this event was raised. + SourceEventCreatedTime *azuredevops.Time `json:"sourceEventCreatedTime,omitempty"` +} + +type WrappedException struct { + CustomProperties *map[string]interface{} `json:"customProperties,omitempty"` + ErrorCode *int `json:"errorCode,omitempty"` + EventId *int `json:"eventId,omitempty"` + HelpLink *string `json:"helpLink,omitempty"` + InnerException *WrappedException `json:"innerException,omitempty"` + Message *string `json:"message,omitempty"` + StackTrace *string `json:"stackTrace,omitempty"` + TypeKey *string `json:"typeKey,omitempty"` + TypeName *string `json:"typeName,omitempty"` +} diff --git a/wire_gen.go b/wire_gen.go index c243b3e17d..2db118e329 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -149,7 +149,8 @@ func InitializeApp() (*App, error) { imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) argoK8sClientImpl := argocdServer.NewArgoK8sClientImpl(sugaredLogger) - gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl) + gitCliUtil := util.NewGitCliUtil(sugaredLogger) + gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) if err != nil { return nil, err }